diff --git a/forge-mod/gradle.properties b/forge-mod/gradle.properties index 87d6051..d522331 100644 --- a/forge-mod/gradle.properties +++ b/forge-mod/gradle.properties @@ -49,7 +49,7 @@ mod_name=Leisure Time Dock Mod # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=MIT # The mod version. See https://semver.org/ -mod_version=1.1.1 +mod_version=1.1.2 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/forge-mod/src/main/java/com/leisuretimedock/crossmod/mixin/MixinPlayerList.java b/forge-mod/src/main/java/com/leisuretimedock/crossmod/mixin/MixinPlayerList.java index f16e7fa..68a4d9b 100644 --- a/forge-mod/src/main/java/com/leisuretimedock/crossmod/mixin/MixinPlayerList.java +++ b/forge-mod/src/main/java/com/leisuretimedock/crossmod/mixin/MixinPlayerList.java @@ -2,6 +2,7 @@ package com.leisuretimedock.crossmod.mixin; import com.leisuretimedock.crossmod.config.CrossServerConfigManager; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.contents.TranslatableContents; import net.minecraft.server.players.PlayerList; import org.slf4j.Logger; import org.spongepowered.asm.mixin.Final; @@ -23,8 +24,16 @@ public class MixinPlayerList { ) private void send(Component message, boolean bypassHiddenChat, CallbackInfo ci) { try { - if (CrossServerConfigManager.INSTANCE.isDisabledJoinQuitMessage() && message.toString().contains("multiplayer.player.joined") || message.toString().contains("multiplayer.player.left")) { - ci.cancel(); + if (CrossServerConfigManager.INSTANCE.isDisabledJoinQuitMessage()) { + // 更好的方式:检查消息的翻译键 + if (message.getContents() instanceof TranslatableContents translatable) { + String key = translatable.getKey(); + if ("multiplayer.player.joined".equals(key) || + "multiplayer.player.joined.renamed".equals(key) || + "multiplayer.player.left".equals(key)) { + ci.cancel(); + } + } } } catch (Exception e) { LOGGER.warn("Exception while sending system message to client", e);