diff --git a/nms-patches/CommandDispatcher.patch b/nms-patches/CommandDispatcher.patch index b33f9d6ec0..3067bda754 100644 --- a/nms-patches/CommandDispatcher.patch +++ b/nms-patches/CommandDispatcher.patch @@ -93,7 +93,7 @@ ChatComponentText chatcomponenttext; try { -@@ -135,54 +188,59 @@ +@@ -135,65 +188,80 @@ return i; } catch (CommandException commandexception) { commandlistenerwrapper.sendFailureMessage(commandexception.a()); @@ -145,17 +145,17 @@ } catch (Exception exception) { - chatcomponenttext = new ChatComponentText; - } -+ ChatMessage chatmessage1 = new ChatMessage("command.failed", new Object[0]); - +- - chatcomponenttext.(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 = 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) { @@ -180,3 +180,25 @@ } return b0; + } + + public void a(EntityPlayer entityplayer) { +- HashMap hashmap = Maps.newHashMap(); ++ // CraftBukkit start ++ // Register Vanilla commands into builtRoot as before ++ Map hashmap = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues ++ RootCommandNode vanillaRoot = new RootCommandNode(); ++ ++ RootCommandNode vanilla = entityplayer.server.vanillaCommandDispatcher.a().getRoot(); ++ hashmap.put(vanilla, vanillaRoot); ++ this.a(vanilla, vanillaRoot, entityplayer.getCommandListener(), (Map) hashmap); ++ ++ // Now build the global commands in a second pass + RootCommandNode rootcommandnode = new RootCommandNode(); + + hashmap.put(this.b.getRoot(), rootcommandnode); + this.a(this.b.getRoot(), rootcommandnode, entityplayer.getCommandListener(), (Map) hashmap); ++ // CraftBukkit end + entityplayer.playerConnection.sendPacket(new PacketPlayOutCommands(rootcommandnode)); + } + diff --git a/nms-patches/CustomFunctionData.patch b/nms-patches/CustomFunctionData.patch index d478a82391..67c67470e0 100644 --- a/nms-patches/CustomFunctionData.patch +++ b/nms-patches/CustomFunctionData.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CustomFunctionData.java +++ b/net/minecraft/server/CustomFunctionData.java -@@ -32,14 +32,16 @@ +@@ -32,7 +32,7 @@ private final Map g = Maps.newHashMap(); private final ArrayDeque h = new ArrayDeque(); private boolean i; @@ -9,25 +9,16 @@ return this.a(minecraftkey) != null; }, this::a, "tags/functions", true, "function"); private final List k = Lists.newArrayList(); - private boolean l; -+ private final com.mojang.brigadier.CommandDispatcher dispatcher; // CraftBukkit - - public CustomFunctionData(MinecraftServer minecraftserver) { - this.f = minecraftserver; -+ this.dispatcher = this.f.getCommandDispatcher().a(); // CraftBukkit - } - - @Nullable -@@ -60,7 +62,7 @@ +@@ -60,7 +60,7 @@ } public com.mojang.brigadier.CommandDispatcher d() { - return this.f.getCommandDispatcher().a(); -+ return dispatcher; // CraftBukkit ++ return this.f.vanillaCommandDispatcher.a(); // CraftBukkit } public void X_() { -@@ -164,7 +166,7 @@ +@@ -164,7 +164,7 @@ arraylist.add(CompletableFuture.supplyAsync(() -> { return a(iresourcemanager, minecraftkey); }, Resource.a).thenApplyAsync((list) -> { diff --git a/nms-patches/MinecraftServer.patch b/nms-patches/MinecraftServer.patch index 5d140dd509..dbcc897cb6 100644 --- a/nms-patches/MinecraftServer.patch +++ b/nms-patches/MinecraftServer.patch @@ -31,10 +31,10 @@ + public java.util.Queue processQueue = new java.util.concurrent.ConcurrentLinkedQueue(); + public int autosavePeriod; + public File bukkitDataPackFolder; ++ public CommandDispatcher vanillaCommandDispatcher; + // CraftBukkit end + + public MinecraftServer(OptionSet options, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { -+ this.commandDispatcher = commanddispatcher; // CraftBukkit this.ac = new ResourceManager(EnumResourcePackType.SERVER_DATA); this.resourcePackRepository = new ResourcePackRepository(ResourcePackLoader::new); this.ag = new CraftingManager(); @@ -43,7 +43,7 @@ this.am = new CustomFunctionData(this); this.d = proxy; - this.commandDispatcher = commanddispatcher; -+ // this.commandDispatcher = commanddispatcher; // CraftBukkit - moved up ++ this.commandDispatcher = this.vanillaCommandDispatcher = commanddispatcher; // CraftBukkit this.U = yggdrasilauthenticationservice; this.V = minecraftsessionservice; this.W = gameprofilerepository; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index df6d227fef..c86225c4be 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -355,7 +355,7 @@ public final class CraftServer implements Server { } private void setVanillaCommands() { - CommandDispatcher dispatcher = console.getCommandDispatcher(); + CommandDispatcher dispatcher = console.vanillaCommandDispatcher; // Build a list of all Vanilla commands and create wrappers for (CommandNode cmd : dispatcher.a().getRoot().getChildren()) {