these changes fixes a few startup errors related to non-attached factions lacking universe.

This commit is contained in:
Olof Larsson 2013-04-24 18:22:52 +02:00
parent 80eb506499
commit 82e380cd3d
8 changed files with 25 additions and 31 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 B

View File

@ -43,11 +43,11 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
@Override
public Faction load(Faction that)
{
this.tag = that.tag;
this.setTag(that.tag);
this.setDescription(that.description);
this.home = that.home;
this.setHome(that.home);
this.setPowerBoost(that.powerBoost);
this.open = that.open;
this.setOpen(that.open);
this.setInvitedPlayerIds(that.invitedPlayerIds);
this.setRelationWishes(that.relationWish);
this.setFlags(that.flagOverrides);
@ -238,6 +238,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public void setHome(PS home)
{
this.home = home;
this.changed();
}
// -------------------------------------------- //
@ -255,10 +256,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
public void setPowerBoost(Double powerBoost)
{
if (powerBoost == null || powerBoost == 0)
{
powerBoost = null;
}
if (powerBoost == null || powerBoost == 0) powerBoost = null;
this.powerBoost = powerBoost;
this.changed();
}
@ -470,6 +468,8 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
target.putAll(flags);
}
if (this.attached() && Factions.get().isDatabaseInitialized())
{
Iterator<Entry<FFlag, Boolean>> iter = target.entrySet().iterator();
while (iter.hasNext())
{
@ -479,6 +479,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
iter.remove();
}
}
}
if (target == null || target.isEmpty())
{
@ -542,6 +543,8 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
}
}
if (this.attached() && Factions.get().isDatabaseInitialized())
{
Iterator<Entry<FPerm, Set<Rel>>> iter = target.entrySet().iterator();
while (iter.hasNext())
{
@ -551,6 +554,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
iter.remove();
}
}
}
if (target == null || target.isEmpty())
{

View File

@ -20,7 +20,6 @@ import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.ps.PS;
import com.massivecraft.mcore.ps.PSFormatSlug;
import com.massivecraft.mcore.store.SenderEntity;
import com.massivecraft.mcore.util.MUtil;
import com.massivecraft.mcore.util.SenderUtil;
@ -186,24 +185,18 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
// This setter is so long because it search for default/null case and takes care of updating the faction member index
public void setFactionId(String factionId)
{
// Avoid null input
if (factionId == null) factionId = this.getDefaultFactionId();
// Get the old value
String oldFactionId = this.getFactionId();
// Ignore nochange
if (factionId.equals(oldFactionId)) return;
// Get the raw old value
String oldFactionId = this.factionId;
// Apply change
if (factionId.equals(this.getDefaultFactionId())) factionId = null;
this.factionId = factionId;
// Next we must be attached and inited
if (!this.attached()) return;
if (!this.getColl().inited()) return;
if (!Factions.get().isDatabaseInitialized()) return;
if (oldFactionId == null) oldFactionId = this.getDefaultFactionId();
// Update index
Faction oldFaction = FactionColls.get().get(this).get(oldFactionId);
Faction faction = FactionColls.get().get(this).get(factionId);
@ -237,7 +230,6 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
public void setRole(Rel role)
{
if (role == null || MUtil.equals(role, this.getDefaultRole())) role = null;
this.role = role;
this.changed();
}
@ -328,8 +320,6 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
public void setPower(Double power)
{
if (power == null || MUtil.equals(power, this.getDefaultPower())) power = null;
power = this.getLimitedPower(power);
this.power = power;
this.changed();
}