Warn unsigned messages
This commit is contained in:
parent
ca0a5761cb
commit
5978dbe176
2 changed files with 20 additions and 2 deletions
|
@ -85,6 +85,7 @@ public class RccServer implements ModInitializer {
|
|||
}
|
||||
|
||||
public static final RegistryKey<MessageType> 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!
|
||||
"""
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<SentMessage> cir) {
|
||||
|
||||
if(message.isSenderMissing()) {
|
||||
if (message.isSenderMissing()) {
|
||||
RccServer.warnUnsignedMessages();
|
||||
cir.setReturnValue(new SentMessage.Profileless(message.getContent()));
|
||||
} else {
|
||||
cir.setReturnValue(new CustomSentMessage(message));
|
||||
|
|
Loading…
Reference in a new issue