From f08db2d23442179b61f86a52f2b084ce75f1bd73 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Wed, 9 Dec 2020 11:31:37 +0100 Subject: [PATCH] Fix startup #BlameGerry --- .../java/us/myles/ViaVersion/ViaVersionPlugin.java | 3 ++- .../bukkit/listeners/ProtocolLibEnableListener.java | 10 +++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java b/bukkit/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java index 682904946..ba1fd2576 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java @@ -53,7 +53,6 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform // Init platform BukkitViaInjector injector = new BukkitViaInjector(); injector.setProtocolLib(Bukkit.getPluginManager().getPlugin("ProtocolLib") != null); - Bukkit.getPluginManager().registerEvents(new ProtocolLibEnableListener(injector), this); Via.init(ViaManager.builder() .platform(this) @@ -117,6 +116,8 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform getCommand("viaversion").setExecutor(commandHandler); getCommand("viaversion").setTabCompleter(commandHandler); + getServer().getPluginManager().registerEvents(new ProtocolLibEnableListener(), this); + // Warn them if they have anti-xray on and they aren't using spigot if (conf.isAntiXRay() && !spigot) { getLogger().info("You have anti-xray on in your config, since you're not using spigot it won't fix xray!"); diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/ProtocolLibEnableListener.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/ProtocolLibEnableListener.java index a818fbd50..a9253fc13 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/ProtocolLibEnableListener.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/ProtocolLibEnableListener.java @@ -4,26 +4,22 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginEnableEvent; +import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.bukkit.platform.BukkitViaInjector; public class ProtocolLibEnableListener implements Listener { - private final BukkitViaInjector injector; - - public ProtocolLibEnableListener(BukkitViaInjector injector) { - this.injector = injector; - } @EventHandler public void onPluginEnable(PluginEnableEvent e) { if (e.getPlugin().getName().equals("ProtocolLib")) { - injector.setProtocolLib(true); + ((BukkitViaInjector) Via.getManager().getInjector()).setProtocolLib(true); } } @EventHandler public void onPluginDisable(PluginDisableEvent e) { if (e.getPlugin().getName().equals("ProtocolLib")) { - injector.setProtocolLib(false); + ((BukkitViaInjector) Via.getManager().getInjector()).setProtocolLib(false); } } }