Set paper override when available in selector suggestions to match parsing behavior
This commit is contained in:
parent
5ffb467414
commit
adea7d5ba9
1 changed files with 19 additions and 1 deletions
|
|
@ -303,7 +303,25 @@ final class SelectorUtils {
|
||||||
final CommandContext<C> commandContext,
|
final CommandContext<C> commandContext,
|
||||||
final String input
|
final String input
|
||||||
) {
|
) {
|
||||||
return this.wrappedBrigadierParser.suggestions(commandContext, input);
|
final Object commandSourceStack = commandContext.get(WrappedBrigadierParser.COMMAND_CONTEXT_BRIGADIER_NATIVE_SENDER);
|
||||||
|
final @Nullable Field bypassField =
|
||||||
|
CraftBukkitReflection.findField(commandSourceStack.getClass(), "bypassSelectorPermissions");
|
||||||
|
try {
|
||||||
|
boolean prev = false;
|
||||||
|
try {
|
||||||
|
if (bypassField != null) {
|
||||||
|
prev = bypassField.getBoolean(commandSourceStack);
|
||||||
|
bypassField.setBoolean(commandSourceStack, true);
|
||||||
|
}
|
||||||
|
return this.wrappedBrigadierParser.suggestions(commandContext, input);
|
||||||
|
} finally {
|
||||||
|
if (bypassField != null) {
|
||||||
|
bypassField.setBoolean(commandSourceStack, prev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (final ReflectiveOperationException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue