Improve command permission lookups

This allows us to append to the vanilla permission check object to avoid having to look into a map.

This also fixes non vanilla commands from technically being able to be skipped through permissions.
This commit is contained in:
Owen1212055
2025-06-06 22:11:49 -04:00
parent 94fefb88e6
commit 73d218c154
4 changed files with 29 additions and 35 deletions

View File

@@ -12,7 +12,7 @@
AdvancementCommands.register(this.dispatcher);
AttributeCommand.register(this.dispatcher, context);
ExecuteCommand.register(this.dispatcher, context);
@@ -280,6 +_,40 @@
@@ -280,6 +_,42 @@
PublishCommand.register(this.dispatcher);
}
@@ -20,6 +20,8 @@
+ for (final CommandNode<CommandSourceStack> node : this.dispatcher.getRoot().getChildren()) {
+ if (node.getRequirement() == com.mojang.brigadier.builder.ArgumentBuilder.<CommandSourceStack>defaultRequirement()) {
+ node.requirement = stack -> stack.source == CommandSource.NULL || stack.getBukkitSender().hasPermission(org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(node));
+ } else if (node.getRequirement() instanceof net.minecraft.commands.PermissionSource.Check<CommandSourceStack> check) {
+ check.vanillaNode().set(node);
+ }
+ }
+ // Paper end - Vanilla command permission fixes