当前位置: 首页>>代码示例>>Java>>正文


Java Timings类代码示例

本文整理汇总了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();
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:21,代码来源:PermissibleBase.java

示例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();
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:18,代码来源:Server.java

示例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;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:22,代码来源:Player.java

示例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;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:24,代码来源:Player.java

示例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;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:24,代码来源:Player.java

示例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);
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:22,代码来源:BlockEntity.java

示例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;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:27,代码来源:Player.java

示例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;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:27,代码来源:Player.java

示例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);
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:21,代码来源:BlockEntity.java

示例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);
    }
}
 
开发者ID:DragonetMC,项目名称:DragonProxy,代码行数:26,代码来源:CommandRegister.java

示例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;
        }
    }
}
 
开发者ID:DragonetMC,项目名称:DragonProxy,代码行数:18,代码来源:PacketTranslatorRegister.java

示例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;
        }
    }
}
 
开发者ID:DragonetMC,项目名称:DragonProxy,代码行数:18,代码来源:PacketTranslatorRegister.java

示例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)));
    }
}
 
开发者ID:DragonetMC,项目名称:DragonProxy,代码行数:25,代码来源:UpstreamSession.java

示例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);
}
 
开发者ID:DragonetMC,项目名称:DragonProxy,代码行数:17,代码来源:DragonProxy.java

示例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;
            }
    }
}
 
开发者ID:DragonetMC,项目名称:DragonProxy,代码行数:20,代码来源:TickerThread.java


注:本文中的co.aikar.timings.Timings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。