mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-14 19:34:54 -05:00
Add configuration option to disable chat signatures (#71)
Ported to 1.19.3
This commit is contained in:
parent
23ac49a449
commit
1dddffad0d
2 changed files with 102 additions and 61 deletions
|
@ -1,61 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
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 bd82f0316df85b621c1970ff30bbbec0d2712ccd..19d9c1e500c89271fd8aa19280cdcc9e472a0bd4 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;
|
||||
@@ -87,6 +88,14 @@ public interface OutgoingPlayerChatMessage {
|
||||
// Paper end
|
||||
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
|
||||
playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
|
||||
+
|
||||
+ // Scissors start - Add configuration option to disable chat signatures
|
||||
+ if (!ScissorsConfig.chatSignaturesEnabled)
|
||||
+ {
|
||||
+ playerChatMessage = PlayerChatMessage.system(new ChatMessageContent(playerChatMessage.serverContent().getString(), playerChatMessage.serverContent()));
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (!playerChatMessage.isFullyFiltered()) {
|
||||
this.playersWithFullMessage.add(sender);
|
||||
RegistryAccess registryAccess = sender.level.registryAccess();
|
|
@ -0,0 +1,102 @@
|
|||
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
|
||||
}
|
Loading…
Reference in a new issue