attempt to handle an NPE someone has been getting in MyLocationTypeAdapter.serialize()
This commit is contained in:
parent
62ecceca5f
commit
ebde7bcc1a
@ -332,7 +332,11 @@ public class Faction {
|
||||
try {
|
||||
DiscUtil.write(file, Factions.gson.toJson(instances));
|
||||
} catch (IOException e) {
|
||||
Factions.log("Failed to save the factions to disk.");
|
||||
Factions.log("Failed to save the factions to disk due to I/O exception.");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} catch (NullPointerException e) {
|
||||
Factions.log("Failed to save the factions to disk due to NPE.");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
@ -38,7 +38,18 @@ public class MyLocationTypeAdapter implements JsonDeserializer<Location>, JsonSe
|
||||
@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;
|
||||
}
|
||||
|
||||
obj.addProperty(WORLD, src.getWorld().getName());
|
||||
obj.addProperty(X, src.getX());
|
||||
obj.addProperty(Y, src.getY());
|
||||
|
Loading…
Reference in New Issue
Block a user