Minor changes to npe detection and denied commands

This commit is contained in:
Olof Larsson 2013-04-26 11:06:07 +02:00
parent 7626aed06a
commit 7ce0100e73
3 changed files with 6 additions and 17 deletions

View File

@ -101,7 +101,6 @@ public class BoardColls extends XColls<BoardColl, Board> implements BoardInterfa
@Override
public TerritoryAccess getTerritoryAccessAt(PS ps)
{
if (ps == null) return null;
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return null;
return coll.getTerritoryAccessAt(ps);
@ -110,7 +109,6 @@ public class BoardColls extends XColls<BoardColl, Board> implements BoardInterfa
@Override
public Faction getFactionAt(PS ps)
{
if (ps == null) return null;
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return null;
return coll.getFactionAt(ps);
@ -121,7 +119,6 @@ public class BoardColls extends XColls<BoardColl, Board> implements BoardInterfa
@Override
public void setTerritoryAccessAt(PS ps, TerritoryAccess territoryAccess)
{
if (ps == null) return;
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return;
coll.setTerritoryAccessAt(ps, territoryAccess);
@ -130,7 +127,6 @@ public class BoardColls extends XColls<BoardColl, Board> implements BoardInterfa
@Override
public void setFactionAt(PS ps, Faction faction)
{
if (ps == null) return;
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return;
coll.setFactionAt(ps, faction);
@ -141,7 +137,6 @@ public class BoardColls extends XColls<BoardColl, Board> implements BoardInterfa
@Override
public void removeAt(PS ps)
{
if (ps == null) return;
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return;
coll.removeAt(ps);
@ -194,7 +189,6 @@ public class BoardColls extends XColls<BoardColl, Board> implements BoardInterfa
@Override
public boolean isBorderPs(PS ps)
{
if (ps == null) return false;
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return false;
return coll.isBorderPs(ps);
@ -203,7 +197,6 @@ public class BoardColls extends XColls<BoardColl, Board> implements BoardInterfa
@Override
public boolean isConnectedPs(PS ps, Faction faction)
{
if (ps == null) return false;
BoardColl coll = this.getForWorld(ps.getWorld());
if (coll == null) return false;
return coll.isConnectedPs(ps, faction);
@ -214,7 +207,6 @@ public class BoardColls extends XColls<BoardColl, Board> implements BoardInterfa
@Override
public ArrayList<String> getMap(RelationParticipator observer, PS centerPs, double inDegrees)
{
if (centerPs == null) return null;
BoardColl coll = this.getForWorld(centerPs.getWorld());
if (coll == null) return null;
return coll.getMap(observer, centerPs, inDegrees);

View File

@ -515,12 +515,6 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
return RelationUtil.getRelationOfThatToMe(this, observer, ignorePeaceful);
}
public Rel getRelationToLocation()
{
// TODO: Use some built in system to get sender
return BoardColls.get().getFactionAt(PS.valueOf(this.getPlayer())).getRelationTo(this);
}
@Override
public ChatColor getColorTo(RelationParticipator observer)
{

View File

@ -454,10 +454,13 @@ public class FactionsListenerMain implements Listener
return;
}
// ... the command may be denied in the territory of this relation type ...
Rel rel = uplayer.getRelationToLocation();
// ... if there is a faction at the players location ...
PS ps = PS.valueOf(player).getChunk(true);
if (BoardColls.get().getFactionAt(ps).isNone()) return;
Faction factionAtPs = BoardColls.get().getFactionAt(ps);
if (factionAtPs.isNone()) return;
// ... the command may be denied in the territory of this relation type ...
Rel rel = factionAtPs.getRelationTo(uplayer);
List<String> deniedCommands = UConf.get(player).denyCommandsTerritoryRelation.get(rel);
if (deniedCommands == null) return;