parent
721645f88f
commit
a51b1563b1
|
|
@ -27,7 +27,7 @@ public class ModernFixClient {
|
||||||
|
|
||||||
public static float gameStartTimeSeconds = -1;
|
public static float gameStartTimeSeconds = -1;
|
||||||
|
|
||||||
private static boolean recipesUpdated, tagsUpdated = false;
|
public static boolean recipesUpdated, tagsUpdated = false;
|
||||||
|
|
||||||
public String brandingString = null;
|
public String brandingString = null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import net.minecraft.network.chat.TranslatableComponent;
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
import org.embeddedt.modernfix.ModernFix;
|
import org.embeddedt.modernfix.ModernFix;
|
||||||
|
import org.embeddedt.modernfix.ModernFixClient;
|
||||||
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
|
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
|
||||||
import org.embeddedt.modernfix.util.CommonModUtil;
|
import org.embeddedt.modernfix.util.CommonModUtil;
|
||||||
|
|
||||||
|
|
@ -16,11 +17,11 @@ import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class NightConfigFixer {
|
public class NightConfigFixer {
|
||||||
public static final LinkedHashSet<Runnable> configsToReload = new LinkedHashSet<>();
|
public static final LinkedHashSet<Runnable> configsToReload = new LinkedHashSet<>();
|
||||||
|
|
||||||
public static void monitorFileWatcher() {
|
public static void monitorFileWatcher() {
|
||||||
if(!ModernFixMixinPlugin.instance.isOptionEnabled("bugfix.fix_config_crashes.NightConfigFixerMixin"))
|
if(!ModernFixMixinPlugin.instance.isOptionEnabled("bugfix.fix_config_crashes.NightConfigFixerMixin"))
|
||||||
return;
|
return;
|
||||||
|
|
@ -49,6 +50,7 @@ public class NightConfigFixer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ModernFix.LOGGER.info("Processed {} config reloads", runnablesToRun.size());
|
ModernFix.LOGGER.info("Processed {} config reloads", runnablesToRun.size());
|
||||||
|
couldShowMessage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class MonitoringMap extends ConcurrentHashMap<Path, Object> {
|
static class MonitoringMap extends ConcurrentHashMap<Path, Object> {
|
||||||
|
|
@ -74,13 +76,13 @@ public class NightConfigFixer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long lastConfigTrigger = System.nanoTime();
|
private static boolean couldShowMessage = true;
|
||||||
|
|
||||||
private static void triggerConfigMessage() {
|
private static void triggerConfigMessage() {
|
||||||
if((System.nanoTime() - lastConfigTrigger) >= TimeUnit.SECONDS.toNanos(5)) {
|
if(couldShowMessage && Minecraft.getInstance().level != null && ModernFixClient.recipesUpdated && ModernFixClient.tagsUpdated) {
|
||||||
lastConfigTrigger = System.nanoTime();
|
|
||||||
Minecraft.getInstance().execute(() -> {
|
Minecraft.getInstance().execute(() -> {
|
||||||
if(Minecraft.getInstance().level != null) {
|
if(Minecraft.getInstance().level != null) {
|
||||||
|
couldShowMessage = false;
|
||||||
Minecraft.getInstance().gui.getChat().addMessage(new TranslatableComponent("modernfix.message.reload_config"));
|
Minecraft.getInstance().gui.getChat().addMessage(new TranslatableComponent("modernfix.message.reload_config"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -102,8 +104,9 @@ public class NightConfigFixer {
|
||||||
synchronized(configsToReload) {
|
synchronized(configsToReload) {
|
||||||
if(FMLLoader.getDist().isClient())
|
if(FMLLoader.getDist().isClient())
|
||||||
triggerConfigMessage();
|
triggerConfigMessage();
|
||||||
if(configsToReload.size() == 0)
|
if(configsToReload.size() == 0) {
|
||||||
ModernFixMixinPlugin.instance.logger.info("Please use /{} to reload any changed mod config files", FMLLoader.getDist().isDedicatedServer() ? "mfsrc" : "mfrc");
|
ModernFixMixinPlugin.instance.logger.info("Please use /{} to reload any changed mod config files", FMLLoader.getDist().isDedicatedServer() ? "mfsrc" : "mfrc");
|
||||||
|
}
|
||||||
configsToReload.add(configTracker);
|
configsToReload.add(configTracker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user