修复删除加入、离开消息隐藏

This commit is contained in:
叁玖领域 2026-06-06 03:34:46 +08:00
parent d7f222442c
commit 2e5e1195b5
2 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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,9 +24,17 @@ 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")) {
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);
}