修复删除加入、离开消息隐藏
This commit is contained in:
parent
d7f222442c
commit
2e5e1195b5
|
|
@ -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.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=MIT
|
mod_license=MIT
|
||||||
# The mod version. See https://semver.org/
|
# 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.
|
# 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.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.leisuretimedock.crossmod.mixin;
|
||||||
|
|
||||||
import com.leisuretimedock.crossmod.config.CrossServerConfigManager;
|
import com.leisuretimedock.crossmod.config.CrossServerConfigManager;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.chat.contents.TranslatableContents;
|
||||||
import net.minecraft.server.players.PlayerList;
|
import net.minecraft.server.players.PlayerList;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
|
@ -23,8 +24,16 @@ public class MixinPlayerList {
|
||||||
)
|
)
|
||||||
private void send(Component message, boolean bypassHiddenChat, CallbackInfo ci) {
|
private void send(Component message, boolean bypassHiddenChat, CallbackInfo ci) {
|
||||||
try {
|
try {
|
||||||
if (CrossServerConfigManager.INSTANCE.isDisabledJoinQuitMessage() && message.toString().contains("multiplayer.player.joined") || message.toString().contains("multiplayer.player.left")) {
|
if (CrossServerConfigManager.INSTANCE.isDisabledJoinQuitMessage()) {
|
||||||
ci.cancel();
|
// 更好的方式:检查消息的翻译键
|
||||||
|
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) {
|
} catch (Exception e) {
|
||||||
LOGGER.warn("Exception while sending system message to client", e);
|
LOGGER.warn("Exception while sending system message to client", e);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user