mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-17 18:56:12 +00:00
2109ba025d
* Remove patch that is now in Paper * Redirect Paper's safe component method to ours
102 lines
6.1 KiB
Diff
102 lines
6.1 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..1a44bad14ce764d6c09f38065ee8e5f0da4975aa 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,25 @@ 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;
|
|
}
|
|
|
|
+ if (sender.getServer().server.getOnlineMode()) {
|
|
+ sender.connection.sendDisguisedChatMessage(playerChatMessage.decoratedContent(), params);
|
|
+ } else {
|
|
+ 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 52fb4163e8d7e0b9d859ac5d2827f8695f6b867f..3c798443b7eb52dd0b66bdb27422f6e198d48c2c 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; // Scissors
|
|
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.primitives.Floats;
|
|
@@ -2313,7 +2314,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
}
|
|
|
|
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));
|
|
@@ -2369,6 +2370,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
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
|
|
}
|
|
@@ -2604,6 +2606,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
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
|
|
}
|