From 45bd1776ee8fb1fc33d07f734b622201fcb07747 Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Tue, 1 Apr 2014 23:09:15 -0500 Subject: [PATCH 1/2] If Vault is not enabled, don't enable Jailpay. --- src/main/java/com/graywolf336/jail/JailPayManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/graywolf336/jail/JailPayManager.java b/src/main/java/com/graywolf336/jail/JailPayManager.java index a96ad11..33a9c19 100644 --- a/src/main/java/com/graywolf336/jail/JailPayManager.java +++ b/src/main/java/com/graywolf336/jail/JailPayManager.java @@ -162,6 +162,7 @@ public class JailPayManager { private boolean setupEconomy(JailMain plugin) { if (economy != null) return true; + else if(!plugin.getServer().getPluginManager().isPluginEnabled("Vault")) return false; RegisteredServiceProvider economyProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); if (economyProvider != null) { From caf4315d6c99f7ac91a2c87d71202a0def31b1a6 Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Tue, 1 Apr 2014 23:21:24 -0500 Subject: [PATCH 2/2] Only initialize JailPayManager if vault exists. --- .../java/com/graywolf336/jail/JailMain.java | 19 +++++++++++-------- .../com/graywolf336/jail/JailPayManager.java | 4 +--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/graywolf336/jail/JailMain.java b/src/main/java/com/graywolf336/jail/JailMain.java index 287661f..6ef05a4 100644 --- a/src/main/java/com/graywolf336/jail/JailMain.java +++ b/src/main/java/com/graywolf336/jail/JailMain.java @@ -92,12 +92,7 @@ public class JailMain extends JavaPlugin { jt = new JailTimer(this); - try { - jpm = new JailPayManager(this); - } catch (Exception e) { - getLogger().severe(e.getMessage()); - jpm = null; - } + reloadJailPayManager(); sbm = new ScoreBoardManager(this); @@ -192,9 +187,17 @@ public class JailMain extends JavaPlugin { * * @throws Exception If we couldn't successfully create a new Jail Pay Manager instance. */ - public void reloadJailPayManager() throws Exception { + public void reloadJailPayManager() { this.jpm = null; - this.jpm = new JailPayManager(this); + + if(getConfig().getBoolean(Settings.JAILPAYENABLED.getPath())) { + if(getServer().getPluginManager().isPluginEnabled("Vault")) { + this.jpm = new JailPayManager(this); + }else { + getConfig().set(Settings.JAILPAYENABLED.getPath(), false); + getLogger().severe("Jail Pay couldn't find an economy, disabling Jail Pay."); + } + } } /** Gets the {@link HandCuffManager} instance. */ diff --git a/src/main/java/com/graywolf336/jail/JailPayManager.java b/src/main/java/com/graywolf336/jail/JailPayManager.java index 33a9c19..550cf2a 100644 --- a/src/main/java/com/graywolf336/jail/JailPayManager.java +++ b/src/main/java/com/graywolf336/jail/JailPayManager.java @@ -16,7 +16,7 @@ public class JailPayManager { private Material item; private boolean infinite, timed; - public JailPayManager(JailMain plugin) throws Exception { + public JailPayManager(JailMain plugin) { this.item = Material.getMaterial(plugin.getConfig().getString(Settings.JAILPAYITEM.getPath().toUpperCase())); if(this.item == null) this.item = Material.AIR; @@ -25,7 +25,6 @@ public class JailPayManager { if(!this.usingItemsForPayment()) { if(!this.setupEconomy(plugin)) { plugin.getConfig().set(Settings.JAILPAYENABLED.getPath(), false); - throw new Exception("Jail Pay couldn't find an economy, disabling Jail Pay."); } } @@ -162,7 +161,6 @@ public class JailPayManager { private boolean setupEconomy(JailMain plugin) { if (economy != null) return true; - else if(!plugin.getServer().getPluginManager().isPluginEnabled("Vault")) return false; RegisteredServiceProvider economyProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); if (economyProvider != null) {