From 5ac0baf84a7fa095fa3abe6c186c94af0c289416 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Sat, 28 Jan 2012 05:24:39 -0600 Subject: [PATCH] Fix for Vault economy integration bugging out if the target economy plugin loaded after Factions (really seems like a Vault issue, but we'll work around it) Fix for users who have Vault but don't use economy getting an NPE --- src/com/massivecraft/factions/P.java | 3 +- .../factions/integration/Econ.java | 30 +++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/com/massivecraft/factions/P.java b/src/com/massivecraft/factions/P.java index b0d89cb8..a64d26eb 100644 --- a/src/com/massivecraft/factions/P.java +++ b/src/com/massivecraft/factions/P.java @@ -99,8 +99,7 @@ public class P extends MPlugin //setupPermissions(); integrateEssentialsChat(); setupSpout(this); - Econ.doSetup(); - Econ.oldMoneyDoTransfer(); + Econ.initialSetup(this); CapiFeatures.setup(); setupLWC(); diff --git a/src/com/massivecraft/factions/integration/Econ.java b/src/com/massivecraft/factions/integration/Econ.java index cff3919b..8237ae27 100644 --- a/src/com/massivecraft/factions/integration/Econ.java +++ b/src/com/massivecraft/factions/integration/Econ.java @@ -32,7 +32,26 @@ public class Econ { return econ != null; } - + + public static void initialSetup(P p) + { + if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) + { + P.p.log("Economy integration is "+(Conf.econEnabled ? "enabled, but" : "disabled, and")+" the plugin \"Vault\" is not installed."); + return; + } + + p.getServer().getScheduler().scheduleSyncDelayedTask(p, new Runnable() + { + @Override + public void run() + { + doSetup(); + oldMoneyDoTransfer(); + } + }, 1); + } + public static void doSetup() { if (isSetup()) return; @@ -40,6 +59,11 @@ public class Econ if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) { RegisteredServiceProvider rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class); + if (rsp == null) + { + P.p.log("Economy integration is "+(Conf.econEnabled ? "enabled" : "disabled")+", but the plugin \"Vault\" is not hooked into an economy plugin."); + return; + } econ = rsp.getProvider(); P.p.log("Economy integration through Vault plugin successful."); @@ -47,10 +71,6 @@ public class Econ if ( ! Conf.econEnabled) P.p.log("NOTE: Economy is disabled. Enable with command: f config econEnabled true"); } - else - { - P.p.log("Economy integration is "+(Conf.econEnabled ? "enabled, but" : "disabled, and")+" the plugin \"Vault\" is not installed."); - } P.p.cmdBase.cmdHelp.updateHelp(); }