Skip to content

Commit f5f60dd

Browse files
committed
🐛 Prevent processing of translation keys in system messages
1 parent 7d37b2f commit f5f60dd

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/main/java/dev/renoux/emotes/mixins/ServerPlayerMixin.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import dev.renoux.emotes.utils.EmoteProcessor;
2828
import net.minecraft.core.BlockPos;
2929
import net.minecraft.network.chat.*;
30+
import net.minecraft.network.chat.contents.TranslatableContents;
3031
import net.minecraft.server.level.ServerPlayer;
3132
import net.minecraft.world.entity.player.Player;
3233
import net.minecraft.world.level.Level;
@@ -54,7 +55,13 @@ public ServerPlayerMixin(Level world, BlockPos pos, float yaw, GameProfile gameP
5455
@Inject(method = "sendSystemMessage(Lnet/minecraft/network/chat/Component;)V", at = @At("HEAD"), cancellable = true)
5556
private void onSendMessage(Component message, CallbackInfo ci) {
5657
if (message.toFlatList().isEmpty()) {
57-
this.sendSystemMessage(EmoteProcessor.processMessage(message.getString(), message.getStyle()), false);
58+
if (message.getContents() instanceof TranslatableContents) {
59+
// If the message is a translation key, we don't want to process it
60+
this.sendSystemMessage(message, false);
61+
} else {
62+
// Process the message normally
63+
this.sendSystemMessage(EmoteProcessor.processMessage(message.getString(), message.getStyle()), false);
64+
}
5865
} else {
5966
this.sendSystemMessage(processSiblings(message.toFlatList()), false);
6067
}
@@ -87,7 +94,13 @@ private Component processSiblings(List<Component> siblings) {
8794
if (!sibling.getSiblings().isEmpty()) {
8895
newSibling = processSiblings(sibling.toFlatList());
8996
} else {
90-
newSibling = EmoteProcessor.processMessage(sibling.getString(), sibling.getStyle());
97+
if (sibling.getContents() instanceof TranslatableContents) {
98+
// If the sibling is a translation key, we don't want to process it
99+
newSibling = sibling;
100+
} else {
101+
// Process the sibling normally
102+
newSibling = EmoteProcessor.processMessage(sibling.getString(), sibling.getStyle());
103+
}
91104
}
92105
newComponent.append(newSibling);
93106
}

0 commit comments

Comments
 (0)