diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitListener.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitListener.java index bf5f1b72..10e5b225 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitListener.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitListener.java @@ -35,6 +35,7 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.server.PluginEnableEvent; import java.util.UUID; @@ -143,4 +144,11 @@ class BukkitListener extends AbstractListener implements Listener { e.getPlayer().sendMessage(Message.OP_DISABLED.toString()); } } + + @EventHandler + public void onPluginEnable(PluginEnableEvent e) { + if (e.getPlugin().getName().equalsIgnoreCase("Vault")) { + plugin.tryVaultHook(true); + } + } } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java index 3ec569c1..b6996c90 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java @@ -198,19 +198,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin { } // Provide vault support - getLog().info("Attempting to hook into Vault..."); - try { - if (getServer().getPluginManager().isPluginEnabled("Vault")) { - vaultHook = new VaultHook(); - vaultHook.hook(this); - getLog().info("Registered Vault permission & chat hook."); - } else { - getLog().info("Vault not found."); - } - } catch (Exception e) { - getLog().severe("Error occurred whilst hooking into Vault."); - e.printStackTrace(); - } + tryVaultHook(false); // register with the LP API getLog().info("Registering API..."); @@ -268,6 +256,27 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin { } } + public void tryVaultHook(boolean force) { + if (vaultHook != null) { + return; + } + + getLog().info("Attempting to hook with Vault..."); + try { + if (force || getServer().getPluginManager().isPluginEnabled("Vault")) { + vaultHook = new VaultHook(); + vaultHook.hook(this); + getLog().info("Registered Vault permission & chat hook."); + } else { + getLog().info("Vault not found."); + } + } catch (Exception e) { + vaultHook = null; + getLog().severe("Error occurred whilst hooking into Vault."); + e.printStackTrace(); + } + } + @Override public void doAsync(Runnable r) { asyncExecutor.execute(r); diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 641ada88..63d6efc0 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -5,7 +5,8 @@ author: Luck website: https://github.com/lucko/LuckPerms main: me.lucko.luckperms.bukkit.LPBukkitPlugin -softdepend: [Vault, PermissionsEx, GroupManager, PowerfulPerms, zPermissions, bPermissions] # For migration +load: STARTUP +softdepend: [PermissionsEx, GroupManager, PowerfulPerms, zPermissions, bPermissions] # For migration commands: luckperms: