mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 06:26:43 +01:00
Fixed config saving
This commit is contained in:
parent
4b9d349639
commit
84f5b9d347
1 changed files with 7 additions and 7 deletions
|
@ -32,12 +32,10 @@ public class UConfig {
|
||||||
File file = new File(directory, "unicopia.json");
|
File file = new File(directory, "unicopia.json");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!file.exists()) {
|
if (file.exists()) {
|
||||||
file.createNewFile();
|
try(JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(file)));) {
|
||||||
}
|
instance = gson.fromJson(reader, UConfig.class);
|
||||||
|
}
|
||||||
try(JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(file)));) {
|
|
||||||
instance = gson.fromJson(reader, UConfig.class);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -48,7 +46,7 @@ public class UConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.file = file;
|
instance.file = file;
|
||||||
|
instance.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private File file;
|
private File file;
|
||||||
|
@ -66,6 +64,8 @@ public class UConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
try (JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(file)))) {
|
try (JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(file)))) {
|
||||||
|
writer.setIndent(" ");
|
||||||
|
|
||||||
gson.toJson(this, UConfig.class, writer);
|
gson.toJson(this, UConfig.class, writer);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in a new issue