mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-27 21:29:47 +01:00
Fix Forge plugin msg messenger (#3894)
Co-authored-by: powercas_gamer <cas@mizule.dev>
This commit is contained in:
parent
b5400f885b
commit
c3802c2a5a
@ -49,6 +49,7 @@ import me.lucko.luckperms.forge.listeners.ForgeCommandListUpdater;
|
||||
import me.lucko.luckperms.forge.listeners.ForgeConnectionListener;
|
||||
import me.lucko.luckperms.forge.listeners.ForgePlatformListener;
|
||||
import me.lucko.luckperms.forge.messaging.ForgeMessagingFactory;
|
||||
import me.lucko.luckperms.forge.messaging.PluginMessageMessenger;
|
||||
import me.lucko.luckperms.forge.service.ForgePermissionHandlerListener;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
@ -100,6 +101,8 @@ public class LPForgePlugin extends AbstractLuckPermsPlugin {
|
||||
|
||||
this.commandManager = new ForgeCommandExecutor(this);
|
||||
this.bootstrap.registerListeners(this.commandManager);
|
||||
|
||||
PluginMessageMessenger.registerChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,10 +45,10 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class PluginMessageMessenger extends AbstractPluginMessageMessenger implements Messenger {
|
||||
private static final ResourceLocation CHANNEL = new ResourceLocation(AbstractPluginMessageMessenger.CHANNEL);
|
||||
private static final ResourceLocation CHANNEL_ID = new ResourceLocation(AbstractPluginMessageMessenger.CHANNEL);
|
||||
private static final EventNetworkChannel CHANNEL = ChannelBuilder.named(CHANNEL_ID).eventNetworkChannel();
|
||||
|
||||
private final LPForgePlugin plugin;
|
||||
private EventNetworkChannel channel;
|
||||
|
||||
public PluginMessageMessenger(LPForgePlugin plugin, IncomingMessageConsumer consumer) {
|
||||
super(consumer);
|
||||
@ -56,8 +56,7 @@ public class PluginMessageMessenger extends AbstractPluginMessageMessenger imple
|
||||
}
|
||||
|
||||
public void init() {
|
||||
this.channel = ChannelBuilder.named(CHANNEL).eventNetworkChannel();
|
||||
this.channel.addListener(event -> {
|
||||
CHANNEL.addListener(event -> {
|
||||
byte[] buf = new byte[event.getPayload().readableBytes()];
|
||||
event.getPayload().readBytes(buf);
|
||||
|
||||
@ -83,7 +82,7 @@ public class PluginMessageMessenger extends AbstractPluginMessageMessenger imple
|
||||
FriendlyByteBuf byteBuf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
byteBuf.writeBytes(buf);
|
||||
|
||||
this.channel.send(byteBuf, PacketDistributor.PLAYER.with(player));
|
||||
CHANNEL.send(byteBuf, PacketDistributor.PLAYER.with(player));
|
||||
|
||||
SchedulerTask t = taskRef.getAndSet(null);
|
||||
if (t != null) {
|
||||
@ -93,4 +92,9 @@ public class PluginMessageMessenger extends AbstractPluginMessageMessenger imple
|
||||
taskRef.set(task);
|
||||
}
|
||||
|
||||
public static void registerChannel() {
|
||||
// do nothing - the channels are registered in the static initializer, we just
|
||||
// need to make sure that is called (which it will be if this method runs)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user