Paper/nms-patches/CommandDebug.patch
Pokechu22 4d3bf20155 Re-enable the vanilla debug MethodProfiler and /debug command
This is highly useful for profiling vanilla code, and in some cases plugin code.  It is somewhat expensive, though, which is why it was initially disabled.

I chose to use a system property instead of a configuration setting because 1) the MethodProfiler is exclusive to CraftBukkit and not part of the general API (the timings system is the general API equivalent), and 2) using a static final boolean property _may_ allow the JITter to optimize out the methods when disabled (though I'm not sure of it).

There are several changes to fix cases where the profiler code was broken slightly by other craftbukkit changes.  All of cases have been fixed, except for the block entity ticking one, due to the cost of the getSimpleName call.  For that, a ticking entry is used instead, so that time spent actually ticking the block entities can be compared with time processing the list.

This (effectively) reverts 7dde6cc566.
2017-01-18 17:42:35 -08:00

33 lines
1.6 KiB
Diff

--- a/net/minecraft/server/CommandDebug.java
+++ b/net/minecraft/server/CommandDebug.java
@@ -32,6 +32,14 @@
}
public void execute(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring) throws CommandException {
+ // CraftBukkit start - only allow use when enabled (so that no blank profile results occur)
+ if (!minecraftserver.methodProfiler.ENABLED) {
+ icommandlistener.sendMessage(new ChatComponentText("Vanilla debug profiling is disabled."));
+ icommandlistener.sendMessage(new ChatComponentText("To enable, restart the server with `-DenableDebugMethodProfiler=true' before `-jar'."));
+ icommandlistener.sendMessage(new ChatComponentText("Use `/timings' for plugin timings."));
+ return;
+ }
+ // CraftBukkit end
if (astring.length < 1) {
throw new ExceptionUsage("commands.debug.usage", new Object[0]);
} else {
@@ -140,6 +148,13 @@
}
public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) {
- return astring.length == 1 ? a(astring, new String[] { "start", "stop"}) : Collections.emptyList();
+ return astring.length == 1 ? a(astring, new String[] { "start", "stop"}) : Collections.<String>emptyList(); // CraftBukkit - decompile error
+ }
+
+ // CraftBukkit start - fix decompile error
+ @Override
+ public int compareTo(ICommand o) {
+ return a((ICommand) o);
}
+ // CraftBukkit end
}