mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-22 10:35:16 +01:00
Pretty-print main settings file, to make manual editing easier
This commit is contained in:
parent
ae992419bb
commit
330f2cdbe2
@ -24,6 +24,7 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.common;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import de.bluecolored.bluemap.common.config.WebappConfig;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.resources.adapter.ResourcesGson;
|
||||
@ -65,7 +66,10 @@ public void saveSettings() throws IOException {
|
||||
Files.createDirectories(getSettingsFile().getParent());
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(getSettingsFile(),
|
||||
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
|
||||
ResourcesGson.INSTANCE.toJson(this.settings, writer);
|
||||
ResourcesGson.addAdapter(new GsonBuilder())
|
||||
.setPrettyPrinting() // enable pretty printing for easy editing
|
||||
.create()
|
||||
.toJson(this.settings, writer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,12 +17,12 @@
|
||||
|
||||
public class ResourcesGson {
|
||||
|
||||
public static final Gson INSTANCE = createGson();
|
||||
public static final Gson INSTANCE = addAdapter(new GsonBuilder())
|
||||
.setLenient()
|
||||
.create();
|
||||
|
||||
private static Gson createGson() {
|
||||
|
||||
return new GsonBuilder()
|
||||
.setLenient()
|
||||
public static GsonBuilder addAdapter(GsonBuilder builder) {
|
||||
return builder
|
||||
.registerTypeAdapter(Axis.class, new AxisAdapter())
|
||||
.registerTypeAdapter(Color.class, new ColorAdapter())
|
||||
.registerTypeAdapter(Direction.class, new DirectionAdapter())
|
||||
@ -35,9 +35,7 @@ private static Gson createGson() {
|
||||
.registerTypeAdapter(
|
||||
new TypeToken<EnumMap<Direction, Face>>(){}.getType(),
|
||||
new EnumMapInstanceCreator<Direction, Face>(Direction.class)
|
||||
)
|
||||
.create();
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
public static String nextStringOrBoolean(JsonReader in) throws IOException {
|
||||
|
Loading…
Reference in New Issue
Block a user