Skip to content

Commit

Permalink
chore: Add formatVersion to config
Browse files Browse the repository at this point in the history
Preparing for format v2.0
  • Loading branch information
null2264 committed Dec 8, 2023
1 parent 5022090 commit a1d73bd
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import blue.endless.jankson.annotation.Serializer;
import io.github.null2264.cobblegen.data.CGIdentifier;
import io.github.null2264.cobblegen.data.JanksonSerializable;
import lombok.val;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
Expand All @@ -15,6 +16,9 @@

public class ConfigData implements Config, JanksonSerializable
{
@Comment(value = "CobbleGen Format Version, you can leave this alone for now. v2.0 will be released in CobbleGen v6.0")
public String formatVersion = "1.0";

@Nullable
@Comment(value = """
Default Generators
Expand Down Expand Up @@ -120,6 +124,7 @@ public static ConfigData defaultConfig() {
@Serializer
public JsonObject toJson() {
JsonObject json = new JsonObject();
json.put("formatVersion", JsonPrimitive.of(formatVersion));
json.put("cobbleGen", JANKSON.toJson(cobbleGen));
json.put("stoneGen", JANKSON.toJson(stoneGen));
json.put("basaltGen", JANKSON.toJson(basaltGen));
Expand All @@ -139,6 +144,8 @@ public JsonObject toJson() {
@Deserializer
public static ConfigData fromJson(JsonObject json) {
ConfigData config = new ConfigData();
val formatVersion = json.get("formatVersion");
config.formatVersion = (formatVersion instanceof JsonPrimitive) ? ((JsonPrimitive) formatVersion).asString() : "1.0";
config.cobbleGen = JANKSON.fromJson(json.getObject("cobbleGen"), List.class);
config.stoneGen = JANKSON.fromJson(json.getObject("stoneGen"), List.class);
config.basaltGen = JANKSON.fromJson(json.getObject("basaltGen"), List.class);
Expand Down

0 comments on commit a1d73bd

Please sign in to comment.