From ea23a28ec6022e4e80032b3409f486ecb96151fd Mon Sep 17 00:00:00 2001 From: ajgeiss0702 Date: Mon, 22 Nov 2021 11:44:08 -0700 Subject: [PATCH] load vault hook after server load --- .../java/com/andrei1058/bedwars/BedWars.java | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java index a420ba20d..4c4e94e2c 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java @@ -421,31 +421,37 @@ public void onEnable() { new PAPISupport().register(); SupportPAPI.setSupportPAPI(new SupportPAPI.withPAPI()); } - /* Vault support */ - if (this.getServer().getPluginManager().getPlugin("Vault") != null) { - try { - //noinspection rawtypes - RegisteredServiceProvider rsp = this.getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class); - WithChat.setChat((net.milkbowl.vault.chat.Chat) rsp.getProvider()); - plugin.getLogger().info("Hook into vault chat support!"); - chat = new WithChat(); - } catch (Exception var2_2) { + /* + * Vault support + * The task is to initialize after all plugins have loaded, + * to make sure any economy/chat plugins have been loaded and registered. + */ + Bukkit.getScheduler().runTask(this, () -> { + if (this.getServer().getPluginManager().getPlugin("Vault") != null) { + try { + //noinspection rawtypes + RegisteredServiceProvider rsp = this.getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class); + WithChat.setChat((net.milkbowl.vault.chat.Chat) rsp.getProvider()); + plugin.getLogger().info("Hook into vault chat support!"); + chat = new WithChat(); + } catch (Exception var2_2) { + chat = new NoChat(); + } + try { + //noinspection rawtypes + registerEvents(new MoneyListeners()); + RegisteredServiceProvider rsp = this.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); + WithEconomy.setEconomy((net.milkbowl.vault.economy.Economy) rsp.getProvider()); + plugin.getLogger().info("Hook into vault economy support!"); + economy = new WithEconomy(); + } catch (Exception var2_2) { + economy = new NoEconomy(); + } + } else { chat = new NoChat(); - } - try { - //noinspection rawtypes - registerEvents(new MoneyListeners()); - RegisteredServiceProvider rsp = this.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); - WithEconomy.setEconomy((net.milkbowl.vault.economy.Economy) rsp.getProvider()); - plugin.getLogger().info("Hook into vault economy support!"); - economy = new WithEconomy(); - } catch (Exception var2_2) { economy = new NoEconomy(); } - } else { - chat = new NoChat(); - economy = new NoEconomy(); - } + }); /* Chat support */ if (config.getBoolean("formatChat")) {