[FEAT] Improved chat handling for mods like StyledChat

This commit is contained in:
2024-08-08 21:34:36 +02:00
parent 862b5b2af4
commit 2c13d507c3
3 changed files with 6 additions and 3 deletions

View File

@@ -27,7 +27,8 @@ public class ServerGamePacketListenerImplMixin {
cancellable = true
)
private void injectChatEvent(PlayerChatMessage arg, Component arg2, FilteredText arg3, CallbackInfo ci) {
CraterServerChatEvent event = new CraterServerChatEvent(BridgedPlayer.of(this.player), arg.decoratedContent().getString(), ChatUtils.mojangToAdventure(arg.decoratedContent()));
Component finalArg = arg2 == null ? arg.decoratedContent() : arg2;
CraterServerChatEvent event = new CraterServerChatEvent(BridgedPlayer.of(this.player), finalArg.getString(), ChatUtils.mojangToAdventure(finalArg));
CraterEventBus.INSTANCE.postEvent(event);
if (event.wasCancelled())
ci.cancel();