mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-30 08:06:01 +00:00
1dddffad0d
Ported to 1.19.3
103 lines
5.2 KiB
Diff
103 lines
5.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Allink <arclicious@vivaldi.net>
|
|
Date: Tue, 31 Jan 2023 23:16:52 +0000
|
|
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 37b8ce4fe8913fd1097c552609c9eddb2751555e..5f46c6e93048a237e25ad84b8839a2945cc88e81 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/OutgoingChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
|
index 74cf1c043beef03cfd5adf481414a5ee78bef2a6..182f68359a7a8c0b331acd103ed3952ea3c33b93 100644
|
|
--- a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
|
+++ b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
|
@@ -1,5 +1,6 @@
|
|
package net.minecraft.network.chat;
|
|
|
|
+import me.totalfreedom.scissors.ScissorsConfig;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
|
|
public interface OutgoingChatMessage {
|
|
@@ -42,12 +43,16 @@ public interface OutgoingChatMessage {
|
|
}
|
|
public void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params, @javax.annotation.Nullable Component unsigned) {
|
|
// Paper end
|
|
+ // Scissors start - Add configuration option to disable chat signatures
|
|
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
|
|
playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
|
|
- if (!playerChatMessage.isFullyFiltered()) {
|
|
+ if (!playerChatMessage.isFullyFiltered() && /* Scissors */ ScissorsConfig.chatSignaturesEnabled) {
|
|
sender.connection.sendPlayerChatMessage(playerChatMessage, params);
|
|
+ return;
|
|
}
|
|
|
|
+ sender.connection.sendDisguisedChatMessage(playerChatMessage.decoratedContent(), params);
|
|
+ // Scissors end
|
|
}
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 7d160cdc01d85c4fdc78342051c92be26e394a7f..b55d78ae48ebc18b857f28084fe86ea41e574cd9 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -1,5 +1,6 @@
|
|
package net.minecraft.server.network;
|
|
|
|
+import me.totalfreedom.scissors.ScissorsConfig;
|
|
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.primitives.Floats;
|
|
@@ -2366,6 +2367,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
Optional<LastSeenMessages> optional = this.lastSeenMessages.applyUpdate(acknowledgment);
|
|
|
|
if (optional.isEmpty()) {
|
|
+ // Scissors start - Add configuration option to disable chat signatures
|
|
+ if (!ScissorsConfig.chatSignaturesEnabled)
|
|
+ {
|
|
+ return optional;
|
|
+ }
|
|
+ // Scissors end
|
|
+
|
|
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
|
this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
|
|
}
|
|
@@ -2601,6 +2609,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
synchronized (this.lastSeenMessages) {
|
|
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
|
|
+ // Scissors start - Add configuration option to disable chat signatures
|
|
+ if (!ScissorsConfig.chatSignaturesEnabled)
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+ // Scissors end
|
|
+
|
|
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
|
this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
|
|
}
|