mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Better feedback messages while setting up economy support
Showing economy name on successful linking for convenience sake
This commit is contained in:
parent
057e8cea31
commit
edb1d5d2e7
@ -33,32 +33,47 @@ public class HookEconomyTask implements Runnable {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
enum hookResult {
|
||||
novault, noeconomy, pass;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (setVault())
|
||||
|
||||
hookResult result = setVault();
|
||||
|
||||
if (result.equals(hookResult.pass)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// no Economy found
|
||||
Jobs.setEconomy(new BlackholeEconomy());
|
||||
Jobs.getPluginLogger().severe("==================== " + plugin.getDescription().getName() + " ====================");
|
||||
if (result.equals(hookResult.novault)) {
|
||||
Jobs.getPluginLogger().severe("Vault is required by this plugin for economy support!");
|
||||
Jobs.getPluginLogger().severe("Please install them first!");
|
||||
Jobs.getPluginLogger().severe("You can find the latest versions here:");
|
||||
Jobs.getPluginLogger().severe("https://www.spigotmc.org/resources/34315/");
|
||||
} else {
|
||||
Jobs.getPluginLogger().severe("Vault detected but economy plugin still missing!");
|
||||
Jobs.getPluginLogger().severe("Please install Vault supporting economy plugin!");
|
||||
}
|
||||
Jobs.getPluginLogger().severe("==============================================");
|
||||
}
|
||||
|
||||
private boolean setVault() {
|
||||
private hookResult setVault() {
|
||||
if (!plugin.getServer().getPluginManager().isPluginEnabled("Vault"))
|
||||
return false;
|
||||
return hookResult.novault;
|
||||
|
||||
RegisteredServiceProvider<Economy> provider = plugin.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (provider == null)
|
||||
return false;
|
||||
if (provider == null) {
|
||||
return hookResult.noeconomy;
|
||||
}
|
||||
|
||||
Jobs.setEconomy(new VaultEconomy(provider.getProvider()));
|
||||
Jobs.consoleMsg("&e[" + plugin.getDescription().getName() + "] Successfully linked with Vault.");
|
||||
return true;
|
||||
Jobs.consoleMsg("&e[" + plugin.getDescription().getName() + "] Successfully linked with Vault. (" + provider.getProvider().getName() + ")");
|
||||
return hookResult.pass;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user