aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/commands/CommandSourceStack.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/commands/CommandSourceStack.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/commands/CommandSourceStack.java.patch411
1 files changed, 411 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/commands/CommandSourceStack.java.patch b/patch-remap/mache-spigotflower/net/minecraft/commands/CommandSourceStack.java.patch
new file mode 100644
index 0000000000..16f4f7d9a5
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/commands/CommandSourceStack.java.patch
@@ -0,0 +1,411 @@
+--- a/net/minecraft/commands/CommandSourceStack.java
++++ b/net/minecraft/commands/CommandSourceStack.java
+@@ -1,7 +1,6 @@
+ package net.minecraft.commands;
+
+ import com.google.common.collect.Lists;
+-import com.mojang.brigadier.CommandDispatcher;
+ import com.mojang.brigadier.Message;
+ import com.mojang.brigadier.context.CommandContext;
+ import com.mojang.brigadier.exceptions.CommandExceptionType;
+@@ -44,12 +43,13 @@
+ import net.minecraft.world.level.dimension.DimensionType;
+ import net.minecraft.world.phys.Vec2;
+ import net.minecraft.world.phys.Vec3;
++import com.mojang.brigadier.tree.CommandNode; // CraftBukkit
+
+ public class CommandSourceStack implements ExecutionCommandSource<CommandSourceStack>, SharedSuggestionProvider {
+
+ public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player"));
+ public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity"));
+- private final CommandSource source;
++ public final CommandSource source;
+ private final Vec3 worldPosition;
+ private final ServerLevel level;
+ private final int permissionLevel;
+@@ -64,46 +64,46 @@
+ private final Vec2 rotation;
+ private final CommandSigningContext signingContext;
+ private final TaskChainer chatMessageChainer;
++ public volatile CommandNode currentCommand; // CraftBukkit
+
+- public CommandSourceStack(CommandSource commandsource, Vec3 vec3, Vec2 vec2, ServerLevel serverlevel, int i, String s, Component component, MinecraftServer minecraftserver, @Nullable Entity entity) {
+- this(commandsource, vec3, vec2, serverlevel, i, s, component, minecraftserver, entity, false, CommandResultCallback.EMPTY, EntityAnchorArgument.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(minecraftserver));
++ public CommandSourceStack(CommandSource source, Vec3 worldPosition, Vec2 rotation, ServerLevel level, int permissionLevel, String textName, Component displayName, MinecraftServer server, @Nullable Entity entity) {
++ this(source, worldPosition, rotation, level, permissionLevel, textName, displayName, server, entity, false, CommandResultCallback.EMPTY, EntityAnchorArgument.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(server));
+ }
+
+- protected CommandSourceStack(CommandSource commandsource, Vec3 vec3, Vec2 vec2, ServerLevel serverlevel, int i, String s, Component component, MinecraftServer minecraftserver, @Nullable Entity entity, boolean flag, CommandResultCallback commandresultcallback, EntityAnchorArgument.Anchor entityanchorargument_anchor, CommandSigningContext commandsigningcontext, TaskChainer taskchainer) {
+- this.source = commandsource;
+- this.worldPosition = vec3;
+- this.level = serverlevel;
++ protected CommandSourceStack(CommandSource icommandlistener, Vec3 vec3d, Vec2 vec2f, ServerLevel worldserver, int i, String s, Component ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity, boolean flag, CommandResultCallback commandresultcallback, EntityAnchorArgument.Anchor argumentanchor_anchor, CommandSigningContext commandsigningcontext, TaskChainer taskchainer) {
++ this.source = icommandlistener;
++ this.worldPosition = vec3d;
++ this.level = worldserver;
+ this.silent = flag;
+ this.entity = entity;
+ this.permissionLevel = i;
+ this.textName = s;
+- this.displayName = component;
++ this.displayName = ichatbasecomponent;
+ this.server = minecraftserver;
+ this.resultCallback = commandresultcallback;
+- this.anchor = entityanchorargument_anchor;
+- this.rotation = vec2;
++ this.anchor = argumentanchor_anchor;
++ this.rotation = vec2f;
+ this.signingContext = commandsigningcontext;
+ this.chatMessageChainer = taskchainer;
+ }
+
+- public CommandSourceStack withSource(CommandSource commandsource) {
+- return this.source == commandsource ? this : new CommandSourceStack(commandsource, this.worldPosition, this.rotation, this.level, this.permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
++ public CommandSourceStack withSource(CommandSource source) {
++ return this.source == source ? this : new CommandSourceStack(source, this.worldPosition, this.rotation, this.level, this.permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
+ }
+
+ public CommandSourceStack withEntity(Entity entity) {
+ return this.entity == entity ? this : new CommandSourceStack(this.source, this.worldPosition, this.rotation, this.level, this.permissionLevel, entity.getName().getString(), entity.getDisplayName(), this.server, entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
+ }
+
+- public CommandSourceStack withPosition(Vec3 vec3) {
+- return this.worldPosition.equals(vec3) ? this : new CommandSourceStack(this.source, vec3, this.rotation, this.level, this.permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
++ public CommandSourceStack withPosition(Vec3 pos) {
++ return this.worldPosition.equals(pos) ? this : new CommandSourceStack(this.source, pos, this.rotation, this.level, this.permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
+ }
+
+- public CommandSourceStack withRotation(Vec2 vec2) {
+- return this.rotation.equals(vec2) ? this : new CommandSourceStack(this.source, this.worldPosition, vec2, this.level, this.permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
++ public CommandSourceStack withRotation(Vec2 rotation) {
++ return this.rotation.equals(rotation) ? this : new CommandSourceStack(this.source, this.worldPosition, rotation, this.level, this.permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
+ }
+
+ @Override
+- @Override
+ public CommandSourceStack withCallback(CommandResultCallback commandresultcallback) {
+ return Objects.equals(this.resultCallback, commandresultcallback) ? this : new CommandSourceStack(this.source, this.worldPosition, this.rotation, this.level, this.permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, commandresultcallback, this.anchor, this.signingContext, this.chatMessageChainer);
+ }
+@@ -118,38 +118,38 @@
+ return !this.silent && !this.source.alwaysAccepts() ? new CommandSourceStack(this.source, this.worldPosition, this.rotation, this.level, this.permissionLevel, this.textName, this.displayName, this.server, this.entity, true, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer) : this;
+ }
+
+- public CommandSourceStack withPermission(int i) {
+- return i == this.permissionLevel ? this : new CommandSourceStack(this.source, this.worldPosition, this.rotation, this.level, i, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
++ public CommandSourceStack withPermission(int permissionLevel) {
++ return permissionLevel == this.permissionLevel ? this : new CommandSourceStack(this.source, this.worldPosition, this.rotation, this.level, permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
+ }
+
+- public CommandSourceStack withMaximumPermission(int i) {
+- return i <= this.permissionLevel ? this : new CommandSourceStack(this.source, this.worldPosition, this.rotation, this.level, i, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
++ public CommandSourceStack withMaximumPermission(int permissionLevel) {
++ return permissionLevel <= this.permissionLevel ? this : new CommandSourceStack(this.source, this.worldPosition, this.rotation, this.level, permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
+ }
+
+- public CommandSourceStack withAnchor(EntityAnchorArgument.Anchor entityanchorargument_anchor) {
+- return entityanchorargument_anchor == this.anchor ? this : new CommandSourceStack(this.source, this.worldPosition, this.rotation, this.level, this.permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, entityanchorargument_anchor, this.signingContext, this.chatMessageChainer);
++ public CommandSourceStack withAnchor(EntityAnchorArgument.Anchor anchor) {
++ return anchor == this.anchor ? this : new CommandSourceStack(this.source, this.worldPosition, this.rotation, this.level, this.permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, anchor, this.signingContext, this.chatMessageChainer);
+ }
+
+- public CommandSourceStack withLevel(ServerLevel serverlevel) {
+- if (serverlevel == this.level) {
++ public CommandSourceStack withLevel(ServerLevel level) {
++ if (level == this.level) {
+ return this;
+ } else {
+- double d0 = DimensionType.getTeleportationScale(this.level.dimensionType(), serverlevel.dimensionType());
+- Vec3 vec3 = new Vec3(this.worldPosition.x * d0, this.worldPosition.y, this.worldPosition.z * d0);
++ double d0 = DimensionType.getTeleportationScale(this.level.dimensionType(), level.dimensionType());
++ Vec3 vec3d = new Vec3(this.worldPosition.x * d0, this.worldPosition.y, this.worldPosition.z * d0);
+
+- return new CommandSourceStack(this.source, vec3, this.rotation, serverlevel, this.permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
++ return new CommandSourceStack(this.source, vec3d, this.rotation, level, this.permissionLevel, this.textName, this.displayName, this.server, this.entity, this.silent, this.resultCallback, this.anchor, this.signingContext, this.chatMessageChainer);
+ }
+ }
+
+- public CommandSourceStack facing(Entity entity, EntityAnchorArgument.Anchor entityanchorargument_anchor) {
+- return this.facing(entityanchorargument_anchor.apply(entity));
++ public CommandSourceStack facing(Entity entity, EntityAnchorArgument.Anchor anchor) {
++ return this.facing(anchor.apply(entity));
+ }
+
+- public CommandSourceStack facing(Vec3 vec3) {
+- Vec3 vec31 = this.anchor.apply(this);
+- double d0 = vec3.x - vec31.x;
+- double d1 = vec3.y - vec31.y;
+- double d2 = vec3.z - vec31.z;
++ public CommandSourceStack facing(Vec3 lookPos) {
++ Vec3 vec3d1 = this.anchor.apply(this);
++ double d0 = lookPos.x - vec3d1.x;
++ double d1 = lookPos.y - vec3d1.y;
++ double d2 = lookPos.z - vec3d1.z;
+ double d3 = Math.sqrt(d0 * d0 + d2 * d2);
+ float f = Mth.wrapDegrees((float) (-(Mth.atan2(d1, d3) * 57.2957763671875D)));
+ float f1 = Mth.wrapDegrees((float) (Mth.atan2(d2, d0) * 57.2957763671875D) - 90.0F);
+@@ -170,11 +170,24 @@
+ }
+
+ @Override
+- @Override
+- public boolean hasPermission(int i) {
+- return this.permissionLevel >= i;
++ public boolean hasPermission(int level) {
++ // CraftBukkit start
++ CommandNode currentCommand = this.currentCommand;
++ if (currentCommand != null) {
++ return hasPermission(level, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
++ }
++ // CraftBukkit end
++
++ return this.permissionLevel >= level;
+ }
+
++ // CraftBukkit start
++ public boolean hasPermission(int i, String bukkitPermission) {
++ // World is null when loading functions
++ return ((getLevel() == null || !getLevel().getCraftServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || getBukkitSender().hasPermission(bukkitPermission);
++ }
++ // CraftBukkit end
++
+ public Vec3 getPosition() {
+ return this.worldPosition;
+ }
+@@ -200,9 +213,9 @@
+ Entity entity = this.entity;
+
+ if (entity instanceof ServerPlayer) {
+- ServerPlayer serverplayer = (ServerPlayer) entity;
++ ServerPlayer entityplayer = (ServerPlayer) entity;
+
+- return serverplayer;
++ return entityplayer;
+ } else {
+ throw CommandSourceStack.ERROR_NOT_PLAYER.create();
+ }
+@@ -211,17 +224,17 @@
+ @Nullable
+ public ServerPlayer getPlayer() {
+ Entity entity = this.entity;
+- ServerPlayer serverplayer;
++ ServerPlayer entityplayer;
+
+ if (entity instanceof ServerPlayer) {
+- ServerPlayer serverplayer1 = (ServerPlayer) entity;
++ ServerPlayer entityplayer1 = (ServerPlayer) entity;
+
+- serverplayer = serverplayer1;
++ entityplayer = entityplayer1;
+ } else {
+- serverplayer = null;
++ entityplayer = null;
+ }
+
+- return serverplayer;
++ return entityplayer;
+ }
+
+ public boolean isPlayer() {
+@@ -248,155 +261,143 @@
+ return this.chatMessageChainer;
+ }
+
+- public boolean shouldFilterMessageTo(ServerPlayer serverplayer) {
+- ServerPlayer serverplayer1 = this.getPlayer();
++ public boolean shouldFilterMessageTo(ServerPlayer receiver) {
++ ServerPlayer entityplayer1 = this.getPlayer();
+
+- return serverplayer == serverplayer1 ? false : serverplayer1 != null && serverplayer1.isTextFilteringEnabled() || serverplayer.isTextFilteringEnabled();
++ return receiver == entityplayer1 ? false : entityplayer1 != null && entityplayer1.isTextFilteringEnabled() || receiver.isTextFilteringEnabled();
+ }
+
+- public void sendChatMessage(OutgoingChatMessage outgoingchatmessage, boolean flag, ChatType.Bound chattype_bound) {
++ public void sendChatMessage(OutgoingChatMessage message, boolean shouldFilter, ChatType.Bound boundChatType) {
+ if (!this.silent) {
+- ServerPlayer serverplayer = this.getPlayer();
++ ServerPlayer entityplayer = this.getPlayer();
+
+- if (serverplayer != null) {
+- serverplayer.sendChatMessage(outgoingchatmessage, flag, chattype_bound);
++ if (entityplayer != null) {
++ entityplayer.sendChatMessage(message, shouldFilter, boundChatType);
+ } else {
+- this.source.sendSystemMessage(chattype_bound.decorate(outgoingchatmessage.content()));
++ this.source.sendSystemMessage(boundChatType.decorate(message.content()));
+ }
+
+ }
+ }
+
+- public void sendSystemMessage(Component component) {
++ public void sendSystemMessage(Component message) {
+ if (!this.silent) {
+- ServerPlayer serverplayer = this.getPlayer();
++ ServerPlayer entityplayer = this.getPlayer();
+
+- if (serverplayer != null) {
+- serverplayer.sendSystemMessage(component);
++ if (entityplayer != null) {
++ entityplayer.sendSystemMessage(message);
+ } else {
+- this.source.sendSystemMessage(component);
++ this.source.sendSystemMessage(message);
+ }
+
+ }
+ }
+
+- public void sendSuccess(Supplier<Component> supplier, boolean flag) {
++ public void sendSuccess(Supplier<Component> messageSupplier, boolean allowLogging) {
+ boolean flag1 = this.source.acceptsSuccess() && !this.silent;
+- boolean flag2 = flag && this.source.shouldInformAdmins() && !this.silent;
++ boolean flag2 = allowLogging && this.source.shouldInformAdmins() && !this.silent;
+
+ if (flag1 || flag2) {
+- Component component = (Component) supplier.get();
++ Component ichatbasecomponent = (Component) messageSupplier.get();
+
+ if (flag1) {
+- this.source.sendSystemMessage(component);
++ this.source.sendSystemMessage(ichatbasecomponent);
+ }
+
+ if (flag2) {
+- this.broadcastToAdmins(component);
++ this.broadcastToAdmins(ichatbasecomponent);
+ }
+
+ }
+ }
+
+- private void broadcastToAdmins(Component component) {
+- MutableComponent mutablecomponent = Component.translatable("chat.type.admin", this.getDisplayName(), component).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC);
++ private void broadcastToAdmins(Component message) {
++ MutableComponent ichatmutablecomponent = Component.translatable("chat.type.admin", this.getDisplayName(), message).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC);
+
+ if (this.server.getGameRules().getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK)) {
+ Iterator iterator = this.server.getPlayerList().getPlayers().iterator();
+
+ while (iterator.hasNext()) {
+- ServerPlayer serverplayer = (ServerPlayer) iterator.next();
++ ServerPlayer entityplayer = (ServerPlayer) iterator.next();
+
+- if (serverplayer != this.source && this.server.getPlayerList().isOp(serverplayer.getGameProfile())) {
+- serverplayer.sendSystemMessage(mutablecomponent);
++ if (entityplayer != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit
++ entityplayer.sendSystemMessage(ichatmutablecomponent);
+ }
+ }
+ }
+
+ if (this.source != this.server && this.server.getGameRules().getBoolean(GameRules.RULE_LOGADMINCOMMANDS)) {
+- this.server.sendSystemMessage(mutablecomponent);
++ this.server.sendSystemMessage(ichatmutablecomponent);
+ }
+
+ }
+
+- public void sendFailure(Component component) {
++ public void sendFailure(Component message) {
+ if (this.source.acceptsFailure() && !this.silent) {
+- this.source.sendSystemMessage(Component.empty().append(component).withStyle(ChatFormatting.RED));
++ this.source.sendSystemMessage(Component.empty().append(message).withStyle(ChatFormatting.RED));
+ }
+
+ }
+
+ @Override
+- @Override
+ public CommandResultCallback callback() {
+ return this.resultCallback;
+ }
+
+ @Override
+- @Override
+ public Collection<String> getOnlinePlayerNames() {
+ return Lists.newArrayList(this.server.getPlayerNames());
+ }
+
+ @Override
+- @Override
+ public Collection<String> getAllTeams() {
+ return this.server.getScoreboard().getTeamNames();
+ }
+
+ @Override
+- @Override
+ public Stream<ResourceLocation> getAvailableSounds() {
+ return BuiltInRegistries.SOUND_EVENT.stream().map(SoundEvent::getLocation);
+ }
+
+ @Override
+- @Override
+ public Stream<ResourceLocation> getRecipeNames() {
+ return this.server.getRecipeManager().getRecipeIds();
+ }
+
+ @Override
+- @Override
+- public CompletableFuture<Suggestions> customSuggestion(CommandContext<?> commandcontext) {
++ public CompletableFuture<Suggestions> customSuggestion(CommandContext<?> context) {
+ return Suggestions.empty();
+ }
+
+ @Override
+- @Override
+- public CompletableFuture<Suggestions> suggestRegistryElements(ResourceKey<? extends Registry<?>> resourcekey, SharedSuggestionProvider.ElementSuggestionType sharedsuggestionprovider_elementsuggestiontype, SuggestionsBuilder suggestionsbuilder, CommandContext<?> commandcontext) {
+- return (CompletableFuture) this.registryAccess().registry(resourcekey).map((registry) -> {
+- this.suggestRegistryElements(registry, sharedsuggestionprovider_elementsuggestiontype, suggestionsbuilder);
+- return suggestionsbuilder.buildFuture();
++ public CompletableFuture<Suggestions> suggestRegistryElements(ResourceKey<? extends Registry<?>> resourceKey, SharedSuggestionProvider.a registryKey, SuggestionsBuilder builder, CommandContext<?> context) {
++ return (CompletableFuture) this.registryAccess().registry(resourceKey).map((iregistry) -> {
++ this.suggestRegistryElements(iregistry, registryKey, builder);
++ return builder.buildFuture();
+ }).orElseGet(Suggestions::empty);
+ }
+
+ @Override
+- @Override
+ public Set<ResourceKey<Level>> levels() {
+ return this.server.levelKeys();
+ }
+
+ @Override
+- @Override
+ public RegistryAccess registryAccess() {
+ return this.server.registryAccess();
+ }
+
+ @Override
+- @Override
+ public FeatureFlagSet enabledFeatures() {
+ return this.level.enabledFeatures();
+ }
+
+ @Override
+- @Override
+- public CommandDispatcher<CommandSourceStack> dispatcher() {
++ public com.mojang.brigadier.CommandDispatcher<CommandSourceStack> dispatcher() {
+ return this.getServer().getFunctions().getDispatcher();
+ }
+
+ @Override
+- @Override
+ public void handleError(CommandExceptionType commandexceptiontype, Message message, boolean flag, @Nullable TraceCallbacks tracecallbacks) {
+ if (tracecallbacks != null) {
+ tracecallbacks.onError(message.getString());
+@@ -409,8 +410,13 @@
+ }
+
+ @Override
+- @Override
+ public boolean isSilent() {
+ return this.silent;
+ }
++
++ // CraftBukkit start
++ public org.bukkit.command.CommandSender getBukkitSender() {
++ return source.getBukkitSender(this);
++ }
++ // CraftBukkit end
+ }