2023-07-01 20:21:13 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2024-04-16 05:12:25 +00:00
From: Telesphoreo <me@telesphoreo.me>
Date: Mon, 15 Apr 2024 23:01:26 -0500
2023-07-01 20:21:13 +00:00
Subject: [PATCH] Add configuration option to disable chat signatures
diff --git a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
2024-04-21 17:53:01 +00:00
index c87b708c368713a23a10ad97704575ee4df27891..4a8ab800d4a974aaf14872d50dcf01c806a0fe3b 100644
2023-07-01 20:21:13 +00:00
--- 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;
2023-12-11 01:20:31 +00:00
+import me.totalfreedom.scissors.ScissorsConfig;
2023-07-01 20:21:13 +00:00
import net.minecraft.server.level.ServerPlayer;
public interface OutgoingChatMessage {
2024-04-21 17:53:01 +00:00
@@ -46,9 +47,19 @@ public interface OutgoingChatMessage {
2023-07-01 20:21:13 +00:00
// Paper end
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
- if (!playerChatMessage.isFullyFiltered()) {
2023-12-11 01:20:31 +00:00
+ // Sccissors start
2023-07-01 20:21:13 +00:00
+ if (!playerChatMessage.isFullyFiltered() && ScissorsConfig.chatSignaturesEnabled) {
sender.connection.sendPlayerChatMessage(playerChatMessage, params);
+ return;
}
2023-07-30 16:29:13 +00:00
+ sender.connection.sendPlayerChatMessage(new PlayerChatMessage(
+ SignedMessageLink.unsigned(playerChatMessage.sender()),
+ null,
+ SignedMessageBody.unsigned(playerChatMessage.signedContent()),
+ unsigned,
2024-04-21 17:53:01 +00:00
+ playerChatMessage.filterMask()
2023-07-30 16:29:13 +00:00
+ ), params);
2023-07-01 20:21:13 +00:00
+ // Scissors end
}
}
}
diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
2024-04-16 05:12:25 +00:00
index 0af9ed92824ccf30814eceb6a2c2e5c12661c991..c92374104b4aed2f952b250c5559ab9cc83532da 100644
2023-07-01 20:21:13 +00:00
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
2023-12-11 01:20:31 +00:00
@@ -5,6 +5,8 @@ import java.time.Instant;
2023-07-01 20:21:13 +00:00
import java.util.UUID;
2023-12-11 01:20:31 +00:00
import java.util.function.BooleanSupplier;
2023-07-01 20:21:13 +00:00
import javax.annotation.Nullable;
2023-12-11 01:20:31 +00:00
+
+import me.totalfreedom.scissors.ScissorsConfig;
2023-07-01 20:21:13 +00:00
import net.minecraft.util.SignatureValidator;
import net.minecraft.util.Signer;
2024-04-16 05:12:25 +00:00
import net.minecraft.world.entity.player.ProfilePublicKey;
@@ -45,7 +47,7 @@ public class SignedMessageChain {
2023-07-01 20:21:13 +00:00
if (!playerChatMessage.verify(signatureValidator)) {
throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.unsigned_chat"), true, org.bukkit.event.player.PlayerKickEvent.Cause.UNSIGNED_CHAT); // Paper - kick event causes
} else {
- if (playerChatMessage.hasExpiredServer(Instant.now())) {
+ if (playerChatMessage.hasExpiredServer(Instant.now()) && ScissorsConfig.chatSignaturesEnabled) { // Scissors
2024-04-16 05:12:25 +00:00
LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", body.content());
2023-07-01 20:21:13 +00:00
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2024-04-21 17:37:04 +00:00
index 80f0f88258770862f419e4faba4cfca4c0457b2c..c0aa9520d547d6d77169fd1dbb02844b90ef4a1d 100644
2023-07-01 20:21:13 +00:00
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2023-10-15 22:45:13 +00:00
@@ -1,5 +1,6 @@
2023-07-01 20:21:13 +00:00
package net.minecraft.server.network;
2023-12-11 01:20:31 +00:00
+import me.totalfreedom.scissors.ScissorsConfig;
2023-10-15 22:45:13 +00:00
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
2023-07-01 20:21:13 +00:00
import com.google.common.collect.Lists;
import com.google.common.primitives.Floats;
2024-02-18 18:44:06 +00:00
@@ -2243,7 +2244,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2023-07-01 20:21:13 +00:00
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
2023-12-11 01:20:31 +00:00
ServerGamePacketListenerImpl.LOGGER.warn("Failed to update secure chat state for {}: '{}'", this.player.getGameProfile().getName(), exception.getComponent().getString());
2023-07-01 20:21:13 +00:00
- if (exception.shouldDisconnect()) {
+ if (exception.shouldDisconnect() && ScissorsConfig.chatSignaturesEnabled) { // Scissors - Do not kick when chat signatures are disabled
this.disconnect(exception.getComponent(), exception.kickCause); // Paper - kick event causes
} else {
this.player.sendSystemMessage(exception.getComponent().copy().withStyle(ChatFormatting.RED));
2024-02-18 18:44:06 +00:00
@@ -2291,6 +2292,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2023-07-01 20:21:13 +00:00
Optional<LastSeenMessages> optional = this.lastSeenMessages.applyUpdate(acknowledgment);
if (optional.isEmpty()) {
+ if (!ScissorsConfig.chatSignaturesEnabled) return optional; // Scissors
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
}
2024-02-18 18:44:06 +00:00
@@ -2489,6 +2491,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2023-07-01 20:21:13 +00:00
synchronized (this.lastSeenMessages) {
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
+ if (!ScissorsConfig.chatSignaturesEnabled) return; // Scissors
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
}
2024-04-21 17:37:04 +00:00
@@ -3473,6 +3476,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2023-07-30 16:29:13 +00:00
@Override
public void handleChatSessionUpdate(ServerboundChatSessionUpdatePacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
+ if (!ScissorsConfig.chatSignaturesEnabled) return; // Scissors
RemoteChatSession.Data remotechatsession_a = packet.chatSession();
ProfilePublicKey.Data profilepublickey_a = this.chatSession != null ? this.chatSession.profilePublicKey().data() : null;
ProfilePublicKey.Data profilepublickey_a1 = remotechatsession_a.profilePublicKey();