mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-16 18:46:12 +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 f356196aaeb498a6d2c9ad2112329cef5a3103d6..a8d8445be1cfb67de1adcaf64847d0bfaf8c503d 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;
|
|
}
|
|
}
|