From ee5907b893b21cf6e75752c190f485e2d63662e4 Mon Sep 17 00:00:00 2001 From: BuildTools <46540330+willkroboth@users.noreply.github.com> Date: Wed, 3 Jul 2024 18:09:53 -0400 Subject: [PATCH] Propagate namespace when registering subcommands --- .../dev/jorel/commandapi/AbstractCommandAPICommand.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commandapi-core/src/main/java/dev/jorel/commandapi/AbstractCommandAPICommand.java b/commandapi-core/src/main/java/dev/jorel/commandapi/AbstractCommandAPICommand.java index 380284308c..2bf2a9b701 100644 --- a/commandapi-core/src/main/java/dev/jorel/commandapi/AbstractCommandAPICommand.java +++ b/commandapi-core/src/main/java/dev/jorel/commandapi/AbstractCommandAPICommand.java @@ -215,7 +215,7 @@ Impl setConverted(boolean isConverted) { // shouldn't be accessing/depending on any of the contents of the current class instance) @SuppressWarnings({ "unchecked", "rawtypes" }) private static , Argument extends AbstractArgument, CommandSender> - void flatten(Impl rootCommand, List prevArguments, Impl subcommand) { + void flatten(Impl rootCommand, List prevArguments, Impl subcommand, String namespace) { // Get the list of literals represented by the current subcommand. This // includes the subcommand's name and any aliases for this subcommand String[] literals = new String[subcommand.meta.aliases.length + 1]; @@ -243,11 +243,11 @@ void flatten(Impl rootCommand, List prevArguments, Impl subcommand) { rootCommand.withArguments(subcommand.arguments); rootCommand.executor = subcommand.executor; rootCommand.subcommands = new ArrayList<>(); - rootCommand.register(); + rootCommand.register(namespace); } for (Impl subsubcommand : subcommand.getSubcommands()) { - flatten(rootCommand, new ArrayList<>(prevArguments), subsubcommand); + flatten(rootCommand, new ArrayList<>(prevArguments), subsubcommand, namespace); } } @@ -310,7 +310,7 @@ public void register(String namespace) { // Convert subcommands into multiliteral arguments for (Impl subcommand : this.subcommands) { - flatten(this.copy(), new ArrayList<>(), subcommand); + flatten(this.copy(), new ArrayList<>(), subcommand, namespace); } }