9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0133-Mirai-Configurable-chat-message-signatures.patch
Dreeam acc71b20a9 Updated Upstream (Paper/Purpur)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@89cdcba5 [ci/skip] Replace wiki mention for BlockType#isOccluding (#12446)
PaperMC/Paper@5f0b8292 Re-add chunk position check to regionfile recalculation patch
PaperMC/Paper@04b91129 Update projects dependents GitHub Action (#12436)
PaperMC/Paper@def0532f Fix writing headers and update to be more papery (#12459)
PaperMC/Paper@d22644aa Expand cooldown API (#12435)
PaperMC/Paper@df429932 Fix floating warning log when the kick event is canceled (#12374)
PaperMC/Paper@a820bdae [ci/skip] Some javadoc fixes
PaperMC/Paper@55f20209 Fix CCE in LingeringPotionSplashEvent (#12463)
PaperMC/Paper@1410a22b Fix passengers sending when riding players
PaperMC/Paper@767868dd Fix some components (#12457)
PaperMC/Paper@9cddf136 Fix portal create event block list (#12373)
PaperMC/Paper@a112d370 Fix horse_variant and tropical_fish_pattern (#12472)
PaperMC/Paper@a211ac2e Remove unused warning (#12478)
PaperMC/Paper@ae512811 Add isSuffocating to Block and BlockState (#12445)
PaperMC/Paper@3409e2d7 Mace was not included in the ENCHANTABLE MaterialSetTag (#12476)
PaperMC/Paper@1cfc96bc Add keyStream() API to registries (#12479)
PaperMC/Paper@3222985e [ci/skip] Rebuild patches
PaperMC/Paper@deaccd2c [ci/skip] Add file reference url to help.yml (#12481)
PaperMC/Paper@f86b4352 Add vault change state event (#12069)
PaperMC/Paper@3e3b42cd Update player chat session sync (#12382)
PaperMC/Paper@f8fa4f6f Add method to retrieve FishHook (#12310)
PaperMC/Paper@b9d3147d Use correct placed block position for sound (#12410)
PaperMC/Paper@952338b3 [ci/skip] Add missing exception docs to Player#listPlayer (#12488)
PaperMC/Paper@1db37853 [ci/skip] improve javadoc for off-hand swaps through getHotbarButton (#12489)
PaperMC/Paper@d1810f24 Allow Server#getDefaultGameMode before worlds are initialized (#12490)
PaperMC/Paper@02d20ff7 Fix NPE in Server#getMap before worlds are loaded (#12492)
PaperMC/Paper@9e873f50 Fix inconsistencies between offline/online spawn position getter (#11960)
PaperMC/Paper@fc0c3717 Fix handling of resultant crafting container from craftItemResult (#12307)
PaperMC/Paper@a7a76c8f Add methods for Armadillo (#12031)
PaperMC/Paper@a74400d9 Update adventure to 4.21.0 (#12499)
PaperMC/Paper@1e930763 Fix ipv6 loopback addresses being able to get connection throttled (#12155)
PaperMC/Paper@646b80ca Fix unnecessary map data saves (#12296)
PaperMC/Paper@e663f999 Add combat tracker API (#11853)
PaperMC/Paper@cd4fe5b7 [ci/skip] Drop non-applicable ATs (#12498)
PaperMC/Paper@5acfdd6a Fix save/load NaN Entity Motion (#12269)
PaperMC/Paper@2754d7c3 Add Throw EntityChangeBlockEvent for BrushableBlockEntity#brush (#12133)
PaperMC/Paper@567f63ae Parity for respawn events (#11792)
PaperMC/Paper@bc3d946f Normalizes CraftEntity#toString/getHandle (#12170)
PaperMC/Paper@0e9b94d5 Fix ItemStack amount issues with Chat Components (#12216)
PaperMC/Paper@835b9559 Add a method on InventoryView to get the MenuType (#12193)
PaperMC/Paper@c9411bfb Fix min ItemStack amount check for asHoverEvent (#12505)
PaperMC/Paper@1acf3b38 Infer block entity data in brigadier blockstate argument (#12197)
PaperMC/Paper@b9b3cd65 Use components instead of ChatColor in more places  (#12507)
PaperMC/Paper@ec421715 Add missing spaces back (#12508)

Purpur Changes:
PurpurMC/Purpur@c3870bda Updated Upstream (Paper)
PurpurMC/Purpur@8b5044e0 [ci/skip] add idea project icon
PurpurMC/Purpur@f2f682fb Updated Upstream (Paper)
PurpurMC/Purpur@bdeba761 Updated Upstream (Paper)
PurpurMC/Purpur@96f5b044 drop void damage height/damage migration
PurpurMC/Purpur@6cc78b63 Updated Upstream (Paper)
PurpurMC/Purpur@4ce97c1d [ci/skip] Update occurences of version numbers to 1.21.5 (#1658)
PurpurMC/Purpur@7f5c4036 Updated Upstream (Paper)
PurpurMC/Purpur@4fdf1d11 Updated Upstream (Paper)
PurpurMC/Purpur@8c77678e Updated Upstream (Paper)
2025-05-02 03:10:20 -04:00

161 lines
10 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: etil2jz <81570777+etil2jz@users.noreply.github.com>
Date: Tue, 2 Aug 2022 14:48:12 +0200
Subject: [PATCH] Mirai: Configurable chat message signatures
Fixed & Updated by Dreeam-qwq
Original license: GPLv3
Original project: https://github.com/Dreeam-qwq/Mirai
Original license: GPLv3
Original project: https://github.com/etil2jz/Mirai
diff --git a/net/minecraft/network/FriendlyByteBuf.java b/net/minecraft/network/FriendlyByteBuf.java
index 7da7d645f83f351e8c964da01734f3074a877ca1..76576f2fd8b267d96186ab337bf4e41520e3cd18 100644
--- a/net/minecraft/network/FriendlyByteBuf.java
+++ b/net/minecraft/network/FriendlyByteBuf.java
@@ -118,6 +118,17 @@ public class FriendlyByteBuf extends ByteBuf {
public <T> void writeJsonWithCodec(Codec<T> codec, T value, int maxLength) {
// Paper end - Adventure; add max length parameter
DataResult<JsonElement> dataResult = codec.encodeStart(JsonOps.INSTANCE, value);
+ // Leaf start - Configurable chat message signatures
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled && codec == net.minecraft.network.protocol.status.ServerStatus.CODEC) {
+ JsonElement element = dataResult.getOrThrow(string -> new EncoderException("Failed to encode: " + string + " " + value));
+
+ element.getAsJsonObject().addProperty("preventsChatReports", true);
+ this.writeUtf(GSON.toJson(element));
+
+ return;
+ }
+ // Leaf end - Configurable chat message signatures
+
this.writeUtf(GSON.toJson(dataResult.getOrThrow(exception -> new EncoderException("Failed to encode: " + exception + " " + value))), maxLength); // Paper - Adventure; add max length parameter
}
diff --git a/net/minecraft/network/protocol/game/ClientboundLoginPacket.java b/net/minecraft/network/protocol/game/ClientboundLoginPacket.java
index 89f06581e2b1f9f0240e7841db2f57dedc5d81b7..ba4ec05a9c9dfa958fdfa4a68ee85bcd9c379883 100644
--- a/net/minecraft/network/protocol/game/ClientboundLoginPacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundLoginPacket.java
@@ -55,7 +55,7 @@ public record ClientboundLoginPacket(
buffer.writeBoolean(this.showDeathScreen);
buffer.writeBoolean(this.doLimitedCrafting);
this.commonPlayerSpawnInfo.write(buffer);
- buffer.writeBoolean(this.enforcesSecureChat);
+ buffer.writeBoolean(!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled || this.enforcesSecureChat); // Leaf - Mirai - Configurable chat message signatures
}
@Override
diff --git a/net/minecraft/network/protocol/game/ServerboundChatPacket.java b/net/minecraft/network/protocol/game/ServerboundChatPacket.java
index b5afc05924ae899e020c303c8b86398e1d4ab8a0..73c2ed488c34cddbafdcbb6f2636264ebcc7286b 100644
--- a/net/minecraft/network/protocol/game/ServerboundChatPacket.java
+++ b/net/minecraft/network/protocol/game/ServerboundChatPacket.java
@@ -23,7 +23,7 @@ public record ServerboundChatPacket(String message, Instant timeStamp, long salt
buffer.writeUtf(this.message, 256);
buffer.writeInstant(this.timeStamp);
buffer.writeLong(this.salt);
- buffer.writeNullable(this.signature, MessageSignature::write);
+ if (org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) buffer.writeNullable(this.signature, MessageSignature::write); // Leaf - Mirai - Configurable chat message signatures
this.lastSeenMessages.write(buffer);
}
diff --git a/net/minecraft/network/protocol/status/ServerStatus.java b/net/minecraft/network/protocol/status/ServerStatus.java
index 094d1821d298fc228270b2d6cf0445949434f3e2..21334ae4764740e5cf1382726d5f5231fa220d5d 100644
--- a/net/minecraft/network/protocol/status/ServerStatus.java
+++ b/net/minecraft/network/protocol/status/ServerStatus.java
@@ -23,7 +23,10 @@ public record ServerStatus(
boolean enforcesSecureChat
) {
public static final Codec<ServerStatus> CODEC = RecordCodecBuilder.create(
- instance -> instance.group(
+ // Leaf start - Mirai - Configurable chat message signatures
+ instance ->
+ org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled
+ ? instance.group(
ComponentSerialization.CODEC.lenientOptionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players),
ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version),
@@ -31,6 +34,15 @@ public record ServerStatus(
Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", false).forGetter(ServerStatus::enforcesSecureChat)
)
.apply(instance, ServerStatus::new)
+ : instance.group(
+ ComponentSerialization.CODEC.lenientOptionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
+ ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players),
+ ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version),
+ ServerStatus.Favicon.CODEC.lenientOptionalFieldOf("favicon").forGetter(ServerStatus::favicon),
+ Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", false).forGetter(x -> true)
+ )
+ .apply(instance, ServerStatus::new)
+ // Leaf end- Mirai - Configurable chat message signatures
);
public record Favicon(byte[] iconBytes) {
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
index cdfb9004dd4f4ea1bbb77895b7fc020d628c485d..54910c2e1d6e6bb556e536fda060bd09402e04e8 100644
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -616,6 +616,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@Override
public boolean enforceSecureProfile() {
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) return false; // Leaf - Mirai - Configurable chat message signatures
DedicatedServerProperties properties = this.getProperties();
// Paper start - Add setting for proxy online mode status
return properties.enforceSecureProfile
diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
index d2e8adccf33c6b842fac615006b782b09cfa7a1a..434be9d08d8e816e2dea1e9d23fa26d21b9f35f6 100644
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -315,10 +315,30 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
}
public void send(Packet<?> packet) {
+ // Leaf start - Mirai - Configurable chat message signatures
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) {
+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat) {
+ packet = new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(
+ chat.chatType().decorate(chat.unsignedContent() != null ? chat.unsignedContent() : Component.literal(chat.body().content())),
+ false
+ );
+ this.send(packet);
+ return;
+ }
+ }
+ // Leaf end - Mirai - Configurable chat message signatures
this.send(packet, null);
}
public void send(Packet<?> packet, @Nullable PacketSendListener listener) {
+ // Leaf start - Mirai - Configurable chat message signatures
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) {
+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat && listener != null) {
+ this.send(chat);
+ return;
+ }
+ }
+ // Leaf end - Mirai - Configurable chat message signatures
// CraftBukkit start
if (packet == null || this.processedDisconnect) { // Spigot
return;
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index 37ba75bd50f785da11a0127fb40d86ee8b988c17..a3fdc328399c5d4806c6f361ba83515cf2094336 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -1386,7 +1386,7 @@ public abstract class PlayerList {
public void broadcastChatMessage(PlayerChatMessage message, Predicate<ServerPlayer> shouldFilterMessageTo, @Nullable ServerPlayer sender, ChatType.Bound boundChatType, @Nullable Function<net.kyori.adventure.audience.Audience, Component> unsignedFunction) {
// Paper end
boolean flag = this.verifyChatTrusted(message);
- this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), boundChatType, flag || !org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.notSecureMarker ? null : "Not Secure"); // Paper // Gale - do not log Not Secure marker
+ this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), boundChatType, !org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled || flag || !org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.notSecureMarker ? null : "Not Secure"); // Paper // Gale - do not log Not Secure marker // Leaf - Mirai - Configurable chat message signatures
OutgoingChatMessage outgoingChatMessage = OutgoingChatMessage.create(message);
boolean flag1 = false;
@@ -1411,6 +1411,7 @@ public abstract class PlayerList {
}
public boolean verifyChatTrusted(PlayerChatMessage message) {
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) return true; // Leaf - Mirai - Configurable chat message signatures
return message.hasSignature() && !message.hasExpiredServer(Instant.now());
}