Set paper override when available in selector suggestions to match parsing behavior

This commit is contained in:
Jason Penilla 2022-11-28 12:27:35 -07:00 committed by Jason
parent 5ffb467414
commit adea7d5ba9

View file

@ -303,7 +303,25 @@ final class SelectorUtils {
final CommandContext<C> commandContext, final CommandContext<C> commandContext,
final String input final String 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); return this.wrappedBrigadierParser.suggestions(commandContext, input);
} finally {
if (bypassField != null) {
bypassField.setBoolean(commandSourceStack, prev);
}
}
} catch (final ReflectiveOperationException ex) {
throw new RuntimeException(ex);
}
} }
} }