aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhackthetime <l4bg0jb7@duck.com>2023-10-26 09:39:51 +0200
committerhackthetime <l4bg0jb7@duck.com>2023-10-26 09:39:51 +0200
commit66df32ba781f84630b70b4d9004c408d1d3417bf (patch)
tree6d1546abacf82b51fcc0412050d20d2f2a206176
parent00efc92b88ea889dba589d683835dbbc8723b31e (diff)
downloadBBsentials-66df32ba781f84630b70b4d9004c408d1d3417bf.tar.gz
BBsentials-66df32ba781f84630b70b4d9004c408d1d3417bf.tar.bz2
BBsentials-66df32ba781f84630b70b4d9004c408d1d3417bf.zip
numpad no config fix.
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/numpad/NumPadCodes.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/numpad/NumPadCodes.java b/fabric/src/main/java/de/hype/bbsentials/fabric/numpad/NumPadCodes.java
index d3b3c1e..441c563 100644
--- a/fabric/src/main/java/de/hype/bbsentials/fabric/numpad/NumPadCodes.java
+++ b/fabric/src/main/java/de/hype/bbsentials/fabric/numpad/NumPadCodes.java
@@ -187,8 +187,7 @@ public class NumPadCodes {
toSaveCodes.add(numCode);
}
}
- try (Writer writer = new FileWriter(new File(EnvironmentCore.mcUtils.getConfigPath(), "BBsentials_Numpad_codes.json")
- )) {
+ try (Writer writer = new FileWriter(new File(EnvironmentCore.mcUtils.getConfigPath(), "BBsentials_Numpad_codes.json"))) {
gson.toJson(toSaveCodes, writer);
} catch (IOException e) {
e.printStackTrace();
@@ -197,14 +196,24 @@ public class NumPadCodes {
public void loadNumCodesFromFile() {
- try (Reader reader = new FileReader(new File(EnvironmentCore.mcUtils.getConfigPath(), "BBsentials_Numpad_codes.json"))) {
+ File file = new File(EnvironmentCore.mcUtils.getConfigPath(), "BBsentials_Numpad_codes.json");
+ try (Reader reader = new FileReader(file)) {
Type listType = new TypeToken<List<NumCode>>() {
}.getType();
numCodes = gson.fromJson(reader, listType);
} catch (IOException e) {
- e.printStackTrace();
+ if (!file.exists()) {
+ try {
+ file.createNewFile();
+ loadNumCodesFromFile();
+ } catch (IOException ex) {
+ System.out.println("Couldnt create new file");
+ e.printStackTrace();
+ }
+ }
+ else {
+ e.printStackTrace();
+ }
}
}
-
-
}