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:39 -06:00
parent fb92fb7c68
commit 5ac0baf84a
2 changed files with 26 additions and 7 deletions

View File

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

View File

@ -32,7 +32,26 @@ public class Econ
{ {
return econ != null; 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() public static void doSetup()
{ {
if (isSetup()) return; if (isSetup()) return;
@ -40,6 +59,11 @@ public class Econ
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null)
{ {
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class); 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(); econ = rsp.getProvider();
P.p.log("Economy integration through Vault plugin successful."); P.p.log("Economy integration through Vault plugin successful.");
@ -47,10 +71,6 @@ public class Econ
if ( ! Conf.econEnabled) if ( ! Conf.econEnabled)
P.p.log("NOTE: Economy is disabled. Enable with command: f config econEnabled true"); 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(); P.p.cmdBase.cmdHelp.updateHelp();
} }