9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-30 12:29:13 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0131-Mirai-Configurable-chat-message-signatures.patch
Dreeam e7915c3726 Updated Upstream (Leaves)
Upstream has released updates that appear to apply and compile correctly

Leaves Changes:
LeavesMC/Leaves@08bfa446 Lithium Sleeping Block Entity(#618) (#630)
LeavesMC/Leaves@610eee60 fix: fix bot resume CME (#635)
LeavesMC/Leaves@04dac366 Fix vanilla display name (#638)
LeavesMC/Leaves@e5aba7eb feat: hopper counter unlimited speed(#625) (#639)
LeavesMC/Leaves@e44e469a fix: fix SleepingBlockEntity crash when /tick freeze (#640)
LeavesMC/Leaves@5d653e31 fix: fix faster chunk serialization patch (#641)
LeavesMC/Leaves@cb6cd658 [ci/skip] chore: fix patch header
LeavesMC/Leaves@8d9a5b2f [ci/skip]chore: rename hopper counter enable config (#644)
LeavesMC/Leaves@cc019e8f [ci/skip] feat: add Bukkit.getFeatureManager api (#645)
LeavesMC/Leaves@81da0c5e [ci/skip] Bring back LivingEntity effect CME (#648)
LeavesMC/Leaves@ea91106a fix: fix hopper counter config (#646)
LeavesMC/Leaves@230e0987 feat: mount action(#619) (#649)
LeavesMC/Leaves@d9f7afc4 fix: fix sleeping block entity(#654) (#655)
LeavesMC/Leaves@12f665c0 Refactor actions (#650)
LeavesMC/Leaves@c29ff9a8 feat: swap action (#657)
LeavesMC/Leaves@3c09044e fix: fix grindstone curse book overstacking(#658) (#659)
LeavesMC/Leaves@e05f3f7c Update paper, revert #632 (#662)
LeavesMC/Leaves@0c866281 Bot Improvements (#661)
LeavesMC/Leaves@956f0227 feat: add skipTripwireHookPlacementValidation to mc-technical-mode, and format config (#664)
LeavesMC/Leaves@e047327c fix: fix bot use raytrace (#669)
LeavesMC/Leaves@29327349 Fix #667 (#668)
LeavesMC/Leaves@08f53c97 Fix bot cant get entity tracker (#670)
LeavesMC/Leaves@e0d62b4e fix photographer bugs (#666)
LeavesMC/Leaves@d094bdad fix: fix raid(#626) (#671)
LeavesMC/Leaves@678d4e20 Revert "Fix bot cant get entity tracker (#670)"
LeavesMC/Leaves@e298d097 [ci/skip] fix: fix patch name (#672)
LeavesMC/Leaves@099be5b8 [ci/skip] fix: fix push to api fail when commit contains double quotation marks (#677)
LeavesMC/Leaves@ba8993d3 Fix fakeplayer cant get entity tracker correctly (#676)
LeavesMC/Leaves@d93e9766  feat: merge old raid config, fix bugs (#680)
LeavesMC/Leaves@bf55b2a4 fix: fix sleeping block entity bug (#682)
LeavesMC/Leaves@5366b382 Fix creative no clip with projectile (#683)
LeavesMC/Leaves@e55edbf8 Resolves #685  (#687)
LeavesMC/Leaves@a591ec57 Do not tick Arrow life regardless (#688)
LeavesMC/Leaves@3623aea8 fix: stupid me (#689)
LeavesMC/Leaves@73e63912 feat: update leavesclip to 3.0.7 (#681)
LeavesMC/Leaves@bb5a1dff [ci/skip] fix: fix comment (#692)
LeavesMC/Leaves@d87bc544 Fix #690 (#691)
LeavesMC/Leaves@79d9ef74 Update paper (#693)
LeavesMC/Leaves@71790286 Fix optimize noise generation
LeavesMC/Leaves@3ffbde0b Optimize config transfer and remove
LeavesMC/Leaves@62e62242 feat: add logger for internal plugin, and format api code (#696)
LeavesMC/Leaves@f37e9d37 Fix fakeplayer break action
LeavesMC/Leaves@aeb8e07d Fix fakeplayer break action * 2
LeavesMC/Leaves@40af0399 Fix StackableShulker config validator
LeavesMC/Leaves@122c7365 Fix fakeplayer use action
LeavesMC/Leaves@0ee80784 fix: fix photographer bugs (#699)
LeavesMC/Leaves@a30c9abb Remove, and opt config and config command
LeavesMC/Leaves@4b21a968 New shears wrench (#700)
LeavesMC/Leaves@0f40159c Enhance update suppression (#701)
LeavesMC/Leaves@374605cd Fix bot (#705)
LeavesMC/Leaves@ff563baf Fix creative no clip can attract xp-orb (#706)
LeavesMC/Leaves@f0de3ecd refactor: use client side judgement instead of special judgement (#708)
2025-08-20 05:53:39 +08: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 bef92cfa7eb86fbc6bc1b7d862eaca575eeeadec..8817aee7eb61e130aacc4f0df980036b92500ad1 100644
--- a/net/minecraft/network/FriendlyByteBuf.java
+++ b/net/minecraft/network/FriendlyByteBuf.java
@@ -119,6 +119,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 a491be4250de3199c3e1aa9e5482b568692bd2f5..5db038df25a1b5bf2f7395464250dc0bbf8d8241 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 87fc8861948b50361ec04c5a23406d3abdec6eac..77f11179836636424927843f5f10c3fd23d2b2d4 100644
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -614,6 +614,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 82c22ca54cc7c8371b744c93f133dfc2b798195b..6b73679351f786362daf988b02b2a226d6b43984 100644
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -363,10 +363,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 ChannelFutureListener channelFutureListener) {
+ // 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 && channelFutureListener != 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 cd7e2e7bdfff90b7147de20dd44fdf2709c4c28f..f09c1472d465de94b16e958ec7051f34aae7402f 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -1506,7 +1506,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;
@@ -1531,6 +1531,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());
}