Move EssentialsX global channel to EventPriority LAST

This commit is contained in:
Vankka 2024-06-21 15:14:32 +03:00
parent f8898be428
commit c9c101b803
No known key found for this signature in database
GPG Key ID: 62E48025ED4E7EBB

View File

@ -2,6 +2,7 @@ package com.discordsrv.bukkit.integration;
import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.channel.GameChannel;
import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.component.MinecraftComponent;
import com.discordsrv.api.event.bus.EventPriority;
import com.discordsrv.api.event.bus.Subscribe; import com.discordsrv.api.event.bus.Subscribe;
import com.discordsrv.api.event.events.channel.GameChannelLookupEvent; import com.discordsrv.api.event.events.channel.GameChannelLookupEvent;
import com.discordsrv.api.event.events.message.receive.game.GameChatMessageReceiveEvent; import com.discordsrv.api.event.events.message.receive.game.GameChatMessageReceiveEvent;
@ -19,6 +20,7 @@ import net.essentialsx.api.v2.events.chat.GlobalChatEvent;
import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -53,6 +55,16 @@ public class EssentialsXIntegration
return super.isEnabled(); return super.isEnabled();
} }
@Override
public void enable() {
discordSRV.server().getPluginManager().registerEvents(this, discordSRV.plugin());
}
@Override
public void disable() {
HandlerList.unregisterAll(this);
}
private Essentials get() { private Essentials get() {
return (Essentials) discordSRV.server().getPluginManager().getPlugin("Essentials"); return (Essentials) discordSRV.server().getPluginManager().getPlugin("Essentials");
} }
@ -113,7 +125,7 @@ public class EssentialsXIntegration
)); ));
} }
@Subscribe @Subscribe(priority = EventPriority.LAST)
public void onGameChannelLookup(GameChannelLookupEvent event) { public void onGameChannelLookup(GameChannelLookupEvent event) {
if (checkProcessor(event) || !discordSRV.server().getPluginManager().isPluginEnabled("EssentialsChat")) { if (checkProcessor(event) || !discordSRV.server().getPluginManager().isPluginEnabled("EssentialsChat")) {
return; return;