mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-25 12:05:13 +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;
|
package de.bluecolored.bluemap.common;
|
||||||
|
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
import de.bluecolored.bluemap.common.config.WebappConfig;
|
import de.bluecolored.bluemap.common.config.WebappConfig;
|
||||||
import de.bluecolored.bluemap.core.logger.Logger;
|
import de.bluecolored.bluemap.core.logger.Logger;
|
||||||
import de.bluecolored.bluemap.core.resources.adapter.ResourcesGson;
|
import de.bluecolored.bluemap.core.resources.adapter.ResourcesGson;
|
||||||
@ -65,7 +66,10 @@ public void saveSettings() throws IOException {
|
|||||||
Files.createDirectories(getSettingsFile().getParent());
|
Files.createDirectories(getSettingsFile().getParent());
|
||||||
try (BufferedWriter writer = Files.newBufferedWriter(getSettingsFile(),
|
try (BufferedWriter writer = Files.newBufferedWriter(getSettingsFile(),
|
||||||
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
|
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 class ResourcesGson {
|
||||||
|
|
||||||
public static final Gson INSTANCE = createGson();
|
public static final Gson INSTANCE = addAdapter(new GsonBuilder())
|
||||||
|
.setLenient()
|
||||||
|
.create();
|
||||||
|
|
||||||
private static Gson createGson() {
|
public static GsonBuilder addAdapter(GsonBuilder builder) {
|
||||||
|
return builder
|
||||||
return new GsonBuilder()
|
|
||||||
.setLenient()
|
|
||||||
.registerTypeAdapter(Axis.class, new AxisAdapter())
|
.registerTypeAdapter(Axis.class, new AxisAdapter())
|
||||||
.registerTypeAdapter(Color.class, new ColorAdapter())
|
.registerTypeAdapter(Color.class, new ColorAdapter())
|
||||||
.registerTypeAdapter(Direction.class, new DirectionAdapter())
|
.registerTypeAdapter(Direction.class, new DirectionAdapter())
|
||||||
@ -35,9 +35,7 @@ private static Gson createGson() {
|
|||||||
.registerTypeAdapter(
|
.registerTypeAdapter(
|
||||||
new TypeToken<EnumMap<Direction, Face>>(){}.getType(),
|
new TypeToken<EnumMap<Direction, Face>>(){}.getType(),
|
||||||
new EnumMapInstanceCreator<Direction, Face>(Direction.class)
|
new EnumMapInstanceCreator<Direction, Face>(Direction.class)
|
||||||
)
|
);
|
||||||
.create();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String nextStringOrBoolean(JsonReader in) throws IOException {
|
public static String nextStringOrBoolean(JsonReader in) throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user