From e32933ada980951365906e31cf80cfc2e907b3bc Mon Sep 17 00:00:00 2001 From: Pablo Herrera Date: Mon, 19 Jun 2023 17:02:05 +0200 Subject: [PATCH] Fix late registration of join listener (#3360) --- .../java/com/viaversion/viaversion/ViaVersionPlugin.java | 6 ++++++ .../viaversion/bukkit/platform/BukkitViaLoader.java | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bukkit/src/main/java/com/viaversion/viaversion/ViaVersionPlugin.java b/bukkit/src/main/java/com/viaversion/viaversion/ViaVersionPlugin.java index 9d04eded4..3fd3ff155 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/ViaVersionPlugin.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/ViaVersionPlugin.java @@ -103,6 +103,12 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform manager.init(); } + if (Via.getConfig().shouldRegisterUserConnectionOnJoin()) { + // When event priority ties, registration order is used. + // Must register without delay to ensure other plugins on lowest get the fix applied. + getServer().getPluginManager().registerEvents(new JoinListener(), this); + } + if (FOLIA) { // Use Folia's RegionizedServerInitEvent to run code after the server has loaded final Class serverInitEventClass; diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaLoader.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaLoader.java index f115e6c67..5148178df 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaLoader.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaLoader.java @@ -79,10 +79,6 @@ public class BukkitViaLoader implements ViaPlatformLoader { public void load() { registerListener(new UpdateListener()); - if (Via.getConfig().shouldRegisterUserConnectionOnJoin()) { - registerListener(new JoinListener()); - } - /* Base Protocol */ final ViaVersionPlugin plugin = (ViaVersionPlugin) Bukkit.getPluginManager().getPlugin("ViaVersion");