[BUG] Fix MessageBroadcastEvent using the wrong thread context (SDLink)
This commit is contained in:
@@ -11,11 +11,13 @@ public class MessageBroadcastEvent extends CraterEvent {
|
|||||||
private final Component component;
|
private final Component component;
|
||||||
private final Function<ServerPlayer, Component> function;
|
private final Function<ServerPlayer, Component> function;
|
||||||
private final boolean bl;
|
private final boolean bl;
|
||||||
|
private final String threadName;
|
||||||
|
|
||||||
public MessageBroadcastEvent(Component component, Function<ServerPlayer, Component> function, boolean bl) {
|
public MessageBroadcastEvent(Component component, Function<ServerPlayer, Component> function, boolean bl, String threadName) {
|
||||||
this.component = component;
|
this.component = component;
|
||||||
this.function = function;
|
this.function = function;
|
||||||
this.bl = bl;
|
this.bl = bl;
|
||||||
|
this.threadName = threadName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getComponent() {
|
public Component getComponent() {
|
||||||
@@ -30,6 +32,10 @@ public class MessageBroadcastEvent extends CraterEvent {
|
|||||||
return function;
|
return function;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getThreadName() {
|
||||||
|
return threadName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canCancel() {
|
public boolean canCancel() {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -24,7 +24,8 @@ public class PlayerListMixin {
|
|||||||
|
|
||||||
@Inject(method = "broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Ljava/util/function/Function;Z)V", at = @At("HEAD"))
|
@Inject(method = "broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Ljava/util/function/Function;Z)V", at = @At("HEAD"))
|
||||||
private void injectBroadcastEvent(Component component, Function<ServerPlayer, Component> function, boolean bl, CallbackInfo ci) {
|
private void injectBroadcastEvent(Component component, Function<ServerPlayer, Component> function, boolean bl, CallbackInfo ci) {
|
||||||
MessageBroadcastEvent event = new MessageBroadcastEvent(component, function, bl);
|
String thread = Thread.currentThread().getStackTrace()[3].getClassName();
|
||||||
|
MessageBroadcastEvent event = new MessageBroadcastEvent(component, function, bl, thread);
|
||||||
CraterEventBus.INSTANCE.postEvent(event);
|
CraterEventBus.INSTANCE.postEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user