Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load vault hook after server load #114

Merged
merged 1 commit into from
Nov 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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