CommandAPI version
4.3 and 5.1
Minecraft version
1.16.3
This bug does not affect versions 1.15 and below.
Describe the bug
/minecraft:reload is used to reload datapacks after the server has started.
Functions can contain custom commands. When the server initially starts up, they fail to load. Then at startup CommandAPI reloads datapacks again in a special way, which causes the datapacks with custom commands to load correctly. No bugs here.
However, if you try to manually /minecraft:reload again after this, the custom commands will break again. This is because every time you trigger /minecraft:reload minecraft creates a new CommandDispatcher, with none of the custom commands in it.
Expected behavior
/minecraft:reload works with functions with custom commands
Workaround
If you happen to be using Paper and have control over your rebuilding your server's paperclip.jar, you can use this patch to work around this behavior and have /minecraft:reload work again as it did in previous versions.
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Byron Marohn <combustible@live.com>
Date: Sat, 24 Oct 2020 14:57:50 -0400
Subject: [PATCH] Monumenta - Ensure minecraft:reload uses latest
CommandDispatcher
diff --git a/src/main/java/net/minecraft/server/DataPackResources.java b/src/main/java/net/minecraft/server/DataPackResources.java
index f6714515cc6b0265b772e5850301f6165c8f3d54..04d2916021e5d3690e60d858d481041920744f85 100644
--- a/src/main/java/net/minecraft/server/DataPackResources.java
+++ b/src/main/java/net/minecraft/server/DataPackResources.java
@@ -7,6 +7,7 @@ import java.util.concurrent.Executor;
public class DataPackResources implements AutoCloseable {
private static final CompletableFuture<Unit> a = CompletableFuture.completedFuture(Unit.INSTANCE);
+ public static CommandDispatcher staticDispatcher = null;
private final IReloadableResourceManager b;
public CommandDispatcher commandDispatcher;
private final CraftingManager d;
@@ -23,7 +24,11 @@ public class DataPackResources implements AutoCloseable {
this.f = new LootPredicateManager();
this.g = new LootTableRegistry(this.f);
this.h = new AdvancementDataWorld(this.f);
- this.commandDispatcher = new CommandDispatcher(commanddispatcher_servertype);
+ if (staticDispatcher == null) {
+ this.commandDispatcher = new CommandDispatcher(commanddispatcher_servertype);
+ } else {
+ this.commandDispatcher = staticDispatcher;
+ }
this.i = new CustomFunctionManager(i, this.commandDispatcher.a());
this.b.a((IReloadListener) this.e);
this.b.a((IReloadListener) this.f);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index d8d29d14559169f5e8d8b4cf63d8b427b823eb2f..f4d429781c5cf20b8127191c20377fc169c3b859 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -456,6 +456,7 @@ public final class CraftServer implements Server {
public void syncCommands() {
// Clear existing commands
CommandDispatcher dispatcher = console.dataPackResources.commandDispatcher = new CommandDispatcher();
+ console.dataPackResources.staticDispatcher = dispatcher;
// Register all commands, vanilla ones will be using the old dispatcher references
for (Map.Entry<String, Command> entry : commandMap.getKnownCommands().entrySet()) {
You can make these edits yourself or copy this file
0626-Monumenta-Ensure-minecraft-reload-uses-latest-Comman.txt
into Spigot-Server-Patches, change it's extension from .txt to .patch and run ./paper jar
CommandAPI version
4.3 and 5.1
Minecraft version
1.16.3
This bug does not affect versions 1.15 and below.
Describe the bug
/minecraft:reloadis used to reload datapacks after the server has started.Functions can contain custom commands. When the server initially starts up, they fail to load. Then at startup CommandAPI reloads datapacks again in a special way, which causes the datapacks with custom commands to load correctly. No bugs here.
However, if you try to manually
/minecraft:reloadagain after this, the custom commands will break again. This is because every time you trigger/minecraft:reloadminecraft creates a new CommandDispatcher, with none of the custom commands in it.Expected behavior
/minecraft:reloadworks with functions with custom commandsWorkaround
If you happen to be using Paper and have control over your rebuilding your server's paperclip.jar, you can use this patch to work around this behavior and have
/minecraft:reloadwork again as it did in previous versions.You can make these edits yourself or copy this file
0626-Monumenta-Ensure-minecraft-reload-uses-latest-Comman.txt
into Spigot-Server-Patches, change it's extension from
.txtto.patchand run./paper jar