diff options
author | makamys <makamys@outlook.com> | 2022-06-10 19:15:04 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-10 19:20:55 +0200 |
commit | bed1d48eff24795c52465d10c81ace37823e2d16 (patch) | |
tree | c9a31990ace46c5cf9e2334586e4bd2b49ba23d4 /src/main/java | |
parent | 1ba50cbfb724560d58f2056f7f0123bfef2f4371 (diff) | |
download | Neodymium-bed1d48eff24795c52465d10c81ace37823e2d16.tar.gz Neodymium-bed1d48eff24795c52465d10c81ace37823e2d16.tar.bz2 Neodymium-bed1d48eff24795c52465d10c81ace37823e2d16.zip |
Fix hotswap weirdness
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/makamys/neodymium/Config.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/makamys/neodymium/Config.java b/src/main/java/makamys/neodymium/Config.java index 65c9274..3dc2f09 100644 --- a/src/main/java/makamys/neodymium/Config.java +++ b/src/main/java/makamys/neodymium/Config.java @@ -10,6 +10,7 @@ import static makamys.neodymium.Neodymium.MODID; import java.io.File; import java.io.IOException; import java.nio.file.FileSystems; +import java.nio.file.Files; import java.nio.file.WatchEvent; import java.nio.file.WatchKey; import java.nio.file.WatchService; @@ -53,6 +54,16 @@ public class Config { private static WatchService watcher; public static void reloadConfig() { + try { + if(Files.size(configFile.toPath()) == 0) { + // Sometimes the watcher fires twice, and the first time the file is empty. + // I don't know why. This is the workaround. + return; + } + } catch (IOException e) { + e.printStackTrace(); + } + Configuration config = new Configuration(configFile); config.load(); |