Skip to content

Commit

Permalink
Final preparations for 1.19.3 port
Browse files Browse the repository at this point in the history
  • Loading branch information
EnnuiL committed Jan 1, 2023
1 parent 7284099 commit 57eba5d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2022 Ennui Langeweile
Copyright (c) 2021-2023 Ennui Langeweile

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,37 +54,37 @@ public String getFileExtension() {
}

private void serialize(JsonWriter writer, Object value) throws IOException {
if (value instanceof Integer) {
writer.value((Integer) value);
} else if (value instanceof Long) {
writer.value((Long) value);
} else if (value instanceof Float) {
writer.value((Float) value);
} else if (value instanceof Double) {
writer.value((Double) value);
} else if (value instanceof Boolean) {
writer.value((Boolean) value);
} else if (value instanceof String) {
writer.value((String) value);
} else if (value instanceof ValueList<?>) {
if (value instanceof Integer intValue) {
writer.value(intValue);
} else if (value instanceof Long longValue) {
writer.value(longValue);
} else if (value instanceof Float floatValue) {
writer.value(floatValue);
} else if (value instanceof Double doubleValue) {
writer.value(doubleValue);
} else if (value instanceof Boolean booleanValue) {
writer.value(booleanValue);
} else if (value instanceof String stringValue) {
writer.value(stringValue);
} else if (value instanceof ValueList<?> valueList) {
writer.beginArray();

for (Object v : (ValueList<?>) value) {
for (var v : valueList) {
serialize(writer, v);
}

writer.endArray();
} else if (value instanceof ValueMap<?>) {
} else if (value instanceof ValueMap<?> valueMap) {
writer.beginObject();

for (Map.Entry<String, ?> entry : (ValueMap<?>) value) {
for (var entry : valueMap) {
writer.name(entry.getKey());
serialize(writer, entry.getValue());
}

writer.endObject();
} else if (value instanceof ConfigSerializableObject) {
serialize(writer, ((ConfigSerializableObject<?>) value).getRepresentation());
} else if (value instanceof ConfigSerializableObject<?> serializableObject) {
serialize(writer, serializableObject.getRepresentation());
} else if (value == null) {
writer.nullValue();
} else if (value.getClass().isEnum()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ModConfig extends WrappedConfig {
public final ValueMap<Object> default_game_rules = ValueMap.builder((Object) "").build();
public final boolean generate_json_schema = true;

// TODO - JSON support, with JSON5 being opt-in
// TODO - Opt-in JSON5/JSONC support
public void setSerializer(Config.Builder builder) {
builder.format("json");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class ModConfigManager {
public static final String GENERATE_ME = "GENERATE_ME";
public static final Path SCHEMA_DIRECTORY_PATH = QuiltLoader.getConfigDir().resolve("boring_default_game_rules");
public static final Path SCHEMA_PATH = SCHEMA_DIRECTORY_PATH.resolve("config.schema.json");
public static final Path CONFIG_PATH = QuiltLoader.getConfigDir().resolve("boringdefaultgamerules.json");
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();

public static final ModConfig CONFIG = QuiltConfig.create("boring_default_game_rules", "config", ModConfig.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
@Mixin(EditGameRulesScreen.class)
public interface EditGameRulesScreenAccessor {
@Accessor
public EditGameRulesScreen.RuleListWidget getRuleListWidget();
EditGameRulesScreen.RuleListWidget getRuleListWidget();

@Accessor
public void setGameRules(GameRules gameRules);
void setGameRules(GameRules gameRules);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 57eba5d

Please sign in to comment.