Added some checks for null values to the GatesManager class.

This commit is contained in:
Tobias Ottenweller 2013-05-18 19:55:20 +02:00
parent 00573c2763
commit 232305a871

View File

@ -35,7 +35,7 @@ public class GatesManager
}
public Set<Gate> getGatesInsideChunk(Chunk chunk)
public Set<Gate> getNearbyGates(Chunk chunk)
{
SimpleChunk simpleChunk = new SimpleChunk(chunk);
return gatesByChunk.get(simpleChunk);
@ -111,7 +111,10 @@ public class GatesManager
HashSet<Chunk> chunksUsedByGates = new HashSet<Chunk>();
for (Gate g : gates) {
if (g.getLocation() != null) {
chunksUsedByGates.add(g.getLocation().getChunk());
}
}
gatesByChunk = new HashMap<SimpleChunk, Set<Gate>>((int)(chunksUsedByGates.size() * 1.25));
@ -170,15 +173,20 @@ public class GatesManager
private void removeGateFromChunk(Gate g, Location l)
{
if (l != null) {
SimpleChunk sc = new SimpleChunk(l.getChunk());
Set<Gate> gatesInChunk = gatesByChunk.get(sc);
gatesInChunk.remove(g);
}
}
private void addGateByChunk(Gate g)
{
SimpleChunk c = new SimpleChunk(g.getLocation().getChunk());
Location gateLocation = g.getLocation();
if (gateLocation != null) {
SimpleChunk c = new SimpleChunk(gateLocation.getChunk());
Set<Gate> gatesForC = gatesByChunk.get(c);
if (gatesForC == null) {
@ -188,6 +196,7 @@ public class GatesManager
gatesForC.add(g);
}
}
public void storeInvalidGate(Map<String, Object> map)