From b50a2b27d3039f48497c41118256f506b69f70ea Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Sun, 23 Jun 2013 17:09:39 +0200 Subject: [PATCH] Bugfix: do not let the location command fail if previous location was invalid. --- src/de/craftinc/gates/commands/CommandLocation.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/de/craftinc/gates/commands/CommandLocation.java b/src/de/craftinc/gates/commands/CommandLocation.java index d5fa315..887d763 100644 --- a/src/de/craftinc/gates/commands/CommandLocation.java +++ b/src/de/craftinc/gates/commands/CommandLocation.java @@ -60,11 +60,22 @@ public class CommandLocation extends BaseLocationCommand try { - Location oldLocation = gate.getLocation(); + boolean gateOpen = gate.isOpen(); + + if (gateOpen) { + gate.setOpen(false); + } + + Location oldLocation = gate.getLocation(); Set oldGateBlockLocations = gate.getGateBlockLocations(); Set oldFrameBlocks = gate.getGateFrameBlocks(); gate.setLocation(playerLocation); + + if (gateOpen) { + gate.setOpen(true); + } + Plugin.getPlugin().getGatesManager().handleGateLocationChange(gate, oldLocation, oldGateBlockLocations, oldFrameBlocks); sendMessage(ChatColor.GREEN + "The location of '" + gate.getId() + "' is now at your current location.");