From 5978dbe176e98d4848c9882f7d974cd20745a961 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Sat, 9 Nov 2024 00:23:57 +0100 Subject: [PATCH] Warn unsigned messages --- .../java/cc/reconnected/server/RccServer.java | 17 +++++++++++++++++ .../server/mixin/SentMessageMixin.java | 5 +++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/cc/reconnected/server/RccServer.java b/src/main/java/cc/reconnected/server/RccServer.java index 4ae55a6..d61e31b 100644 --- a/src/main/java/cc/reconnected/server/RccServer.java +++ b/src/main/java/cc/reconnected/server/RccServer.java @@ -85,6 +85,7 @@ public class RccServer implements ModInitializer { } public static final RegistryKey CHAT_TYPE = RegistryKey.of(RegistryKeys.MESSAGE_TYPE, new Identifier(MOD_ID, "chat")); + private static boolean warnedAboutUnsignedMessages = false; @Override public void onInitialize() { @@ -196,4 +197,20 @@ public class RccServer implements ModInitializer { } } + public static void warnUnsignedMessages() { + if (warnedAboutUnsignedMessages) + return; + warnedAboutUnsignedMessages = true; + + LOGGER.warn( + """ + !!! --- WARNING --- !!! + Cannot retrieve message sender UUID! + + If you are using FabricProxy-Lite, consider disabling + the `hackMessageChain` configuration! + """ + ); + } + } \ No newline at end of file diff --git a/src/main/java/cc/reconnected/server/mixin/SentMessageMixin.java b/src/main/java/cc/reconnected/server/mixin/SentMessageMixin.java index 0984c16..6c1b0b3 100644 --- a/src/main/java/cc/reconnected/server/mixin/SentMessageMixin.java +++ b/src/main/java/cc/reconnected/server/mixin/SentMessageMixin.java @@ -1,5 +1,6 @@ package cc.reconnected.server.mixin; +import cc.reconnected.server.RccServer; import cc.reconnected.server.core.customChat.CustomSentMessage; import net.minecraft.network.message.SentMessage; import net.minecraft.network.message.SignedMessage; @@ -10,11 +11,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(SentMessage.class) public interface SentMessageMixin { - @Inject(method = "of", at = @At("HEAD"), cancellable = true) private static void rccServer$of(SignedMessage message, CallbackInfoReturnable cir) { - if(message.isSenderMissing()) { + if (message.isSenderMissing()) { + RccServer.warnUnsignedMessages(); cir.setReturnValue(new SentMessage.Profileless(message.getContent())); } else { cir.setReturnValue(new CustomSentMessage(message));