Added some checks for null values to the GatesManager class.
This commit is contained in:
parent
00573c2763
commit
232305a871
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user