Bugfix: do not let the location command fail if previous location was invalid.

This commit is contained in:
Tobias Ottenweller 2013-06-23 17:09:39 +02:00
parent e88e03ed42
commit b50a2b27d3

View File

@ -60,11 +60,22 @@ public class CommandLocation extends BaseLocationCommand
try try
{ {
Location oldLocation = gate.getLocation(); boolean gateOpen = gate.isOpen();
if (gateOpen) {
gate.setOpen(false);
}
Location oldLocation = gate.getLocation();
Set<Location> oldGateBlockLocations = gate.getGateBlockLocations(); Set<Location> oldGateBlockLocations = gate.getGateBlockLocations();
Set<Block> oldFrameBlocks = gate.getGateFrameBlocks(); Set<Block> oldFrameBlocks = gate.getGateFrameBlocks();
gate.setLocation(playerLocation); gate.setLocation(playerLocation);
if (gateOpen) {
gate.setOpen(true);
}
Plugin.getPlugin().getGatesManager().handleGateLocationChange(gate, oldLocation, oldGateBlockLocations, oldFrameBlocks); Plugin.getPlugin().getGatesManager().handleGateLocationChange(gate, oldLocation, oldGateBlockLocations, oldFrameBlocks);
sendMessage(ChatColor.GREEN + "The location of '" + gate.getId() + "' is now at your current location."); sendMessage(ChatColor.GREEN + "The location of '" + gate.getId() + "' is now at your current location.");