From bed1d48eff24795c52465d10c81ace37823e2d16 Mon Sep 17 00:00:00 2001 From: makamys Date: Fri, 10 Jun 2022 19:15:04 +0200 Subject: Fix hotswap weirdness --- src/main/java/makamys/neodymium/Config.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/main/java') 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(); -- cgit