fix config event crash

This commit is contained in:
FalsePattern committed 2024-12-06 21:11:16 +01:00
1 parent 627125b821
commit 5bfd4082b3
2 files changed
+10 -20

No files matched your search

@@ -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);
}
}
}
}
@@ -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);
}
}
}
}
}