mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-04 06:02:12 -07:00
Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
34 lines
2.2 KiB
Diff
34 lines
2.2 KiB
Diff
--- a/net/minecraft/commands/arguments/EntityArgument.java
|
|
+++ b/net/minecraft/commands/arguments/EntityArgument.java
|
|
@@ -105,9 +_,14 @@
|
|
}
|
|
|
|
private EntitySelector parse(StringReader reader, boolean allowSelectors) throws CommandSyntaxException {
|
|
+ // CraftBukkit start
|
|
+ return this.parse(reader, allowSelectors, false);
|
|
+ }
|
|
+ public EntitySelector parse(StringReader reader, boolean allowSelectors, boolean overridePermissions) throws CommandSyntaxException {
|
|
+ // CraftBukkit end
|
|
int i = 0;
|
|
EntitySelectorParser entitySelectorParser = new EntitySelectorParser(reader, allowSelectors);
|
|
- EntitySelector entitySelector = entitySelectorParser.parse();
|
|
+ EntitySelector entitySelector = entitySelectorParser.parse(overridePermissions); // CraftBukkit
|
|
if (entitySelector.getMaxResults() > 1 && this.single) {
|
|
if (this.playersOnly) {
|
|
reader.setCursor(0);
|
|
@@ -129,7 +_,13 @@
|
|
if (context.getSource() instanceof SharedSuggestionProvider sharedSuggestionProvider) {
|
|
StringReader stringReader = new StringReader(builder.getInput());
|
|
stringReader.setCursor(builder.getStart());
|
|
- EntitySelectorParser entitySelectorParser = new EntitySelectorParser(stringReader, EntitySelectorParser.allowSelectors(sharedSuggestionProvider));
|
|
+ // Paper start - Fix EntityArgument permissions
|
|
+ final boolean permission = sharedSuggestionProvider instanceof CommandSourceStack stack
|
|
+ ? stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector")
|
|
+ // Only CommandSourceStack implements SharedSuggestionProvider. If *somehow* anything else ends up here, try to query its permission level, otherwise yield false.
|
|
+ : (sharedSuggestionProvider instanceof final net.minecraft.commands.PermissionSource permissionSource && permissionSource.hasPermission(2));
|
|
+ EntitySelectorParser entitySelectorParser = new EntitySelectorParser(stringReader, permission);
|
|
+ // Paper end - Fix EntityArgument permissions
|
|
|
|
try {
|
|
entitySelectorParser.parse();
|