diff options
Diffstat (limited to 'src/main/java/makamys/neodymium/Neodymium.java')
-rw-r--r-- | src/main/java/makamys/neodymium/Neodymium.java | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/src/main/java/makamys/neodymium/Neodymium.java b/src/main/java/makamys/neodymium/Neodymium.java index 7026bd9..de06451 100644 --- a/src/main/java/makamys/neodymium/Neodymium.java +++ b/src/main/java/makamys/neodymium/Neodymium.java @@ -3,6 +3,7 @@ package makamys.neodymium; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -93,31 +94,10 @@ public class Neodymium destroyRenderer(); } if(Config.enabled && newWorld != null) { - List<String> warns = new ArrayList<>(); - List<String> criticalWarns = new ArrayList<>(); + Pair<List<String>, List<String>> warnsAndCriticalWarns = checkCompat(); + List<String> warns = warnsAndCriticalWarns.getLeft(); + List<String> criticalWarns = warnsAndCriticalWarns.getRight(); - Compat.getCompatibilityWarnings(warns, criticalWarns); - - if(!criticalWarns.isEmpty()) { - criticalWarns.add("Neodymium has been disabled due to a critical incompatibility."); - } - - if(!Config.ignoreIncompatibilities) { - for(String warn : warns) { - ChatUtil.showNeoChatMessage(warn, ChatUtil.MessageVerbosity.WARNING, true); - } - for(String fatalWarn : criticalWarns) { - ChatUtil.showNeoChatMessage(fatalWarn, ChatUtil.MessageVerbosity.ERROR, true); - } - } - - for(String warn : warns) { - LOGGER.warn(warn); - } - for(String criticalWarn : criticalWarns) { - LOGGER.warn("Critical: " + criticalWarn); - } - if(criticalWarns.isEmpty() || Config.ignoreIncompatibilities) { renderer = new NeoRenderer(newWorld); renderer.hasIncompatibilities = !warns.isEmpty() || !criticalWarns.isEmpty(); @@ -159,6 +139,15 @@ public class Neodymium } } } + + if(event.phase == TickEvent.Phase.START) { + if(Compat.hasChanged()) { + Pair<List<String>, List<String>> warns = checkCompat(); + if(renderer != null) { + renderer.hasIncompatibilities = !warns.getLeft().isEmpty() || !warns.getRight().isEmpty(); + } + } + } } @SubscribeEvent @@ -222,5 +211,34 @@ public class Neodymium } rendererWorld = null; } + + private static Pair<List<String>, List<String>> checkCompat() { + List<String> warns = new ArrayList<>(); + List<String> criticalWarns = new ArrayList<>(); + + Compat.getCompatibilityWarnings(warns, criticalWarns); + + if(!criticalWarns.isEmpty()) { + criticalWarns.add("Neodymium has been disabled due to a critical incompatibility."); + } + + if(!Config.ignoreIncompatibilities) { + for(String warn : warns) { + ChatUtil.showNeoChatMessage(warn, ChatUtil.MessageVerbosity.WARNING, true); + } + for(String fatalWarn : criticalWarns) { + ChatUtil.showNeoChatMessage(fatalWarn, ChatUtil.MessageVerbosity.ERROR, true); + } + } + + for(String warn : warns) { + LOGGER.warn(warn); + } + for(String criticalWarn : criticalWarns) { + LOGGER.warn("Critical: " + criticalWarn); + } + + return Pair.of(warns, criticalWarns); + } } |