Remove and add gates to the gate attributes.

This commit is contained in:
Tobias Ottenweller 2013-06-23 18:43:22 +02:00
parent 09b9c65ef6
commit f4495240a5

View File

@ -88,7 +88,7 @@ public class GatesManager
return; return;
} }
gatesConfig.set(gatesPath, new ArrayList<Object>(gatesById.values())); gatesConfig.set(gatesPath, gates);
gatesConfig.set(storageVersionPath, storageVersion); gatesConfig.set(storageVersionPath, storageVersion);
try { try {
@ -288,18 +288,24 @@ public class GatesManager
protected void removeGateByLocation(final Set<Location> gateBlocks) protected void removeGateByLocation(final Set<Location> gateBlocks)
{ {
for (Location l : gateBlocks) { if (gateBlocks != null) {
SimpleLocation sl = new SimpleLocation(l);
gatesByLocation.remove(sl); for (Location l : gateBlocks) {
} SimpleLocation sl = new SimpleLocation(l);
gatesByLocation.remove(sl);
}
}
} }
protected void removeGateByFrameLocation(final Set<Block> gateFrameBlocks) protected void removeGateByFrameLocation(final Set<Block> gateFrameBlocks)
{ {
for (Block block : gateFrameBlocks) { if (gateFrameBlocks != null) {
SimpleLocation sl = new SimpleLocation(block.getLocation());
gatesByFrameLocation.remove(sl); for (Block block : gateFrameBlocks) {
SimpleLocation sl = new SimpleLocation(block.getLocation());
gatesByFrameLocation.remove(sl);
}
} }
} }
@ -460,7 +466,9 @@ public class GatesManager
public void handleNewGate(final Gate g) public void handleNewGate(final Gate g)
{ {
this.addGateByChunk(g); this.gates.add(g);
this.addGateByChunk(g);
this.addGateByLocations(g); this.addGateByLocations(g);
this.addGateWithId(g); this.addGateWithId(g);
this.addGateByFrameLocations(g); this.addGateByFrameLocations(g);
@ -469,7 +477,9 @@ public class GatesManager
public void handleDeletion(final Gate g) public void handleDeletion(final Gate g)
{ {
this.removeGateById(g.getId()); this.gates.remove(g);
this.removeGateById(g.getId());
this.removeGateFromChunk(g, g.getLocation()); this.removeGateFromChunk(g, g.getLocation());
this.removeGateByLocation(g.getGateBlockLocations()); this.removeGateByLocation(g.getGateBlockLocations());
this.removeGateByFrameLocation(g.getGateFrameBlocks()); this.removeGateByFrameLocation(g.getGateFrameBlocks());