add nullcheck for claimblocks reading (e.g. caused by editing offline data) fix #226

This commit is contained in:
Flemmli97 2023-03-10 23:13:07 +01:00
parent 17ee9d2355
commit 1d071b1a39
1 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package io.github.flemmli97.flan.player;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
@ -449,7 +450,9 @@ public class PlayerClaimData implements IPlayerData {
JsonObject obj = ConfigHandler.GSON.fromJson(reader, JsonObject.class);
reader.close();
Flan.debug("Read following json data {} from file {}", obj, file.getFileName());
this.claimBlocks = obj.get("ClaimBlocks").getAsInt();
JsonElement claimBlockEl = obj.get("ClaimBlocks");
if (claimBlockEl.isJsonPrimitive())
this.claimBlocks = claimBlockEl.getAsInt();
this.additionalClaimBlocks = obj.get("AdditionalBlocks").getAsInt();
JsonObject defP = ConfigHandler.fromJson(obj, "DefaultGroups");
defP.entrySet().forEach(e -> {