diff options
Diffstat (limited to 'nms-patches')
-rw-r--r-- | nms-patches/CommandDispatcher.patch | 39 | ||||
-rw-r--r-- | nms-patches/CustomFunction.patch | 16 |
2 files changed, 29 insertions, 26 deletions
diff --git a/nms-patches/CommandDispatcher.patch b/nms-patches/CommandDispatcher.patch index 0c03bf60..b33f9d6e 100644 --- a/nms-patches/CommandDispatcher.patch +++ b/nms-patches/CommandDispatcher.patch @@ -1,12 +1,13 @@ --- a/net/minecraft/server/CommandDispatcher.java +++ b/net/minecraft/server/CommandDispatcher.java -@@ -26,12 +26,19 @@ +@@ -26,12 +26,20 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import com.google.common.base.Joiner; +import org.apache.logging.log4j.Level; ++import org.bukkit.craftbukkit.command.VanillaCommandWrapper; +import org.bukkit.event.server.ServerCommandEvent; +// CraftBukkit end + @@ -21,7 +22,7 @@ CommandAdvancement.a(this.b); CommandExecute.a(this.b); CommmandBossBar.a(this.b); -@@ -100,6 +107,11 @@ +@@ -100,6 +108,11 @@ this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> { CommandDispatcher.a.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection); }); @@ -33,7 +34,7 @@ this.b.setConsumer((commandcontext, flag, i) -> { ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i); }); -@@ -114,8 +126,63 @@ +@@ -114,8 +127,49 @@ } @@ -78,27 +79,13 @@ + } + + public int a(CommandListenerWrapper commandlistenerwrapper, String s, String label) { -+ // Some commands use the worldserver variable but we leave it full of null values, -+ // so we must temporarily populate it with the world of the commandsender -+ WorldServer[] prev = MinecraftServer.getServer().worldServer; -+ MinecraftServer server = MinecraftServer.getServer(); -+ server.worldServer = new WorldServer[server.worlds.size()]; -+ server.worldServer[0] = (WorldServer) commandlistenerwrapper.getWorld(); -+ int bpos = 0; -+ for (int pos = 1; pos < server.worldServer.length; pos++) { -+ WorldServer world = server.worlds.get(bpos++); -+ if (server.worldServer[0] == world) { -+ pos--; -+ continue; -+ } -+ server.worldServer[pos] = world; -+ } ++ VanillaCommandWrapper.WorldRescueContext rescue = new VanillaCommandWrapper.WorldRescueContext().start(commandlistenerwrapper.getWorld()); + String s1 = label; + // CraftBukkit end if (s.startsWith("/")) { s = s.substring(1); -@@ -126,7 +193,6 @@ +@@ -126,7 +180,6 @@ byte b0; try { @@ -106,7 +93,7 @@ ChatComponentText chatcomponenttext; try { -@@ -135,54 +201,59 @@ +@@ -135,54 +188,59 @@ return i; } catch (CommandException commandexception) { commandlistenerwrapper.sendFailureMessage(commandexception.a()); @@ -158,17 +145,17 @@ } catch (Exception exception) { - chatcomponenttext = new ChatComponentText; - } -- -- chatcomponenttext.<init>(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage()); -- ChatComponentText chatcomponenttext1 = chatcomponenttext; + ChatMessage chatmessage1 = new ChatMessage("command.failed", new Object[0]); -- if (CommandDispatcher.a.isDebugEnabled()) { -- StackTraceElement[] astacktraceelement = exception.getStackTrace(); +- chatcomponenttext.<init>(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage()); +- ChatComponentText chatcomponenttext1 = chatcomponenttext; + chatcomponenttext = new ChatComponentText(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage()); + if (CommandDispatcher.a.isDebugEnabled()) { + StackTraceElement[] astacktraceelement = exception.getStackTrace(); +- if (CommandDispatcher.a.isDebugEnabled()) { +- StackTraceElement[] astacktraceelement = exception.getStackTrace(); +- - for (int k = 0; k < Math.min(astacktraceelement.length, 3); ++k) { - chatcomponenttext1.a("\n\n").a(astacktraceelement[k].getMethodName()).a("\n ").a(astacktraceelement[k].getFileName()).a(":").a(String.valueOf(astacktraceelement[k].getLineNumber())); + for (int k = 0; k < Math.min(astacktraceelement.length, 3); ++k) { @@ -189,7 +176,7 @@ + } } finally { commandlistenerwrapper.getServer().methodProfiler.e(); -+ MinecraftServer.getServer().worldServer = prev; // CraftBukkit ++ rescue.end(); // CraftBukkit } return b0; diff --git a/nms-patches/CustomFunction.patch b/nms-patches/CustomFunction.patch index 034c3546..b457151c 100644 --- a/nms-patches/CustomFunction.patch +++ b/nms-patches/CustomFunction.patch @@ -9,3 +9,19 @@ if (parseresults.getReader().canRead()) { if (parseresults.getExceptions().size() == 1) { +@@ -142,7 +142,14 @@ + } + + public void a(CustomFunctionData customfunctiondata, CommandListenerWrapper commandlistenerwrapper, ArrayDeque<CustomFunctionData.a> arraydeque, int i) throws CommandSyntaxException { +- customfunctiondata.d().execute(new ParseResults(this.a.getContext().withSource(commandlistenerwrapper), this.a.getReader(), this.a.getExceptions())); ++ // CraftBukkit start ++ org.bukkit.craftbukkit.command.VanillaCommandWrapper.WorldRescueContext rescue = new org.bukkit.craftbukkit.command.VanillaCommandWrapper.WorldRescueContext().start(commandlistenerwrapper.getWorld()); ++ try { ++ customfunctiondata.d().execute(new ParseResults(this.a.getContext().withSource(commandlistenerwrapper), this.a.getReader(), this.a.getExceptions())); ++ } finally { ++ rescue.end(); ++ } ++ // CraftBukkit end + } + + public String toString() { |