diff --git a/src/main/java/world/bentobox/bentobox/database/json/adapters/ProfessionTypeAdapter.java b/src/main/java/world/bentobox/bentobox/database/json/adapters/ProfessionTypeAdapter.java index bd40494ec..e083e3ece 100644 --- a/src/main/java/world/bentobox/bentobox/database/json/adapters/ProfessionTypeAdapter.java +++ b/src/main/java/world/bentobox/bentobox/database/json/adapters/ProfessionTypeAdapter.java @@ -12,8 +12,12 @@ import com.google.gson.stream.JsonWriter; public class ProfessionTypeAdapter extends TypeAdapter { @Override - public void write(JsonWriter out, Profession profession) throws IOException { - out.value(profession.name()); + public void write(JsonWriter out, Profession profession) throws IOException { + if (profession != null) { + out.value(profession.name()); + return; + } + out.nullValue(); } @Override diff --git a/src/main/java/world/bentobox/bentobox/database/json/adapters/VillagerTypeAdapter.java b/src/main/java/world/bentobox/bentobox/database/json/adapters/VillagerTypeAdapter.java index 050142ad6..9752f17a6 100644 --- a/src/main/java/world/bentobox/bentobox/database/json/adapters/VillagerTypeAdapter.java +++ b/src/main/java/world/bentobox/bentobox/database/json/adapters/VillagerTypeAdapter.java @@ -12,7 +12,11 @@ import com.google.gson.stream.JsonWriter; public class VillagerTypeAdapter extends TypeAdapter { @Override - public void write(JsonWriter out, Villager.Type type) throws IOException { + public void write(JsonWriter out, Villager.Type type) throws IOException { + if (type == null) { + out.nullValue(); + return; + } out.value(type.name()); }