Command should also register in place of vanilla (e.g. /list)

This commit is contained in:
Marc Baloup 2024-07-07 15:50:16 +02:00
parent ac52e024f3
commit 307b5132df

View File

@ -145,6 +145,11 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
vanillaPaperDispatcher = event.registrar().getDispatcher(); vanillaPaperDispatcher = event.registrar().getDispatcher();
} }
if (vanillaPaperDispatcher.getRoot().getChild(commandNode.getName()) != null) {
Log.info("There is already a /" + commandNode.getName() + " in the vanilla dispatcher. Is it a vanilla command? Replacing it anyway.");
vanillaPaperDispatcher.getRoot().getChildren().removeIf(c -> c.getName().equals(commandNode.getName()));
}
registeredAliases = new HashSet<>(event.registrar().register(commandNode, description, List.of(aliases))); registeredAliases = new HashSet<>(event.registrar().register(commandNode, description, List.of(aliases)));
if (registrationPolicy == RegistrationPolicy.ALL) { if (registrationPolicy == RegistrationPolicy.ALL) {