@@ -1045,7 +1045,7 @@ public void verifyAndRegister() {
10451045 }
10461046 });
10471047
1048- this .getLeavesRaw (this .internalTree ).forEach (this ::propagateRequirements );
1048+ this .getExecutorNodes (this .internalTree ).forEach (this ::propagateRequirements );
10491049 }
10501050
10511051 /**
@@ -1071,34 +1071,19 @@ private void propagateRequirements(final @NonNull CommandNode<C> leafNode) {
10711071 if (senderType == null ) {
10721072 senderType = Object .class ;
10731073 }
1074- /* All leaves must necessarily have an owning command */
1075- leafNode .nodeMeta ().put (CommandNode .META_KEY_PERMISSION , commandPermission );
1076- leafNode .nodeMeta ().put (CommandNode .META_KEY_SENDER_TYPES , new HashSet <>(Collections .singletonList (senderType )));
1077- // Get chain and order it tail->head then skip the tail (leaf node)
1074+ // Get chain and order it tail->head
10781075 List <CommandNode <C >> chain = this .getChain (leafNode );
10791076 Collections .reverse (chain );
1080- chain = chain .subList (1 , chain .size ());
1081- // Go through all nodes from the tail upwards until a collision occurs
10821077 for (final CommandNode <C > commandArgumentNode : chain ) {
10831078 final Permission existingPermission = (Permission ) commandArgumentNode .nodeMeta ().get (CommandNode .META_KEY_PERMISSION );
10841079
1085- Permission permission ;
1080+ final Permission permission ;
10861081 if (existingPermission != null ) {
10871082 permission = Permission .anyOf (commandPermission , existingPermission );
10881083 } else {
10891084 permission = commandPermission ;
10901085 }
10911086
1092- /* Now also check if there's a command handler attached to an upper level node */
1093- if (commandArgumentNode .component () != null && commandArgumentNode .command () != null ) {
1094- final Command <C > command = commandArgumentNode .command ();
1095- if (this .commandManager ().settings ().get (ManagerSetting .ENFORCE_INTERMEDIARY_PERMISSIONS )) {
1096- permission = command .commandPermission ();
1097- } else {
1098- permission = Permission .anyOf (permission , command .commandPermission ());
1099- }
1100- }
1101-
11021087 commandArgumentNode .nodeMeta ().put (CommandNode .META_KEY_PERMISSION , permission );
11031088
11041089 final Set <Type > senderTypes = (Set <Type >) commandArgumentNode .nodeMeta ()
@@ -1190,6 +1175,19 @@ private void checkAmbiguity(final @NonNull CommandNode<C> node) throws Ambiguous
11901175 return leaves ;
11911176 }
11921177
1178+ private @ NonNull List <@ NonNull CommandNode <C >> getExecutorNodes (
1179+ final @ NonNull CommandNode <C > node
1180+ ) {
1181+ final List <CommandNode <C >> leaves = new LinkedList <>();
1182+ if (node .command () != null ) {
1183+ leaves .add (node );
1184+ }
1185+ for (final CommandNode <C > child : node .children ()) {
1186+ leaves .addAll (this .getExecutorNodes (child ));
1187+ }
1188+ return leaves ;
1189+ }
1190+
11931191 /**
11941192 * Returns all leaf nodes attached to the given {@code node} or its children.
11951193 *
0 commit comments