Faction homes should no longer be lost if their target world isn't already loaded when Factions loads at server startup. This is done using a new lazy-load Location container class which only initializes the Location when it's actually needed.

This commit is contained in:
Brettflan
2012-03-14 13:06:38 -05:00
parent 7b9674dc4b
commit d8a39140fc
5 changed files with 128 additions and 32 deletions

View File

@@ -65,16 +65,18 @@ public class Faction extends Entity implements EconomyParticipator
public void setDescription(String value) { this.description = value; }
// FIELD: home
private Location home;
public void setHome(Location home) { this.home = home; }
public Location getHome() { confirmValidHome(); return home; }
private LazyLocation home;
public void setHome(Location home) { this.home = new LazyLocation(home); }
public boolean hasHome() { return this.getHome() != null; }
public Location getHome()
{
confirmValidHome();
return (this.home != null) ? this.home.getLocation() : null;
}
public void confirmValidHome()
{
if (!Conf.homesMustBeInClaimedTerritory || this.home == null || Board.getFactionAt(new FLocation(this.home)) == this)
{
if (!Conf.homesMustBeInClaimedTerritory || this.home == null || Board.getFactionAt(new FLocation(this.home.getLocation())) == this)
return;
}
msg("<b>Your faction home has been un-set since it is no longer in your territory.");
this.home = null;