本文整理汇总了Java中co.aikar.timings.Timings类的典型用法代码示例。如果您正苦于以下问题:Java Timings类的具体用法?Java Timings怎么用?Java Timings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Timings类属于co.aikar.timings包,在下文中一共展示了Timings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recalculatePermissions
import co.aikar.timings.Timings; //导入依赖的package包/类
@Override
public void recalculatePermissions() {
Timings.permissibleCalculationTimer.startTiming();
this.clearPermissions();
Map<String, Permission> defaults = Server.getInstance().getPluginManager().getDefaultPermissions(this.isOp());
Server.getInstance().getPluginManager().subscribeToDefaultPerms(this.isOp(), this.parent != null ? this.parent : this);
for (Permission perm : defaults.values()) {
String name = perm.getName();
this.permissions.put(name, new PermissionAttachmentInfo(this.parent != null ? this.parent : this, name, null, true));
Server.getInstance().getPluginManager().subscribeToPermission(name, this.parent != null ? this.parent : this);
this.calculateChildPermissions(perm.getChildren(), false, null);
}
for (PermissionAttachment attachment : this.attachments) {
this.calculateChildPermissions(attachment.getPermissions(), false, attachment);
}
Timings.permissibleCalculationTimer.stopTiming();
}
示例2: doAutoSave
import co.aikar.timings.Timings; //导入依赖的package包/类
public void doAutoSave() {
if (this.getAutoSave()) {
Timings.levelSaveTimer.startTiming();
for (Player player : new ArrayList<>(this.players.values())) {
if (player.isOnline()) {
player.save(true);
} else if (!player.isConnected()) {
this.removePlayer(player);
}
}
for (Level level : this.getLevels().values()) {
level.save();
}
Timings.levelSaveTimer.stopTiming();
}
}
示例3: batchDataPacket
import co.aikar.timings.Timings; //导入依赖的package包/类
public boolean batchDataPacket(DataPacket packet) {
if (!this.connected) {
return false;
}
try (Timing timing = Timings.getSendDataPacketTiming(packet)) {
DataPacketSendEvent event = new DataPacketSendEvent(this, packet);
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
timing.stopTiming();
return false;
}
if (!this.batchedPackets.containsKey(packet.getChannel())) {
this.batchedPackets.put(packet.getChannel(), new ArrayList<>());
}
this.batchedPackets.get(packet.getChannel()).add(packet.clone());
}
return true;
}
示例4: dataPacket
import co.aikar.timings.Timings; //导入依赖的package包/类
public int dataPacket(DataPacket packet, boolean needACK) {
if (!this.connected) {
return -1;
}
try (Timing timing = Timings.getSendDataPacketTiming(packet)) {
DataPacketSendEvent ev = new DataPacketSendEvent(this, packet);
this.server.getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
timing.stopTiming();
return -1;
}
Integer identifier = this.interfaz.putPacket(this, packet, needACK, false);
if (needACK && identifier != null) {
this.needACK.put(identifier, false);
timing.stopTiming();
return identifier;
}
}
return 0;
}
示例5: directDataPacket
import co.aikar.timings.Timings; //导入依赖的package包/类
public int directDataPacket(DataPacket packet, boolean needACK) {
if (!this.connected) {
return -1;
}
try (Timing timing = Timings.getSendDataPacketTiming(packet)) {
DataPacketSendEvent ev = new DataPacketSendEvent(this, packet);
this.server.getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
timing.stopTiming();
return -1;
}
Integer identifier = this.interfaz.putPacket(this, packet, needACK, true);
if (needACK && identifier != null) {
this.needACK.put(identifier, false);
timing.stopTiming();
return identifier;
}
}
return 0;
}
示例6: BlockEntity
import co.aikar.timings.Timings; //导入依赖的package包/类
public BlockEntity(FullChunk chunk, CompoundTag nbt) {
if (chunk == null || chunk.getProvider() == null) {
throw new ChunkException("Invalid garbage Chunk given to Block Entity");
}
this.timing = Timings.getBlockEntityTiming(this);
this.server = chunk.getProvider().getLevel().getServer();
this.chunk = chunk;
this.setLevel(chunk.getProvider().getLevel());
this.namedTag = nbt;
this.name = "";
this.lastUpdate = System.currentTimeMillis();
this.id = BlockEntity.count++;
this.x = this.namedTag.getInt("x");
this.y = this.namedTag.getInt("y");
this.z = this.namedTag.getInt("z");
this.movable = this.namedTag.getBoolean("isMovable");
this.chunk.addBlockEntity(this);
this.getLevel().addBlockEntity(this);
}
示例7: dataPacket
import co.aikar.timings.Timings; //导入依赖的package包/类
public int dataPacket(DataPacket packet, boolean needACK) {
if (!this.connected) {
return -1;
}
if(this.printPackets)
this.getServer().getLogger().info(TextFormat.YELLOW + "[SEND] " + TextFormat.WHITE + packet.getName());
try (Timing timing = Timings.getSendDataPacketTiming(packet)) {
DataPacketSendEvent ev = new DataPacketSendEvent(this, packet);
this.server.getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
timing.stopTiming();
return -1;
}
Integer identifier = this.interfaz.putPacket(this, packet, needACK, false);
if (needACK && identifier != null) {
this.needACK.put(identifier.intValue(), false);
timing.stopTiming();
return identifier;
}
}
return 0;
}
示例8: directDataPacket
import co.aikar.timings.Timings; //导入依赖的package包/类
public int directDataPacket(DataPacket packet, boolean needACK) {
if (!this.connected) {
return -1;
}
if(this.printPackets)
this.getServer().getLogger().info(TextFormat.LIGHT_PURPLE + "[SEND-DIRECT] " + TextFormat.WHITE + packet.getClass().getSimpleName());
try (Timing timing = Timings.getSendDataPacketTiming(packet)) {
DataPacketSendEvent ev = new DataPacketSendEvent(this, packet);
this.server.getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
timing.stopTiming();
return -1;
}
Integer identifier = this.interfaz.putPacket(this, packet, needACK, true);
if (needACK && identifier != null) {
this.needACK.put(identifier.intValue(), false);
timing.stopTiming();
return identifier;
}
}
return 0;
}
示例9: BlockEntity
import co.aikar.timings.Timings; //导入依赖的package包/类
public BlockEntity(FullChunk chunk, CompoundTag nbt) {
if (chunk == null || chunk.getProvider() == null) {
throw new ChunkException("Invalid garbage Chunk given to Block Entity");
}
this.timing = Timings.getBlockEntityTiming(this);
this.server = chunk.getProvider().getLevel().getServer();
this.chunk = chunk;
this.setLevel(chunk.getProvider().getLevel());
this.namedTag = nbt;
this.name = "";
this.lastUpdate = System.currentTimeMillis();
this.id = BlockEntity.count++;
this.x = this.namedTag.getInt("x");
this.y = this.namedTag.getInt("y");
this.z = this.namedTag.getInt("z");
this.chunk.addBlockEntity(this);
this.getLevel().addBlockEntity(this);
}
示例10: callCommand
import co.aikar.timings.Timings; //导入依赖的package包/类
public void callCommand(String cmd) {
String trimedCmd = cmd.trim();
String label = null;
String[] args = null;
if (!cmd.trim().contains(" ")) {
label = trimedCmd.toLowerCase();
args = new String[0];
} else {
label = trimedCmd.substring(0, trimedCmd.indexOf(" ")).toLowerCase();
String argLine = trimedCmd.substring(trimedCmd.indexOf(" ") + 1);
args = argLine.contains(" ") ? argLine.split(" ") : new String[]{argLine};
}
if (label == null) {
proxy.getLogger().warning(proxy.getLang().get(Lang.COMMAND_NOT_FOUND));
return;
}
Command command = commandMap.get(label);
if (command == null) {
proxy.getLogger().warning(proxy.getLang().get(Lang.COMMAND_NOT_FOUND));
return;
}
try(Timing timing = Timings.getCommandTiming(command)) {
command.execute(proxy, args);
}
}
示例11: translateToPE
import co.aikar.timings.Timings; //导入依赖的package包/类
public static PEPacket[] translateToPE(UpstreamSession session, Packet packet) {
if (packet == null)
return null;
IPCPacketTranslator<Packet> target = (IPCPacketTranslator<Packet>) PC_TO_PE_TRANSLATOR.get(packet.getClass());
if (target == null)
return null;
try (Timing timing = Timings.getPcPacketTranslatorTiming(target)) {
try {
return target.translate(session, packet);
} catch (Exception e) {
timing.stopTiming();
e.printStackTrace();
return null;
}
}
}
示例12: translateToPC
import co.aikar.timings.Timings; //导入依赖的package包/类
public static Packet[] translateToPC(UpstreamSession session, PEPacket packet) {
if (packet == null)
return null;
IPEPacketTranslator<PEPacket> target = (IPEPacketTranslator<PEPacket>) PE_TO_PC_TRANSLATOR.get(packet.getClass());
if (target == null)
return null;
try (Timing timing = Timings.getPePacketTranslatorTiming(target)) {
try {
return target.translate(session, packet);
} catch (Exception e) {
timing.stopTiming();
e.printStackTrace();
return null;
}
}
}
示例13: sendPacket
import co.aikar.timings.Timings; //导入依赖的package包/类
public void sendPacket(PEPacket packet, boolean immediate) {
if (packet == null)
return;
// System.out.println("Sending [" + packet.getClass().getSimpleName() + "] ");
try (Timing timing = Timings.getSendDataPacketTiming(packet)) {
packet.encode();
byte[] buffer;
try {
buffer = Zlib.deflate(Binary.appendBytes(Binary.writeUnsignedVarInt(packet.getBuffer().length), packet.getBuffer()), 6);
} catch (Exception e) {
timing.stopTiming();
e.printStackTrace();
return;
}
// handler.sendEncapsulated(identifier, encapsulated, RakNet.FLAG_NEED_ACK |
// (overridedImmediate ? RakNet.PRIORITY_IMMEDIATE : RakNet.PRIORITY_NORMAL));
raknetClient.sendMessage(Reliability.RELIABLE_ORDERED, 0,
new net.marfgamer.jraknet.Packet(Binary.appendBytes((byte) 0xfe, buffer)));
}
}
示例14: shutdown
import co.aikar.timings.Timings; //导入依赖的package包/类
public void shutdown() {
logger.info(lang.get(Lang.SHUTTING_DOWN));
debug = false;
this.shuttingDown = true;
network.shutdown();
try {
Thread.sleep(2000); // Wait for all clients disconnected
} catch (Exception ex) {
System.out.println("Exception while shutting down!");
ex.printStackTrace();
}
Timings.stopServer();
System.out.println("Goodbye!");
System.exit(0);
}
示例15: run
import co.aikar.timings.Timings; //导入依赖的package包/类
@Override
public void run() {
long time;
while (!proxy.isShuttingDown()) {
time = System.currentTimeMillis();
Timings.fullServerTickTimer.startTiming();
proxy.onTick();
Timings.fullServerTickTimer.stopTiming();
time = System.currentTimeMillis() - time;
if (time >= 50)
continue;
else
try {
Thread.sleep(50 - time);
} catch (InterruptedException ex) {
return;
}
}
}