Paper commands should be built right before registration into command dispatcher (so the root command node exists in case we need it)
This commit is contained in:
parent
e6b77bcad6
commit
974347cbde
@ -68,7 +68,9 @@
|
||||
"1.20.5": 766,
|
||||
"1.20.6": 766,
|
||||
"1.21": 767,
|
||||
"1.21.1": 767
|
||||
"1.21.1": 767,
|
||||
"1.21.2": 768,
|
||||
"1.21.3": 768
|
||||
},
|
||||
"versionsOfProtocol": {
|
||||
"4": [
|
||||
@ -223,6 +225,10 @@
|
||||
"767": [
|
||||
"1.21",
|
||||
"1.21.1"
|
||||
],
|
||||
"768": [
|
||||
"1.21.2",
|
||||
"1.21.3"
|
||||
]
|
||||
}
|
||||
}
|
@ -113,7 +113,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
||||
/**
|
||||
* The command node of this command.
|
||||
*/
|
||||
protected final LiteralCommandNode<CommandSourceStack> commandNode;
|
||||
protected LiteralCommandNode<CommandSourceStack> commandNode;
|
||||
/**
|
||||
* The command requested aliases.
|
||||
*/
|
||||
@ -134,11 +134,9 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
||||
public PaperBrigadierCommand(Plugin pl, RegistrationPolicy regPolicy) {
|
||||
plugin = pl;
|
||||
registrationPolicy = regPolicy;
|
||||
commandNode = buildCommand().build();
|
||||
String[] aliasesTmp = getAliases();
|
||||
aliases = aliasesTmp == null ? new String[0] : aliasesTmp;
|
||||
description = getDescription();
|
||||
postBuildCommand(commandNode);
|
||||
register();
|
||||
//try {
|
||||
// PandalibPaperPermissions.addPermissionMapping("minecraft.command." + commandNode.getLiteral().toLowerCase(), getTargetPermission().toLowerCase());
|
||||
@ -160,6 +158,9 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
||||
plugin.getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, event -> {
|
||||
updateVanillaPaperDispatcher(event.registrar().getDispatcher());
|
||||
|
||||
commandNode = buildCommand().build();
|
||||
postBuildCommand(commandNode);
|
||||
|
||||
if (vanillaPaperDispatcher.getRoot().getChild(commandNode.getName()) != null) {
|
||||
Log.info("Command /" + commandNode.getName() + " found in the vanilla dispatcher during initial command registration. Replacing it by force.");
|
||||
vanillaPaperDispatcher.getRoot().getChildren().removeIf(c -> c.getName().equals(commandNode.getName()));
|
||||
@ -177,7 +178,6 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(plugin, () -> {
|
||||
if (vanillaPaperDispatcher == null)
|
||||
@ -211,6 +211,9 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
||||
vanillaPaperDispatcher.getRoot().addChild(newPCN);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user