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


Java Timings.isTimingsEnabled方法代码示例

本文整理汇总了Java中co.aikar.timings.Timings.isTimingsEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java Timings.isTimingsEnabled方法的具体用法?Java Timings.isTimingsEnabled怎么用?Java Timings.isTimingsEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在co.aikar.timings.Timings的用法示例。


在下文中一共展示了Timings.isTimingsEnabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCommand

import co.aikar.timings.Timings; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!isAllowed(sender, command)) {
        sender.sendMessage(org.bukkit.ChatColor.DARK_RED + "Not whitelisted");
        return true;
    }

    try {
        Class.forName(EXPORT_CLASS);
    } catch (ClassNotFoundException e) {
        sender.sendMessage(ChatColor.DARK_RED + "You aren't using PaperSpigot.");
        sender.sendMessage(ChatColor.DARK_RED + "This command is for the new timings (v2) system only");
        sender.sendMessage(ChatColor.DARK_RED + "Please use '/timing' for the old system");
        return true;
    }

    if (!Timings.isTimingsEnabled()) {
        sender.sendMessage(ChatColor.DARK_RED + "The server deactivated timing reports");
        sender.sendMessage(ChatColor.DARK_RED + "Go to paper.yml and activate timings");
        return true;
    }

    EvictingQueue<TimingHistory> history = Reflection.getField(TimingsManager.class, "HISTORY", EvictingQueue.class)
            .get(null);

    TimingHistory lastHistory = history.peek();
    if (lastHistory == null) {
        sender.sendMessage(ChatColor.DARK_RED + "Not enough data collected yet");
        return true;
    }

    List<BaseComponent[]> lines = Lists.newArrayList();
    printTimings(lines, lastHistory);

    Pagination pagination = new Pagination("Paper Timings", lines);
    pagination.send(sender);

    this.plugin.getPaginations().put(sender, pagination);
    return true;
}
 
开发者ID:games647,项目名称:LagMonitor,代码行数:41,代码来源:PaperTimingsCommand.java

示例2: execute

import co.aikar.timings.Timings; //导入方法依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }

    if (args.length != 1) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", usageMessage));
        return true;
    }

    String mode = args[0].toLowerCase();

    if (mode.equals("on")) {
        Timings.setTimingsEnabled(true);
        Timings.reset();
        sender.sendMessage(new TranslationContainer("nukkit.command.timings.enable"));
        return true;
    } else if (mode.equals("off")) {
        Timings.setTimingsEnabled(false);
        sender.sendMessage(new TranslationContainer("nukkit.command.timings.disable"));
        return true;
    }

    if (!Timings.isTimingsEnabled()) {
        sender.sendMessage(new TranslationContainer("nukkit.command.timings.timingsDisabled"));
        return true;
    }

    switch (mode) {
        case "verbon":
            sender.sendMessage(new TranslationContainer("nukkit.command.timings.verboseEnable"));
            Timings.setVerboseEnabled(true);
            break;
        case "verboff":
            sender.sendMessage(new TranslationContainer("nukkit.command.timings.verboseDisable"));
            Timings.setVerboseEnabled(true);
            break;
        case "reset":
            Timings.reset();
            sender.sendMessage(new TranslationContainer("nukkit.command.timings.reset"));
            break;
        case "report":
        case "paste":
            TimingsExport.reportTimings(sender);
            break;
    }
    return true;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:50,代码来源:TimingsCommand.java


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