From a2356397db22342810eee6a02553ad80ced31377 Mon Sep 17 00:00:00 2001 From: Allink <44676012+allinkdev@users.noreply.github.com> Date: Mon, 1 Aug 2022 23:46:08 +0100 Subject: [PATCH] Add configuration option to disable chat signatures, update Paper and some patch fixes (#59) * Update Paper * Update Patches for 1.19.1 * Fix method style * Fix incorrect access modifier for configuration defaults * Add configuration option to disable chat signatures --- gradle.properties | 2 +- ...ates-before-attempting-to-get-block-.patch | 4 +- ...033-Prevent-invalid-container-events.patch | 6 +- ...running-commands-in-books-by-default.patch | 14 +++++ ...vents-on-Signs-bypassing-permissions.patch | 6 +- ...on-option-to-disable-chat-signatures.patch | 61 +++++++++++++++++++ 6 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 patches/server/0039-Add-configuration-option-to-disable-chat-signatures.patch diff --git a/gradle.properties b/gradle.properties index d5317c3..93f8faa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ group=me.totalfreedom.scissors version=1.19.1-R0.1-SNAPSHOT mcVersion=1.19.1 -paperRef=532dc51d5f4deb036474e8d5921275f937e4c4ac +paperRef=dd3e4e7bd66c3e94fafd8cf1480d7087f023c89d org.gradle.caching=true org.gradle.parallel=true diff --git a/patches/server/0023-Validate-coordinates-before-attempting-to-get-block-.patch b/patches/server/0023-Validate-coordinates-before-attempting-to-get-block-.patch index 7deb4dc..c549f9d 100644 --- a/patches/server/0023-Validate-coordinates-before-attempting-to-get-block-.patch +++ b/patches/server/0023-Validate-coordinates-before-attempting-to-get-block-.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Validate coordinates before attempting to get block entities diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index ff7df8026f85b7ad51458a0b720a8baf71cd9bd1..5e105ed98ce3a1ec4b3acc98f57a526404fa1052 100644 +index 5cf5dcf092eb89d7995389a24e7f356f23a727a1..d4132f9a85525dd0f9a6969afcba5c8fab2337d1 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -1931,6 +1931,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @@ -28,7 +28,7 @@ index ff7df8026f85b7ad51458a0b720a8baf71cd9bd1..5e105ed98ce3a1ec4b3acc98f57a5264 @Override public void handleUseItemOn(ServerboundUseItemOnPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); -@@ -3418,17 +3430,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3424,17 +3436,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot BlockPos blockposition = BlockEntity.getPosFromTag(nbttagcompound); diff --git a/patches/server/0033-Prevent-invalid-container-events.patch b/patches/server/0033-Prevent-invalid-container-events.patch index 1884088..4315250 100644 --- a/patches/server/0033-Prevent-invalid-container-events.patch +++ b/patches/server/0033-Prevent-invalid-container-events.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Prevent invalid container events diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index fc5f997f70ee35d666db6941c16e0b34726bb2b2..6928add0c56541addb6e1fbffaa8eeb683bd947e 100644 +index be5aca3aecc1d00f3c308fc7adfa11f09e7554ed..4a41d4778b96dc5c82fdedc9b77b67b155c84605 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -29,6 +29,8 @@ import java.util.function.UnaryOperator; @@ -17,7 +17,7 @@ index fc5f997f70ee35d666db6941c16e0b34726bb2b2..6928add0c56541addb6e1fbffaa8eeb6 import net.minecraft.ChatFormatting; import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; -@@ -3065,6 +3067,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3071,6 +3073,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic public void handleContainerClick(ServerboundContainerClickPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); if (this.player.isImmobile()) return; // CraftBukkit @@ -25,7 +25,7 @@ index fc5f997f70ee35d666db6941c16e0b34726bb2b2..6928add0c56541addb6e1fbffaa8eeb6 this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if -@@ -3086,6 +3089,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3092,6 +3095,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic return; } diff --git a/patches/server/0036-Disable-running-commands-in-books-by-default.patch b/patches/server/0036-Disable-running-commands-in-books-by-default.patch index fdc8a86..6c4f707 100644 --- a/patches/server/0036-Disable-running-commands-in-books-by-default.patch +++ b/patches/server/0036-Disable-running-commands-in-books-by-default.patch @@ -4,6 +4,20 @@ Date: Sun, 10 Jul 2022 10:29:03 +0100 Subject: [PATCH] Disable running commands in books by default +diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java +index e08f502fc7165f9f466217910210edb5059d39a8..1aa418ef5e400aabdf17dbe81da6cee6a1f63d96 100644 +--- a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java ++++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java +@@ -151,7 +151,8 @@ public class ScissorsConfig + + public static boolean runCommandsInBooks = false; + +- private static void runCommandsInBooks() { ++ private static void runCommandsInBooks() ++ { + runCommandsInBooks = getBoolean("runCommandsInBooks", false); + } + diff --git a/src/main/java/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java index 31911c09fe15753ae32fa39417bdc9e9de552a88..8ef33e2e2374c456cb9d4aab8ed6f1742951f402 100644 --- a/src/main/java/net/minecraft/world/item/WrittenBookItem.java diff --git a/patches/server/0038-Fix-ClickEvents-on-Signs-bypassing-permissions.patch b/patches/server/0038-Fix-ClickEvents-on-Signs-bypassing-permissions.patch index 56a423c..3a3683d 100644 --- a/patches/server/0038-Fix-ClickEvents-on-Signs-bypassing-permissions.patch +++ b/patches/server/0038-Fix-ClickEvents-on-Signs-bypassing-permissions.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix ClickEvents on Signs bypassing permissions diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java -index e08f502fc7165f9f466217910210edb5059d39a8..42c833f58656ba80135419e18366f41a08f7d32d 100644 +index 1aa418ef5e400aabdf17dbe81da6cee6a1f63d96..9cd5ffca69df27f794f5a72e687fc6b3ae0f1656 100644 --- a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java +++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java @@ -87,8 +87,8 @@ public class ScissorsConfig @@ -19,13 +19,13 @@ index e08f502fc7165f9f466217910210edb5059d39a8..42c833f58656ba80135419e18366f41a readConfig(ScissorsConfig.class, null); } -@@ -155,6 +155,13 @@ public class ScissorsConfig +@@ -156,6 +156,13 @@ public class ScissorsConfig runCommandsInBooks = getBoolean("runCommandsInBooks", false); } + // people still may want them to bypass permissions for warps + public static boolean commandSignsBypassPermissions = false; -+ public static void commandSignsBypassPermissions() ++ private static void commandSignsBypassPermissions() + { + commandSignsBypassPermissions = getBoolean("commandSignsBypassPermissions", false); + } diff --git a/patches/server/0039-Add-configuration-option-to-disable-chat-signatures.patch b/patches/server/0039-Add-configuration-option-to-disable-chat-signatures.patch new file mode 100644 index 0000000..7468eff --- /dev/null +++ b/patches/server/0039-Add-configuration-option-to-disable-chat-signatures.patch @@ -0,0 +1,61 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Allink +Date: Mon, 1 Aug 2022 21:07:28 +0100 +Subject: [PATCH] Add configuration option to disable chat signatures + + +diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java +index 9cd5ffca69df27f794f5a72e687fc6b3ae0f1656..9cf8f5d85a873c1c6c85b45246d01d4b87267623 100644 +--- a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java ++++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java +@@ -87,8 +87,8 @@ public class ScissorsConfig + config.options().header(HEADER); + config.options().copyDefaults(true); + +- version = getInt("config-version", 2); +- set("config-version", 2); ++ version = getInt("config-version", 3); ++ set("config-version", 3); + readConfig(ScissorsConfig.class, null); + } + +@@ -163,6 +163,12 @@ public class ScissorsConfig + commandSignsBypassPermissions = getBoolean("commandSignsBypassPermissions", false); + } + ++ public static boolean chatSignaturesEnabled = true; ++ private static void chatSignaturesEnabled() ++ { ++ chatSignaturesEnabled = getBoolean("chatSignaturesEnabled", true); ++ } ++ + private static void set(String path, Object val) + { + config.set(path, val); +diff --git a/src/main/java/net/minecraft/network/chat/OutgoingPlayerChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingPlayerChatMessage.java +index fc43cc6f5bbb3485b9ddcc441a13399e57289586..e1ddf22f1829234b32a549cbe0ca10d7114aafde 100644 +--- a/src/main/java/net/minecraft/network/chat/OutgoingPlayerChatMessage.java ++++ b/src/main/java/net/minecraft/network/chat/OutgoingPlayerChatMessage.java +@@ -2,6 +2,7 @@ package net.minecraft.network.chat; + + import com.google.common.collect.Sets; + import java.util.Set; ++import me.totalfreedom.scissors.ScissorsConfig; + import net.minecraft.core.RegistryAccess; + import net.minecraft.network.PacketSendListener; + import net.minecraft.network.protocol.game.ClientboundPlayerChatHeaderPacket; +@@ -86,6 +87,14 @@ public interface OutgoingPlayerChatMessage { + // Paper end + PlayerChatMessage playerChatMessage = this.message.filter(bl); + playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper ++ ++ // Scissors start - Add configuration option to disable chat signatures ++ if (!ScissorsConfig.chatSignaturesEnabled) ++ { ++ playerChatMessage = PlayerChatMessage.unsigned(MessageSigner.system(), new ChatMessageContent(playerChatMessage.serverContent().getString(), playerChatMessage.serverContent())); ++ } ++ // Scissors end ++ + if (!playerChatMessage.isFullyFiltered()) { + this.playersWithFullMessage.add(serverPlayer); + RegistryAccess registryAccess = serverPlayer.level.registryAccess();