Fixing json nulls

This commit is contained in:
samo_lego 2020-07-29 14:47:12 +02:00
parent 8a51f271ad
commit 32de5d188f
1 changed files with 4 additions and 4 deletions

View File

@ -76,10 +76,10 @@ public class PlayerCache {
if (lastLoc != null) {
// Getting DB coords
JsonObject lastLocation = gson.fromJson(lastLoc.getAsString(), JsonObject.class);
this.lastDim = lastLocation.get("dim").getAsString();
this.lastX = lastLocation.get("x").getAsDouble();
this.lastY = lastLocation.get("y").getAsDouble();
this.lastZ = lastLocation.get("z").getAsDouble();
this.lastDim = lastLocation.get("dim").isJsonNull() ? config.worldSpawn.dimension : lastLocation.get("dim").getAsString();
this.lastX = lastLocation.get("x").isJsonNull() ? config.worldSpawn.x : lastLocation.get("x").getAsDouble();
this.lastY = lastLocation.get("y").isJsonNull() ? config.worldSpawn.y : lastLocation.get("y").getAsDouble();
this.lastZ = lastLocation.get("z").isJsonNull() ? config.worldSpawn.z : lastLocation.get("z").getAsDouble();
// Removing location data from DB
json.remove("lastLocation");