1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-02 23:43:44 +01:00

Better feedback messages while setting up economy support

Showing economy name on successful linking for convenience sake
This commit is contained in:
Zrips 2023-02-14 12:33:30 +02:00
parent 057e8cea31
commit edb1d5d2e7

View File

@ -30,35 +30,50 @@ public class HookEconomyTask implements Runnable {
private Jobs plugin; private Jobs plugin;
public HookEconomyTask(Jobs plugin) { public HookEconomyTask(Jobs plugin) {
this.plugin = plugin; this.plugin = plugin;
}
enum hookResult {
novault, noeconomy, pass;
} }
@Override @Override
public void run() { public void run() {
if (setVault())
return;
// no Economy found hookResult result = setVault();
Jobs.setEconomy(new BlackholeEconomy());
Jobs.getPluginLogger().severe("==================== " + plugin.getDescription().getName() + " ===================="); if (result.equals(hookResult.pass)) {
Jobs.getPluginLogger().severe("Vault is required by this plugin for economy support!"); return;
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/"); // no Economy found
Jobs.getPluginLogger().severe("=============================================="); 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")) if (!plugin.getServer().getPluginManager().isPluginEnabled("Vault"))
return false; return hookResult.novault;
RegisteredServiceProvider<Economy> provider = plugin.getServer().getServicesManager().getRegistration(Economy.class); RegisteredServiceProvider<Economy> provider = plugin.getServer().getServicesManager().getRegistration(Economy.class);
if (provider == null) if (provider == null) {
return false; return hookResult.noeconomy;
}
Jobs.setEconomy(new VaultEconomy(provider.getProvider())); Jobs.setEconomy(new VaultEconomy(provider.getProvider()));
Jobs.consoleMsg("&e[" + plugin.getDescription().getName() + "] Successfully linked with Vault."); Jobs.consoleMsg("&e[" + plugin.getDescription().getName() + "] Successfully linked with Vault. (" + provider.getProvider().getName() + ")");
return true; return hookResult.pass;
} }
} }