mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-01 04:37:09 +00:00
106 lines
6.7 KiB
Diff
106 lines
6.7 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Telesphoreo <me@telesphoreo.me>
|
||
|
Date: Mon, 15 Apr 2024 23:01:26 -0500
|
||
|
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
|
||
|
index c87b708c368713a23a10ad97704575ee4df27891..a650bdccc7f8fe77abe2750c9939f5eb0ccfd57b 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 {
|
||
|
@@ -46,9 +47,20 @@ public interface OutgoingChatMessage {
|
||
|
// Paper end
|
||
|
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
|
||
|
playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
|
||
|
- if (!playerChatMessage.isFullyFiltered()) {
|
||
|
+ // Sccissors start
|
||
|
+ if (!playerChatMessage.isFullyFiltered() && ScissorsConfig.chatSignaturesEnabled) {
|
||
|
sender.connection.sendPlayerChatMessage(playerChatMessage, params);
|
||
|
+ return;
|
||
|
}
|
||
|
+ sender.connection.sendPlayerChatMessage(new PlayerChatMessage(
|
||
|
+ SignedMessageLink.unsigned(playerChatMessage.sender()),
|
||
|
+ null,
|
||
|
+ SignedMessageBody.unsigned(playerChatMessage.signedContent()),
|
||
|
+ unsigned,
|
||
|
+ playerChatMessage.filterMask(),
|
||
|
+ playerChatMessage.result()
|
||
|
+ ), params);
|
||
|
+ // Scissors end
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||
|
index 0af9ed92824ccf30814eceb6a2c2e5c12661c991..c92374104b4aed2f952b250c5559ab9cc83532da 100644
|
||
|
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||
|
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||
|
@@ -5,6 +5,8 @@ import java.time.Instant;
|
||
|
import java.util.UUID;
|
||
|
import java.util.function.BooleanSupplier;
|
||
|
import javax.annotation.Nullable;
|
||
|
+
|
||
|
+import me.totalfreedom.scissors.ScissorsConfig;
|
||
|
import net.minecraft.util.SignatureValidator;
|
||
|
import net.minecraft.util.Signer;
|
||
|
import net.minecraft.world.entity.player.ProfilePublicKey;
|
||
|
@@ -45,7 +47,7 @@ public class SignedMessageChain {
|
||
|
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
|
||
|
LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", body.content());
|
||
|
}
|
||
|
|
||
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||
|
index b2971440e73dcce2beee936313568cbb06d32312..88c98ba7673808819b8f85876f22743bc3a4f471 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; // Scissors
|
||
|
import com.google.common.collect.Lists;
|
||
|
import com.google.common.primitives.Floats;
|
||
|
@@ -2243,7 +2244,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||
|
|
||
|
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
|
||
|
ServerGamePacketListenerImpl.LOGGER.warn("Failed to update secure chat state for {}: '{}'", this.player.getGameProfile().getName(), exception.getComponent().getString());
|
||
|
- 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));
|
||
|
@@ -2291,6 +2292,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||
|
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
|
||
|
}
|
||
|
@@ -2489,6 +2491,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||
|
|
||
|
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
|
||
|
}
|
||
|
@@ -3460,6 +3463,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||
|
@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();
|