Fix Vault hook - thanks @Yann151924

This commit is contained in:
Luck 2016-11-14 22:32:06 +00:00
parent b36a33f015
commit de09ae94b8
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 32 additions and 14 deletions

View File

@ -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);
}
}
}

View File

@ -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);

View File

@ -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: