|
27 | 27 | import dev.renoux.emotes.utils.EmoteProcessor; |
28 | 28 | import net.minecraft.core.BlockPos; |
29 | 29 | import net.minecraft.network.chat.*; |
| 30 | +import net.minecraft.network.chat.contents.TranslatableContents; |
30 | 31 | import net.minecraft.server.level.ServerPlayer; |
31 | 32 | import net.minecraft.world.entity.player.Player; |
32 | 33 | import net.minecraft.world.level.Level; |
@@ -54,7 +55,13 @@ public ServerPlayerMixin(Level world, BlockPos pos, float yaw, GameProfile gameP |
54 | 55 | @Inject(method = "sendSystemMessage(Lnet/minecraft/network/chat/Component;)V", at = @At("HEAD"), cancellable = true) |
55 | 56 | private void onSendMessage(Component message, CallbackInfo ci) { |
56 | 57 | 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 | + } |
58 | 65 | } else { |
59 | 66 | this.sendSystemMessage(processSiblings(message.toFlatList()), false); |
60 | 67 | } |
@@ -87,7 +94,13 @@ private Component processSiblings(List<Component> siblings) { |
87 | 94 | if (!sibling.getSiblings().isEmpty()) { |
88 | 95 | newSibling = processSiblings(sibling.toFlatList()); |
89 | 96 | } 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 | + } |
91 | 104 | } |
92 | 105 | newComponent.append(newSibling); |
93 | 106 | } |
|
0 commit comments