From f4495240a5182d494e72f707002e367c620ddc96 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Sun, 23 Jun 2013 18:43:22 +0200 Subject: [PATCH] Remove and add gates to the gate attributes. --- src/de/craftinc/gates/GatesManager.java | 30 ++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/de/craftinc/gates/GatesManager.java b/src/de/craftinc/gates/GatesManager.java index d5bc73a..87d6dbc 100644 --- a/src/de/craftinc/gates/GatesManager.java +++ b/src/de/craftinc/gates/GatesManager.java @@ -88,7 +88,7 @@ public class GatesManager return; } - gatesConfig.set(gatesPath, new ArrayList(gatesById.values())); + gatesConfig.set(gatesPath, gates); gatesConfig.set(storageVersionPath, storageVersion); try { @@ -288,18 +288,24 @@ public class GatesManager protected void removeGateByLocation(final Set gateBlocks) { - for (Location l : gateBlocks) { - SimpleLocation sl = new SimpleLocation(l); - gatesByLocation.remove(sl); - } + if (gateBlocks != null) { + + for (Location l : gateBlocks) { + SimpleLocation sl = new SimpleLocation(l); + gatesByLocation.remove(sl); + } + } } protected void removeGateByFrameLocation(final Set gateFrameBlocks) { - for (Block block : gateFrameBlocks) { - SimpleLocation sl = new SimpleLocation(block.getLocation()); - gatesByFrameLocation.remove(sl); + if (gateFrameBlocks != null) { + + 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) { - this.addGateByChunk(g); + this.gates.add(g); + + this.addGateByChunk(g); this.addGateByLocations(g); this.addGateWithId(g); this.addGateByFrameLocations(g); @@ -469,7 +477,9 @@ public class GatesManager public void handleDeletion(final Gate g) { - this.removeGateById(g.getId()); + this.gates.remove(g); + + this.removeGateById(g.getId()); this.removeGateFromChunk(g, g.getLocation()); this.removeGateByLocation(g.getGateBlockLocations()); this.removeGateByFrameLocation(g.getGateFrameBlocks());