Fixed bug where gates with no exit did cause an exception.

This commit is contained in:
Tobias Ottenweller 2013-02-09 16:27:03 +01:00
parent a677995968
commit 776e4ef3c9
2 changed files with 12 additions and 4 deletions

View File

@ -72,11 +72,11 @@ public class Gate extends BaseGate implements ConfigurationSerializable
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Gate(Map<String, Object> map) public Gate(Map<String, Object> map)
{ {
id = (String)map.get(idKey); try {
id = map.get(idKey).toString();
isHidden = (Boolean)map.get(isHiddenKey); isHidden = (Boolean)map.get(isHiddenKey);
isOpen = (Boolean)map.get(isOpenKey); isOpen = (Boolean)map.get(isOpenKey);
try {
location = LocationSerializer.deserializeLocation((Map<String, Object>) map.get(locationKey)); location = LocationSerializer.deserializeLocation((Map<String, Object>) map.get(locationKey));
exit = LocationSerializer.deserializeLocation((Map<String, Object>) map.get(exitKey)); exit = LocationSerializer.deserializeLocation((Map<String, Object>) map.get(exitKey));

View File

@ -34,6 +34,10 @@ public class LocationSerializer
public static Map<String, Object> serializeLocation(Location l) public static Map<String, Object> serializeLocation(Location l)
{ {
if (l == null) {
return null;
}
Map<String, Object> serializedLocation = new HashMap<String, Object>(); Map<String, Object> serializedLocation = new HashMap<String, Object>();
serializedLocation.put(worldKey, l.getWorld().getName()); serializedLocation.put(worldKey, l.getWorld().getName());
@ -47,6 +51,10 @@ public class LocationSerializer
public static Location deserializeLocation(Map<String, Object> map) throws Exception public static Location deserializeLocation(Map<String, Object> map) throws Exception
{ {
if (map == null) {
return null;
}
World w = getWorld((String)map.get(worldKey)); World w = getWorld((String)map.get(worldKey));