summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nms-patches/CommandDispatcher.patch34
-rw-r--r--nms-patches/CustomFunctionData.patch17
-rw-r--r--nms-patches/MinecraftServer.patch4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java2
4 files changed, 35 insertions, 22 deletions
diff --git a/nms-patches/CommandDispatcher.patch b/nms-patches/CommandDispatcher.patch
index b33f9d6e..3067bda7 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.<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 = 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<CommandListenerWrapper> 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 d478a823..67c67470 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<MinecraftKey, CustomFunction> g = Maps.newHashMap();
private final ArrayDeque<CustomFunctionData.a> h = new ArrayDeque();
private boolean i;
@@ -9,25 +9,16 @@
return this.a(minecraftkey) != null;
}, this::a, "tags/functions", true, "function");
private final List<CustomFunction> k = Lists.newArrayList();
- private boolean l;
-+ private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> 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<CommandListenerWrapper> 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 5d140dd5..dbcc897c 100644
--- a/nms-patches/MinecraftServer.patch
+++ b/nms-patches/MinecraftServer.patch
@@ -31,10 +31,10 @@
+ public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
+ 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 df6d227f..c86225c4 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<CommandListenerWrapper> cmd : dispatcher.a().getRoot().getChildren()) {