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,13 +32,11 @@ public class UConfig {
|
|||
File file = new File(directory, "unicopia.json");
|
||||
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
|
||||
if (file.exists()) {
|
||||
try(JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(file)));) {
|
||||
instance = gson.fromJson(reader, UConfig.class);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
@ -48,7 +46,7 @@ public class UConfig {
|
|||
}
|
||||
|
||||
instance.file = file;
|
||||
|
||||
instance.save();
|
||||
}
|
||||
|
||||
private File file;
|
||||
|
@ -66,6 +64,8 @@ public class UConfig {
|
|||
}
|
||||
|
||||
try (JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(file)))) {
|
||||
writer.setIndent(" ");
|
||||
|
||||
gson.toJson(this, UConfig.class, writer);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Reference in a new issue