@@ -566,31 +566,27 @@ private void registerCommand(RootCommandNode<Source> root, String name, String p
566
566
567
567
@ Override
568
568
public LiteralCommandNode <Source > registerCommandNode (LiteralArgumentBuilder <Source > node , String namespace ) {
569
+ RootCommandNode <Source > rootNode = getBrigadierDispatcher ().getRoot ();
569
570
LiteralCommandNode <Source > builtNode = node .build ();
570
- LiteralCommandNode <Source > customNamespaceNode = null ;
571
-
572
571
String name = node .getLiteral ();
573
- boolean namespaceEqualsMinecraft = namespace .equals ("minecraft" );
574
- if (namespaceEqualsMinecraft && namespacesToFix .contains ("minecraft:" + name )) {
572
+ if (namespace .equals ("minecraft" ) && namespacesToFix .contains ("minecraft:" + name )) {
575
573
// This command wants to exist as `minecraft:name`
576
574
// However, another command has requested that `minecraft:name` be removed
577
575
// We'll keep track of everything that should be `minecraft:name` in
578
576
// `minecraftCommandNamespaces` and fix this later in `#fixNamespaces`
579
577
minecraftCommandNamespaces .addChild (CommandAPIHandler .getInstance ().namespaceNode (builtNode , "minecraft" ));
580
- } else if (!namespaceEqualsMinecraft ) {
581
- // We should set up a custom namespace
582
- customNamespaceNode = CommandAPIHandler .getInstance ().namespaceNode (builtNode , namespace );
578
+ } else {
583
579
// Make sure to remove the `minecraft:name` and
584
580
// `minecraft:namespace:name` commands Bukkit will create
585
581
fillNamespacesToFix (name , namespace + ":" + name );
582
+ // Create the namespaced node
583
+ rootNode .addChild (CommandAPIHandler .getInstance ().namespaceNode (builtNode , namespace ));
586
584
}
587
-
588
- // Add the nodes to the main dispatcher
589
- RootCommandNode < Source > rootNode = getBrigadierDispatcher (). getRoot ();
585
+ // Add the main node to dispatcher
586
+ // We needed to wait until after `fillNamespacesToFix` was called to do this, in case a previous
587
+ // `minecraft:name` version of the command needed to be saved separately before this node was added
590
588
rootNode .addChild (builtNode );
591
- if (customNamespaceNode != null ) {
592
- rootNode .addChild (customNamespaceNode );
593
- }
589
+
594
590
return builtNode ;
595
591
}
596
592
0 commit comments