diff options
-rw-r--r-- | src/main/java/org/bukkit/command/defaults/TimingsCommand.java | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/main/java/org/bukkit/command/defaults/TimingsCommand.java b/src/main/java/org/bukkit/command/defaults/TimingsCommand.java index 8d65c13a..e43456f7 100644 --- a/src/main/java/org/bukkit/command/defaults/TimingsCommand.java +++ b/src/main/java/org/bukkit/command/defaults/TimingsCommand.java @@ -1,6 +1,7 @@ package org.bukkit.command.defaults; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.event.Event; @@ -12,27 +13,28 @@ import org.bukkit.plugin.TimedRegisteredListener; import java.io.File; import java.io.IOException; import java.io.PrintStream; -import java.lang.reflect.Field; -import java.lang.reflect.Method; public class TimingsCommand extends Command { public TimingsCommand(String name) { super(name); this.description = "Records timings for all plugin events"; - this.usageMessage = "/timings <function>"; + this.usageMessage = "/timings <reset|merged|separate>"; this.setPermission("bukkit.command.timings"); } @Override public boolean execute(CommandSender sender, String currentAlias, String[] args) { if (!testPermission(sender)) return true; - if (args.length != 1) return false; + if (args.length != 1) { + sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); + return false; + } if (!sender.getServer().getPluginManager().useTimings()) { sender.sendMessage("Please enable timings by setting \"settings.plugin-profiling\" to true in bukkit.yml"); return true; } - boolean seperate = "seperate".equals(args[0]); + boolean separate = "separate".equals(args[0]); if ("reset".equals(args[0])) { for (HandlerList handlerList : HandlerList.getHandlerLists()) { for (RegisteredListener[] listeners : handlerList.getRegisteredListeners()) { @@ -44,7 +46,7 @@ public class TimingsCommand extends Command { } } sender.sendMessage("Timings reset"); - } else if ("merged".equals(args[0]) || seperate) { + } else if ("merged".equals(args[0]) || separate) { int index = 0; int pluginIdx = 0; @@ -52,18 +54,18 @@ public class TimingsCommand extends Command { timingFolder.mkdirs(); File timings = new File(timingFolder, "timings.txt"); File names = null; - while (timings.exists()) timings = new File(timingFolder, "timinigs" + (++index) + ".txt"); + while (timings.exists()) timings = new File(timingFolder, "timings" + (++index) + ".txt"); try { PrintStream fileTimings = new PrintStream(timings); PrintStream fileNames = null; - if (seperate) { + if (separate) { names = new File(timingFolder, "names" + index + ".txt"); fileNames = new PrintStream(names); } for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { pluginIdx++; long totalTime = 0; - if (seperate) { + if (separate) { fileNames.println(pluginIdx + " " + plugin.getDescription().getFullName()); fileTimings.println("Plugin " + pluginIdx); } @@ -85,7 +87,7 @@ public class TimingsCommand extends Command { fileTimings.println(" Total time " + totalTime + " (" + totalTime / 1000000000 + "s)"); } sender.sendMessage("Timings written to " + timings.getPath()); - if (seperate) sender.sendMessage("Names written to " + names.getPath()); + if (separate) sender.sendMessage("Names written to " + names.getPath()); } catch (IOException e) { } } |