Avoid NPE that could arrise due to NPC plugins etc.

This commit is contained in:
Olof Larsson
2013-07-31 14:50:28 +02:00
parent 9f5753a682
commit 9aaa6de945
2 changed files with 22 additions and 19 deletions

View File

@ -587,14 +587,16 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
public boolean isInOwnTerritory()
{
// TODO: Use Mixin to get this PS instead
return BoardColls.get().getFactionAt(Mixin.getSenderPs(this.getId())) == this.getFaction();
PS ps = Mixin.getSenderPs(this.getId());
if (ps == null) return false;
return BoardColls.get().getFactionAt(ps) == this.getFaction();
}
public boolean isInEnemyTerritory()
{
// TODO: Use Mixin to get this PS instead
return BoardColls.get().getFactionAt(Mixin.getSenderPs(this.getId())).getRelationTo(this) == Rel.ENEMY;
PS ps = Mixin.getSenderPs(this.getId());
if (ps == null) return false;
return BoardColls.get().getFactionAt(ps).getRelationTo(this) == Rel.ENEMY;
}
// -------------------------------------------- //