geforkt von Mirrors/Paper
Flatten namespaced vanilla command alias redirects (#10821)
The brigadier command dispatcher is not capable of executing commands that redirect more than one. The exemplary alias 'minecraft:tp' may hence not redirect to 'tp' it instead has to redirect to 'teleport' as 'tp' itself is merely a redirect.
Dieser Commit ist enthalten in:
Ursprung
532b3df1ee
Commit
6496275397
@ -2045,11 +2045,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper start - Brigadier Command API
|
||||
+ // Create legacy minecraft namespace commands
|
||||
+ for (final CommandNode<CommandSourceStack> node : new java.util.ArrayList<>(this.dispatcher.getRoot().getChildren())) {
|
||||
+ // The brigadier dispatcher is not able to resolve nested redirects.
|
||||
+ // E.g. registering the alias minecraft:tp cannot redirect to tp, as tp itself redirects to teleport.
|
||||
+ // Instead, target the first none redirecting node.
|
||||
+ CommandNode<CommandSourceStack> flattenedAliasTarget = node;
|
||||
+ while (flattenedAliasTarget.getRedirect() != null) flattenedAliasTarget = flattenedAliasTarget.getRedirect();
|
||||
+
|
||||
+ this.dispatcher.register(
|
||||
+ com.mojang.brigadier.builder.LiteralArgumentBuilder.<CommandSourceStack>literal("minecraft:" + node.getName())
|
||||
+ .executes(node.getCommand())
|
||||
+ .requires(node.getRequirement())
|
||||
+ .redirect(node)
|
||||
+ .executes(flattenedAliasTarget.getCommand())
|
||||
+ .requires(flattenedAliasTarget.getRequirement())
|
||||
+ .redirect(flattenedAliasTarget)
|
||||
+ );
|
||||
+ }
|
||||
+ // Paper end - Brigadier Command API
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren