mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-30 08:06:01 +00:00
107 lines
6.6 KiB
Diff
107 lines
6.6 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/net/minecraft/network/chat/OutgoingChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
|
index 74cf1c043beef03cfd5adf481414a5ee78bef2a6..516c61cbb8299828b2f28d4564d08ae1829649b5 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; // Scissors
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
|
|
public interface OutgoingChatMessage {
|
|
@@ -44,10 +45,21 @@ public interface OutgoingChatMessage {
|
|
// Paper end
|
|
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
|
|
playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
|
|
- if (!playerChatMessage.isFullyFiltered()) {
|
|
+ // Scissors 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 c0a80824a0307ea673805015119cc834b268f0dc..9f28f86b1b56ea55ab39f6ac988c1f47c5312c6c 100644
|
|
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
|
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
|
@@ -4,6 +4,7 @@ import com.mojang.logging.LogUtils;
|
|
import java.time.Instant;
|
|
import java.util.UUID;
|
|
import javax.annotation.Nullable;
|
|
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
|
import net.minecraft.util.SignatureUpdater;
|
|
import net.minecraft.util.SignatureValidator;
|
|
import net.minecraft.util.Signer;
|
|
@@ -41,7 +42,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?", (Object)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 001b7ae2067809d7da1d84d7637639f21a1aa980..ad87d90de1679955cb5a9d1c925be7d281cc64c9 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -1,5 +1,7 @@
|
|
package net.minecraft.server.network;
|
|
|
|
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
|
+import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.primitives.Floats;
|
|
import com.mojang.authlib.GameProfile;
|
|
@@ -2219,7 +2221,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
}
|
|
|
|
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
|
|
- 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));
|
|
@@ -2275,6 +2277,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
|
|
}
|
|
@@ -2483,6 +2486,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
|
|
}
|
|
@@ -3456,6 +3460,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();
|