mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 15:30:19 +01:00
Fix Selector Arguments not working with permission (#11286)
This commit is contained in:
parent
6da54bd440
commit
659f0f2fd0
2 changed files with 18 additions and 5 deletions
|
@ -1,8 +1,8 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Wed, 26 Oct 2022 13:13:12 -0700
|
||||
Subject: [PATCH] Fix EntityArgument suggestion permissions to align with
|
||||
EntitySelector#checkPermissions
|
||||
Subject: [PATCH] Fix EntityArgument and EntitySelectorParser permissions to
|
||||
align with EntitySelector#checkPermissions
|
||||
|
||||
Fixes where the user has permission for selectors but not their
|
||||
suggestions, which especially matters when we force suggestions to
|
||||
|
@ -17,12 +17,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
stringreader.setCursor(suggestionsbuilder.getStart());
|
||||
- EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, EntitySelectorParser.allowSelectors(icompletionprovider));
|
||||
+ // Paper start - Fix EntityArgument suggestion permissions
|
||||
+ // 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 suggestion permissions
|
||||
+ // Paper end - Fix EntityArgument permissions
|
||||
|
||||
try {
|
||||
argumentparserselector.parse();
|
||||
diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelectorParser.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelectorParser.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelectorParser.java
|
||||
+++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelectorParser.java
|
||||
@@ -0,0 +0,0 @@ public class EntitySelectorParser {
|
||||
boolean flag;
|
||||
|
||||
if (source instanceof SharedSuggestionProvider icompletionprovider) {
|
||||
- if (icompletionprovider.hasPermission(2)) {
|
||||
+ if (source instanceof net.minecraft.commands.CommandSourceStack stack ? stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector") : icompletionprovider.hasPermission(2)) { // Paper - Fix EntityArgument permissions
|
||||
flag = true;
|
||||
return flag;
|
||||
}
|
|
@ -69,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
: icompletionprovider.hasPermission(2);
|
||||
- EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, permission);
|
||||
+ EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, permission, true); // Paper - tell clients to ask server for suggestions for EntityArguments
|
||||
// Paper end - Fix EntityArgument suggestion permissions
|
||||
// Paper end - Fix EntityArgument permissions
|
||||
|
||||
try {
|
||||
@@ -0,0 +0,0 @@ public class EntityArgument implements ArgumentType<EntitySelector> {
|
||||
|
|
Loading…
Reference in a new issue