|
1 | 1 | --- a/net/minecraft/commands/CommandSourceStack.java |
2 | 2 | +++ b/net/minecraft/commands/CommandSourceStack.java |
| 3 | +@@ -17,6 +_,8 @@ |
| 4 | + import java.util.function.BinaryOperator; |
| 5 | + import java.util.function.Supplier; |
| 6 | + import java.util.stream.Stream; |
| 7 | ++ |
| 8 | ++import com.mojang.brigadier.tree.CommandNode; |
| 9 | + import net.minecraft.ChatFormatting; |
| 10 | + import net.minecraft.advancements.AdvancementHolder; |
| 11 | + import net.minecraft.commands.arguments.EntityAnchorArgument; |
| 12 | +@@ -35,7 +_,9 @@ |
| 13 | + import net.minecraft.server.MinecraftServer; |
| 14 | + import net.minecraft.server.level.ServerLevel; |
| 15 | + import net.minecraft.server.level.ServerPlayer; |
| 16 | ++import net.minecraft.server.permissions.Permission; |
| 17 | + import net.minecraft.server.permissions.PermissionSet; |
| 18 | ++import net.minecraft.server.permissions.Permissions; |
| 19 | + import net.minecraft.sounds.SoundEvent; |
| 20 | + import net.minecraft.util.Mth; |
| 21 | + import net.minecraft.util.TaskChainer; |
3 | 22 | @@ -49,8 +_,9 @@ |
4 | 23 | import org.jspecify.annotations.Nullable; |
5 | 24 |
|
|
11 | 30 | public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player")); |
12 | 31 | public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity")); |
13 | 32 | public final CommandSource source; |
| 33 | +@@ -67,6 +_,7 @@ |
| 34 | + private final Vec2 rotation; |
| 35 | + private final CommandSigningContext signingContext; |
| 36 | + private final TaskChainer chatMessageChainer; |
| 37 | ++ public volatile CommandNode currentCommand; |
| 38 | + |
| 39 | + public CommandSourceStack( |
| 40 | + CommandSource source, |
| 41 | +@@ -128,6 +_,37 @@ |
| 42 | + this.signingContext = signingContext; |
| 43 | + this.chatMessageChainer = chatMessageChainer; |
| 44 | + } |
| 45 | ++ |
| 46 | ++ public class DelegatePermissionSet implements PermissionSet { |
| 47 | ++ |
| 48 | ++ private final PermissionSet handle; |
| 49 | ++ |
| 50 | ++ public DelegatePermissionSet(PermissionSet handle) { |
| 51 | ++ this.handle = handle; |
| 52 | ++ } |
| 53 | ++ |
| 54 | ++ @Override |
| 55 | ++ public boolean hasPermission(Permission permission) { |
| 56 | ++ boolean hasPermission = handle.hasPermission(permission); |
| 57 | ++ |
| 58 | ++ CommandNode currentCommand = CommandSourceStack.this.currentCommand; |
| 59 | ++ if (currentCommand != null) { |
| 60 | ++ return hasPermission(hasPermission, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand)); |
| 61 | ++ } |
| 62 | ++ |
| 63 | ++ if (permission.equals(Permissions.COMMANDS_ENTITY_SELECTORS)) { |
| 64 | ++ return hasPermission(hasPermission, "minecraft.command.selector"); |
| 65 | ++ } |
| 66 | ++ |
| 67 | ++ return hasPermission; |
| 68 | ++ } |
| 69 | ++ |
| 70 | ++ public boolean hasPermission(boolean hasPermission, String bukkitPermission) { |
| 71 | ++ // World is null when loading functions |
| 72 | ++ return ((getLevel() == null || !getLevel().getCraftServer().ignoreVanillaPermissions) && hasPermission) || getBukkitSender().hasPermission(bukkitPermission); |
| 73 | ++ } |
| 74 | ++ } |
| 75 | ++ // CraftBukkit end |
| 76 | + |
| 77 | + public CommandSourceStack withSource(CommandSource source) { |
| 78 | + return this.source == source |
0 commit comments