From 776e4ef3c9d3d87c6d2b770bc97cb78c803c3ab6 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Sat, 9 Feb 2013 16:27:03 +0100 Subject: [PATCH] Fixed bug where gates with no exit did cause an exception. --- src/de/craftinc/gates/Gate.java | 8 ++++---- src/de/craftinc/gates/util/LocationSerializer.java | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/de/craftinc/gates/Gate.java b/src/de/craftinc/gates/Gate.java index be1157d..97d41c2 100644 --- a/src/de/craftinc/gates/Gate.java +++ b/src/de/craftinc/gates/Gate.java @@ -72,11 +72,11 @@ public class Gate extends BaseGate implements ConfigurationSerializable @SuppressWarnings("unchecked") public Gate(Map map) { - id = (String)map.get(idKey); - isHidden = (Boolean)map.get(isHiddenKey); - isOpen = (Boolean)map.get(isOpenKey); - try { + id = map.get(idKey).toString(); + isHidden = (Boolean)map.get(isHiddenKey); + isOpen = (Boolean)map.get(isOpenKey); + location = LocationSerializer.deserializeLocation((Map) map.get(locationKey)); exit = LocationSerializer.deserializeLocation((Map) map.get(exitKey)); diff --git a/src/de/craftinc/gates/util/LocationSerializer.java b/src/de/craftinc/gates/util/LocationSerializer.java index 36ba1a2..e295484 100644 --- a/src/de/craftinc/gates/util/LocationSerializer.java +++ b/src/de/craftinc/gates/util/LocationSerializer.java @@ -34,6 +34,10 @@ public class LocationSerializer public static Map serializeLocation(Location l) { + if (l == null) { + return null; + } + Map serializedLocation = new HashMap(); serializedLocation.put(worldKey, l.getWorld().getName()); @@ -47,6 +51,10 @@ public class LocationSerializer public static Location deserializeLocation(Map map) throws Exception { + if (map == null) { + return null; + } + World w = getWorld((String)map.get(worldKey));