mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-27 07:05:39 +00:00
3f889f5040
* Slime * Add proper credits. Thanks ASP! * Cleanup
68 lines
3.5 KiB
Diff
68 lines
3.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Allink <arclicious@vivaldi.net>
|
|
Date: Wed, 13 Jul 2022 12:13:22 +0100
|
|
Subject: [PATCH] Fix ClickEvents on Signs bypassing permissions
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
|
index 38cde466714e5663cd416b6afd5d2558e139ec09..ed48eaae75e709361a260421934b6b925ae9b427 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
|
@@ -8,8 +8,10 @@ import java.util.Objects;
|
|
import java.util.UUID;
|
|
import java.util.function.UnaryOperator;
|
|
import javax.annotation.Nullable;
|
|
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
|
import net.minecraft.commands.CommandSource;
|
|
import net.minecraft.commands.CommandSourceStack;
|
|
+import net.minecraft.commands.Commands; // Scissors
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.nbt.NbtOps;
|
|
@@ -19,6 +21,7 @@ import net.minecraft.network.chat.Component;
|
|
import net.minecraft.network.chat.ComponentUtils;
|
|
import net.minecraft.network.chat.Style;
|
|
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
|
+import net.minecraft.server.MinecraftServer; // Scissors
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
import net.minecraft.server.network.FilteredText;
|
|
@@ -30,6 +33,7 @@ import net.minecraft.world.level.block.SignBlock;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.phys.Vec2;
|
|
import net.minecraft.world.phys.Vec3;
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity; // Scissors
|
|
import org.slf4j.Logger;
|
|
import org.bukkit.block.sign.Side;
|
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
|
@@ -37,6 +41,7 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.block.SignChangeEvent;
|
|
// CraftBukkit end
|
|
+import org.bukkit.craftbukkit.CraftServer; // Scissors
|
|
|
|
public class SignBlockEntity extends BlockEntity implements CommandSource { // CraftBukkit - implements
|
|
|
|
@@ -291,6 +296,21 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
|
}
|
|
player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), world, pos), event.getMessage());
|
|
// Paper end
|
|
+ // Scissors start - Add optional permissions to command signs
|
|
+ final MinecraftServer vanillaServer = player.getServer();
|
|
+ final CraftServer craftServer = vanillaServer.server;
|
|
+ final CraftHumanEntity craftPlayer = player.getBukkitEntity();
|
|
+ final Commands commands = vanillaServer.getCommands();
|
|
+
|
|
+ if (ScissorsConfig.commandSignsBypassPermissions)
|
|
+ {
|
|
+ commands.performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), world, pos), event.getMessage());
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ craftServer.dispatchCommand(craftPlayer, command.substring(1));
|
|
+ }
|
|
+ // Scissors end
|
|
flag1 = true;
|
|
}
|
|
}
|