Properly pass requirement on namespaced redirects (#10701)

This commit is contained in:
Owen 2024-05-12 02:46:42 -04:00 committed by GitHub
parent 711f82e01e
commit 7e48f66c05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2020,7 +2020,7 @@ index e6c7f62ed379a78645933670299e4fcda8540ed1..59d7e8a3d83d3ab7aa28606401bb129c
public org.bukkit.command.CommandSender getBukkitSender() {
return this.source.getBukkitSender(this);
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index aa2fca6917fb67fe0e9ba067d11487c3a274f675..2b33c5f5a7c5c87cf975c5237a2c9ba8cc0d2bdf 100644
index aa2fca6917fb67fe0e9ba067d11487c3a274f675..24086a82e1687cb1925398218b18c2384fa8f6e3 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -156,7 +156,7 @@ public class Commands {
@ -2032,7 +2032,7 @@ index aa2fca6917fb67fe0e9ba067d11487c3a274f675..2b33c5f5a7c5c87cf975c5237a2c9ba8
AdvancementCommands.register(this.dispatcher);
AttributeCommand.register(this.dispatcher, commandRegistryAccess);
ExecuteCommand.register(this.dispatcher, commandRegistryAccess);
@@ -265,11 +265,17 @@ public class Commands {
@@ -265,11 +265,18 @@ public class Commands {
}
}
// Paper end - Vanilla command permission fixes
@ -2047,6 +2047,7 @@ index aa2fca6917fb67fe0e9ba067d11487c3a274f675..2b33c5f5a7c5c87cf975c5237a2c9ba8
+ this.dispatcher.register(
+ com.mojang.brigadier.builder.LiteralArgumentBuilder.<CommandSourceStack>literal("minecraft:" + node.getName())
+ .executes(node.getCommand())
+ .requires(node.getRequirement())
+ .redirect(node)
+ );
+ }
@ -2055,7 +2056,7 @@ index aa2fca6917fb67fe0e9ba067d11487c3a274f675..2b33c5f5a7c5c87cf975c5237a2c9ba8
this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer());
}
@@ -325,6 +331,11 @@ public class Commands {
@@ -325,6 +332,11 @@ public class Commands {
}
public void performCommand(ParseResults<CommandSourceStack> parseresults, String s, String label) { // CraftBukkit
@ -2067,7 +2068,7 @@ index aa2fca6917fb67fe0e9ba067d11487c3a274f675..2b33c5f5a7c5c87cf975c5237a2c9ba8
CommandSourceStack commandlistenerwrapper = (CommandSourceStack) parseresults.getContext().getSource();
commandlistenerwrapper.getServer().getProfiler().push(() -> {
@@ -339,6 +350,7 @@ public class Commands {
@@ -339,6 +351,7 @@ public class Commands {
});
}
} catch (Exception exception) {
@ -2075,7 +2076,7 @@ index aa2fca6917fb67fe0e9ba067d11487c3a274f675..2b33c5f5a7c5c87cf975c5237a2c9ba8
MutableComponent ichatmutablecomponent = Component.literal(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage());
if (commandlistenerwrapper.getServer().isDebugging() || Commands.LOGGER.isDebugEnabled()) { // Paper - Debugging
@@ -477,7 +489,7 @@ public class Commands {
@@ -477,7 +490,7 @@ public class Commands {
Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
RootCommandNode vanillaRoot = new RootCommandNode();
@ -2084,7 +2085,7 @@ index aa2fca6917fb67fe0e9ba067d11487c3a274f675..2b33c5f5a7c5c87cf975c5237a2c9ba8
map.put(vanilla, vanillaRoot);
this.fillUsableCommands(vanilla, vanillaRoot, player.createCommandSourceStack(), (Map) map);
@@ -515,6 +527,7 @@ public class Commands {
@@ -515,6 +528,7 @@ public class Commands {
}
private void fillUsableCommands(CommandNode<CommandSourceStack> tree, CommandNode<SharedSuggestionProvider> result, CommandSourceStack source, Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> resultNodes) {
@ -2092,7 +2093,7 @@ index aa2fca6917fb67fe0e9ba067d11487c3a274f675..2b33c5f5a7c5c87cf975c5237a2c9ba8
Iterator iterator = tree.getChildren().iterator();
boolean registeredAskServerSuggestionsForTree = false; // Paper - tell clients to ask server for suggestions for EntityArguments
@@ -529,6 +542,42 @@ public class Commands {
@@ -529,6 +543,42 @@ public class Commands {
if (commandnode2.canUse(source)) {
ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); // CraftBukkit - decompile error