[BUG] Fix MessageBroadcastEvent using the wrong thread context (SDLink)

This commit is contained in:
2024-01-02 08:29:01 +02:00
parent 9c05bec9a0
commit 0e4a46f98a
2 changed files with 9 additions and 2 deletions

View File

@@ -11,11 +11,13 @@ public class MessageBroadcastEvent extends CraterEvent {
private final Component component;
private final UUID uuid;
private final ChatType bl;
private final String threadName;
public MessageBroadcastEvent(Component component, UUID uuid, ChatType bl) {
public MessageBroadcastEvent(Component component, UUID uuid, ChatType bl, String threadName) {
this.component = component;
this.uuid = uuid;
this.bl = bl;
this.threadName = threadName;
}
public Component getComponent() {
@@ -30,6 +32,10 @@ public class MessageBroadcastEvent extends CraterEvent {
return uuid;
}
public String getThreadName() {
return threadName;
}
@Override
public boolean canCancel() {
return false;

View File

@@ -24,7 +24,8 @@ public class PlayerListMixin {
@Inject(method = "broadcastMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/ChatType;Ljava/util/UUID;)V", at = @At("HEAD"))
private void injectBroadcast(Component component, ChatType chatType, UUID uUID, CallbackInfo ci) {
MessageBroadcastEvent event = new MessageBroadcastEvent(component, uUID, chatType);
String thread = Thread.currentThread().getStackTrace()[3].getClassName();
MessageBroadcastEvent event = new MessageBroadcastEvent(component, uUID, chatType, thread);
CraterEventBus.INSTANCE.postEvent(event);
}