diff options
author | makamys <makamys@outlook.com> | 2022-06-30 17:45:43 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-30 17:45:43 +0200 |
commit | a005dbd2989664c5443c43e97692635d54d7de8c (patch) | |
tree | 6ca743605484552bfa278404f7b2c57e6a6360cb /src/main/java/makamys/neodymium/Neodymium.java | |
parent | 7d481267fb8a5a3a466fde9bfe38cb64379e1409 (diff) | |
download | Neodymium-a005dbd2989664c5443c43e97692635d54d7de8c.tar.gz Neodymium-a005dbd2989664c5443c43e97692635d54d7de8c.tar.bz2 Neodymium-a005dbd2989664c5443c43e97692635d54d7de8c.zip |
Update warnings immediately when Advanced OpenGL setting is changed
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); + } } |