diff options
author | hackthetime <l4bg0jb7@duck.com> | 2023-10-26 09:39:51 +0200 |
---|---|---|
committer | hackthetime <l4bg0jb7@duck.com> | 2023-10-26 09:39:51 +0200 |
commit | 66df32ba781f84630b70b4d9004c408d1d3417bf (patch) | |
tree | 6d1546abacf82b51fcc0412050d20d2f2a206176 /fabric/src | |
parent | 00efc92b88ea889dba589d683835dbbc8723b31e (diff) | |
download | BBsentials-66df32ba781f84630b70b4d9004c408d1d3417bf.tar.gz BBsentials-66df32ba781f84630b70b4d9004c408d1d3417bf.tar.bz2 BBsentials-66df32ba781f84630b70b4d9004c408d1d3417bf.zip |
numpad no config fix.
Diffstat (limited to 'fabric/src')
-rw-r--r-- | fabric/src/main/java/de/hype/bbsentials/fabric/numpad/NumPadCodes.java | 21 |
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(); + } } } - - } |