Fix for faction not being disbanded properly when last player leaves

Fix for some NoClassDefFoundErrors when Register plugin isn't present and certain economy functions are used
This commit is contained in:
Brettflan 2011-10-12 23:44:59 -05:00
parent 329cef6465
commit cace4aa955
2 changed files with 12 additions and 6 deletions

View File

@ -622,9 +622,12 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
} }
} }
this.resetFactionData();
if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty()) if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty())
{ {
// Transfer all money // Transfer all money
if (Econ.shouldBeUsed())
Econ.transferMoney(this, myFaction, this, myFaction.getAccount().balance()); Econ.transferMoney(this, myFaction, this, myFaction.getAccount().balance());
// Remove this faction // Remove this faction
@ -632,12 +635,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
{ {
fplayer.msg("<i>%s<i> was disbanded.", myFaction.describeTo(fplayer, true)); fplayer.msg("<i>%s<i> was disbanded.", myFaction.describeTo(fplayer, true));
} }
//Faction.delete(myFaction.getId());
myFaction.detach(); myFaction.detach();
} }
this.resetFactionData();
} }
public boolean attemptClaim(boolean notifyFailure) public boolean attemptClaim(boolean notifyFailure)

View File

@ -69,6 +69,8 @@ public class Econ
public static void modifyUniverseMoney(double delta) public static void modifyUniverseMoney(double delta)
{ {
if (!shouldBeUsed()) return;
MethodAccount acc = getUniverseAccount(); MethodAccount acc = getUniverseAccount();
if (acc == null) return; if (acc == null) return;
acc.add(delta); acc.add(delta);
@ -103,6 +105,8 @@ public class Econ
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount)
{ {
if ( ! shouldBeUsed()) return false;
// The amount must be positive. // The amount must be positive.
// If the amount is negative we must flip and multiply amount with -1. // If the amount is negative we must flip and multiply amount with -1.
if (amount < 0) if (amount < 0)
@ -161,6 +165,8 @@ public class Econ
public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis) public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis)
{ {
if ( ! shouldBeUsed()) return false;
MethodAccount acc = ep.getAccount(); MethodAccount acc = ep.getAccount();
String You = ep.describeTo(ep, true); String You = ep.describeTo(ep, true);