From 5bfd4082b348d7dec50cf1e4cc8dc839d2a8e988 Mon Sep 17 00:00:00 2001 From: FalsePattern Date: Fri, 6 Dec 2024 21:10:05 +0100 Subject: [PATCH] fix config event crash --- .../config/event/ClientEventHandlerPre.java | 11 ++++++++++- .../config/event/CommonEventHandlerPre.java | 19 ------------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/falsepattern/lib/internal/impl/config/event/ClientEventHandlerPre.java b/src/main/java/com/falsepattern/lib/internal/impl/config/event/ClientEventHandlerPre.java index 8daec3a..0fec49d 100644 --- a/src/main/java/com/falsepattern/lib/internal/impl/config/event/ClientEventHandlerPre.java +++ b/src/main/java/com/falsepattern/lib/internal/impl/config/event/ClientEventHandlerPre.java @@ -28,7 +28,6 @@ import com.falsepattern.lib.config.event.ConfigSyncEvent; import com.falsepattern.lib.config.event.ConfigValidationFailureEvent; import com.falsepattern.lib.internal.FPLog; import com.falsepattern.lib.internal.config.ConfigEngineConfig; -import com.falsepattern.lib.internal.config.MiscConfig; import com.falsepattern.lib.text.FormattedText; import com.falsepattern.lib.toasts.GuiToast; import com.falsepattern.lib.toasts.SimpleToast; @@ -75,6 +74,9 @@ public class ClientEventHandlerPre { false, 5000)); } + if (ConfigEngineConfig.CONFIG_SYNC_SUCCESS_LOGGING != ConfigEngineConfig.LoggingLevel.None) { + FPLog.LOG.info("Synced config: {}:{}", cfg.modid(), cfg.category()); + } } else { if (ConfigEngineConfig.CONFIG_SYNC_FAILURE_LOGGING == ConfigEngineConfig.LoggingLevel.LogAndToast) { GuiToast.add(new SimpleToast(ToastBG.TOAST_DARK, @@ -86,6 +88,13 @@ public class ClientEventHandlerPre { false, 5000)); } + if (ConfigEngineConfig.CONFIG_SYNC_FAILURE_LOGGING != ConfigEngineConfig.LoggingLevel.None) { + FPLog.LOG.error("Failed to sync config: {}:{}", cfg.modid(), cfg.category()); + val t = e.error; + if (t != null) { + FPLog.LOG.error(t.getMessage(), t); + } + } } } diff --git a/src/main/java/com/falsepattern/lib/internal/impl/config/event/CommonEventHandlerPre.java b/src/main/java/com/falsepattern/lib/internal/impl/config/event/CommonEventHandlerPre.java index 0457f63..b241f17 100644 --- a/src/main/java/com/falsepattern/lib/internal/impl/config/event/CommonEventHandlerPre.java +++ b/src/main/java/com/falsepattern/lib/internal/impl/config/event/CommonEventHandlerPre.java @@ -57,23 +57,4 @@ public class CommonEventHandlerPre { e.logWarn(); } } - - @SubscribeEvent - public void onConfigSyncFinished(ConfigSyncEvent.End e) { - if (e.successful) { - if (ConfigEngineConfig.CONFIG_SYNC_SUCCESS_LOGGING != ConfigEngineConfig.LoggingLevel.None) { - val cfg = e.configClass.getAnnotation(Config.class); - FPLog.LOG.info("Synced config: {}:{}", cfg.modid(), cfg.category()); - } - } else { - if (ConfigEngineConfig.CONFIG_SYNC_FAILURE_LOGGING != ConfigEngineConfig.LoggingLevel.None) { - val cfg = e.configClass.getAnnotation(Config.class); - FPLog.LOG.error("Failed to sync config: {}:{}", cfg.modid(), cfg.category()); - val t = e.error; - if (t != null) { - FPLog.LOG.error(t.getMessage(), t); - } - } - } - } }