mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-01 12:37:10 +00:00
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 a3ec2f522be2d02b9e37810799cecc2ba14f58f3..97d4d9f85ee20aa1dd894d24deefe33478fe1cee 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;
|
|
@@ -32,6 +35,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;
|
|
@@ -39,6 +43,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
|
|
|
|
@@ -289,6 +294,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;
|
|
}
|
|
}
|