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
This commit is contained in:
Brettflan 2012-01-28 05:24:36 -06:00
parent fc04e0a446
commit 7c8e25fb8f
2 changed files with 26 additions and 7 deletions

View File

@ -94,8 +94,7 @@ public class P extends MPlugin
//setupPermissions();
integrateEssentialsChat();
setupSpout(this);
Econ.doSetup();
Econ.oldMoneyDoTransfer();
Econ.initialSetup(this);
CapiFeatures.setup();
setupLWC();

View File

@ -33,7 +33,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;
@ -41,6 +60,11 @@ public class Econ
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null)
{
RegisteredServiceProvider<Economy> 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.");
@ -48,10 +72,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();
}