mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-31 12:23:51 -07:00
net.minecraft.commands.arguments.selector
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
+++ b/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
@@ -105,7 +_,7 @@
|
||||
}
|
||||
|
||||
private void checkPermissions(CommandSourceStack source) throws CommandSyntaxException {
|
||||
- if (this.usesSelector && !source.hasPermission(2)) {
|
||||
+ if (!source.bypassSelectorPermissions && (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector"))) { // CraftBukkit // Paper - add bypass for selector perms
|
||||
throw EntityArgument.ERROR_SELECTORS_NOT_ALLOWED.create();
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
--- a/net/minecraft/commands/arguments/selector/EntitySelectorParser.java
|
||||
+++ b/net/minecraft/commands/arguments/selector/EntitySelectorParser.java
|
||||
@@ -122,7 +_,7 @@
|
||||
}
|
||||
|
||||
public static <S> boolean allowSelectors(S suggestionProvider) {
|
||||
- return suggestionProvider instanceof SharedSuggestionProvider sharedSuggestionProvider && sharedSuggestionProvider.hasPermission(2);
|
||||
+ return suggestionProvider instanceof net.minecraft.commands.CommandSourceStack stack ? stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector") : suggestionProvider instanceof net.minecraft.commands.SharedSuggestionProvider sharedSuggestionProvider && sharedSuggestionProvider.hasPermission(2); // Paper - Fix EntityArgument permissions
|
||||
}
|
||||
|
||||
public EntitySelector getSelector() {
|
||||
@@ -198,8 +_,10 @@
|
||||
};
|
||||
}
|
||||
|
||||
- protected void parseSelector() throws CommandSyntaxException {
|
||||
- this.usesSelectors = true;
|
||||
+ // CraftBukkit start
|
||||
+ protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException {
|
||||
+ this.usesSelectors = !overridePermissions;
|
||||
+ // CraftBukkit end
|
||||
this.suggestions = this::suggestSelector;
|
||||
if (!this.reader.canRead()) {
|
||||
throw ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader);
|
||||
@@ -467,6 +_,12 @@
|
||||
}
|
||||
|
||||
public EntitySelector parse() throws CommandSyntaxException {
|
||||
+ // CraftBukkit start
|
||||
+ return this.parse(false);
|
||||
+ }
|
||||
+
|
||||
+ public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException {
|
||||
+ // CraftBukkit end
|
||||
this.startPosition = this.reader.getCursor();
|
||||
this.suggestions = this::suggestNameOrSelector;
|
||||
if (this.reader.canRead() && this.reader.peek() == '@') {
|
||||
@@ -475,7 +_,7 @@
|
||||
}
|
||||
|
||||
this.reader.skip();
|
||||
- this.parseSelector();
|
||||
+ this.parseSelector(overridePermissions); // CraftBukkit
|
||||
} else {
|
||||
this.parseNameOrUUID();
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/commands/arguments/selector/SelectorPattern.java
|
||||
+++ b/net/minecraft/commands/arguments/selector/SelectorPattern.java
|
||||
@@ -13,7 +_,7 @@
|
||||
EntitySelectorParser entitySelectorParser = new EntitySelectorParser(new StringReader(pattern), true);
|
||||
return DataResult.success(new SelectorPattern(pattern, entitySelectorParser.parse()));
|
||||
} catch (CommandSyntaxException var2) {
|
||||
- return DataResult.error(() -> "Invalid selector component: " + pattern + ": " + var2.getMessage());
|
||||
+ return DataResult.error(() -> "Invalid selector component"); // Paper - limit selector error message
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user