mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 19:34:09 +01:00
7c7eff2c01
Fixes where the user has permission for selectors but not their suggestions, which especially matters when we force suggestions to the server for this type
52 lines
2.9 KiB
Diff
52 lines
2.9 KiB
Diff
--- a/net/minecraft/commands/arguments/EntityArgument.java
|
|
+++ b/net/minecraft/commands/arguments/EntityArgument.java
|
|
@@ -102,21 +102,27 @@
|
|
}
|
|
|
|
private EntitySelector parse(StringReader reader, boolean allowAtSelectors) throws CommandSyntaxException {
|
|
+ // CraftBukkit start
|
|
+ return this.parse(reader, allowAtSelectors, false);
|
|
+ }
|
|
+
|
|
+ public EntitySelector parse(StringReader stringreader, boolean flag, boolean overridePermissions) throws CommandSyntaxException {
|
|
+ // CraftBukkit end
|
|
boolean flag1 = false;
|
|
- EntitySelectorParser argumentparserselector = new EntitySelectorParser(reader, allowAtSelectors);
|
|
- EntitySelector entityselector = argumentparserselector.parse();
|
|
+ EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, flag);
|
|
+ EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit
|
|
|
|
if (entityselector.getMaxResults() > 1 && this.single) {
|
|
if (this.playersOnly) {
|
|
- reader.setCursor(0);
|
|
- throw EntityArgument.ERROR_NOT_SINGLE_PLAYER.createWithContext(reader);
|
|
+ stringreader.setCursor(0);
|
|
+ throw EntityArgument.ERROR_NOT_SINGLE_PLAYER.createWithContext(stringreader);
|
|
} else {
|
|
- reader.setCursor(0);
|
|
- throw EntityArgument.ERROR_NOT_SINGLE_ENTITY.createWithContext(reader);
|
|
+ stringreader.setCursor(0);
|
|
+ throw EntityArgument.ERROR_NOT_SINGLE_ENTITY.createWithContext(stringreader);
|
|
}
|
|
} else if (entityselector.includesEntities() && this.playersOnly && !entityselector.isSelfSelector()) {
|
|
- reader.setCursor(0);
|
|
- throw EntityArgument.ERROR_ONLY_PLAYERS_ALLOWED.createWithContext(reader);
|
|
+ stringreader.setCursor(0);
|
|
+ throw EntityArgument.ERROR_ONLY_PLAYERS_ALLOWED.createWithContext(stringreader);
|
|
} else {
|
|
return entityselector;
|
|
}
|
|
@@ -129,7 +135,12 @@
|
|
StringReader stringreader = new StringReader(suggestionsbuilder.getInput());
|
|
|
|
stringreader.setCursor(suggestionsbuilder.getStart());
|
|
- EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, EntitySelectorParser.allowSelectors(icompletionprovider));
|
|
+ // Paper start - Fix EntityArgument permissions
|
|
+ final boolean permission = object instanceof CommandSourceStack stack
|
|
+ ? stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector")
|
|
+ : icompletionprovider.hasPermission(2);
|
|
+ EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, permission);
|
|
+ // Paper end - Fix EntityArgument permissions
|
|
|
|
try {
|
|
argumentparserselector.parse();
|