Skip to content

Commit

Permalink
load vault hook after server load (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgeiss0702 authored Nov 29, 2021
1 parent 9086502 commit 27af825
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down

0 comments on commit 27af825

Please sign in to comment.