diff --git a/releases/factions 1.1.5b.zip b/releases/factions 1.1.5b.zip new file mode 100644 index 00000000..75a2f47a Binary files /dev/null and b/releases/factions 1.1.5b.zip differ diff --git a/src/com/bukkit/mcteam/factions/MyLocationTypeAdapter.java b/src/com/bukkit/mcteam/factions/MyLocationTypeAdapter.java index 6248039b..d3b40ba3 100644 --- a/src/com/bukkit/mcteam/factions/MyLocationTypeAdapter.java +++ b/src/com/bukkit/mcteam/factions/MyLocationTypeAdapter.java @@ -1,6 +1,7 @@ package com.bukkit.mcteam.factions; import java.lang.reflect.Type; +import java.util.logging.Level; import org.bukkit.Location; import org.bukkit.World; @@ -23,43 +24,52 @@ public class MyLocationTypeAdapter implements JsonDeserializer, JsonSe @Override public Location deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - JsonObject obj = json.getAsJsonObject(); + try { + JsonObject obj = json.getAsJsonObject(); - if (obj.isJsonNull() || obj.get(WORLD).isJsonNull()) + World world = Factions.instance.getServer().getWorld(obj.get(WORLD).getAsString()); + double x = obj.get(X).getAsDouble(); + double y = obj.get(Y).getAsDouble(); + double z = obj.get(Z).getAsDouble(); + float yaw = obj.get(YAW).getAsFloat(); + float pitch = obj.get(PITCH).getAsFloat(); + + return new Location(world, x, y, z, yaw, pitch); + + } catch (NullPointerException ex) { + Factions.log(Level.SEVERE, "NPE encountered while deserializing a location"); return null; - - World world = Factions.instance.getServer().getWorld(obj.get(WORLD).getAsString()); - double x = obj.get(X).getAsDouble(); - double y = obj.get(Y).getAsDouble(); - double z = obj.get(Z).getAsDouble(); - float yaw = obj.get(YAW).getAsFloat(); - float pitch = obj.get(PITCH).getAsFloat(); - - return new Location(world, x, y, z, yaw, pitch); + } } @Override public JsonElement serialize(Location src, Type typeOfSrc, JsonSerializationContext context) { JsonObject obj = new JsonObject(); - if (src == null) - { - Factions.log("Passed location is null in MyLocationTypeAdapter."); - return obj; - } - else if (src.getWorld() == null) - { - Factions.log("Passed location's world is null in MyLocationTypeAdapter."); - return obj; - } + try { + if (src == null) + { + Factions.log("Passed location is null in MyLocationTypeAdapter."); + return obj; + } + else if (src.getWorld() == null) + { + Factions.log("Passed location's world is null in MyLocationTypeAdapter."); + return obj; + } - obj.addProperty(WORLD, src.getWorld().getName()); - obj.addProperty(X, src.getX()); - obj.addProperty(Y, src.getY()); - obj.addProperty(Z, src.getZ()); - obj.addProperty(YAW, src.getYaw()); - obj.addProperty(PITCH, src.getPitch()); - - return obj; + obj.addProperty(WORLD, src.getWorld().getName()); + obj.addProperty(X, src.getX()); + obj.addProperty(Y, src.getY()); + obj.addProperty(Z, src.getZ()); + obj.addProperty(YAW, src.getYaw()); + obj.addProperty(PITCH, src.getPitch()); + + return obj; + + } catch (NullPointerException ex) { + Factions.log(Level.SEVERE, "NPE encountered while serializing a location"); + return obj; + } } }