mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-04 15:41:40 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@6ea679eb Allow listening to plugin messages during configuration phase (#12775) PaperMC/Paper@c3be00f0 Always call plugin message dispatch on PlayerConnection PaperMC/Paper@3fec37a9 Move the double call into the dispatch method PaperMC/Paper@108255cb Reduce PlayerLoginEvent alt behavior nag for now (#12782) PaperMC/Paper@2141ca52 Port plugins command to brigadier (#12632) PaperMC/Paper@0cadaefc Fix quitmessage nullability issues (#12783) Purpur Changes: PurpurMC/Purpur@2d8cdd15 Updated Upstream (Paper)
161 lines
10 KiB
Diff
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 87f5e88ff6e557d51d7ce4942413215e371b6b29..c66207aaa3f62bac1d2c2707654a473a69e38b73 100644
|
|
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
@@ -337,10 +337,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 56876236505d17663900857e4b6777f1778538a6..f439712ec2cc021360583b2ae70f837e2a9417ac 100644
|
|
--- a/net/minecraft/server/players/PlayerList.java
|
|
+++ b/net/minecraft/server/players/PlayerList.java
|
|
@@ -1517,7 +1517,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;
|
|
|
|
@@ -1542,6 +1542,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());
|
|
}
|
|
|