From 38193e94485d0b2df8622538c8c4683c69582673 Mon Sep 17 00:00:00 2001 From: andi-makes Date: Mon, 28 Oct 2024 11:55:53 +0100 Subject: [PATCH] fix dataprovider config save issue --- .../java/dev/schmarrn/lighty/DataProviders.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/dev/schmarrn/lighty/DataProviders.java b/common/src/main/java/dev/schmarrn/lighty/DataProviders.java index c9c4997..f07c5d8 100644 --- a/common/src/main/java/dev/schmarrn/lighty/DataProviders.java +++ b/common/src/main/java/dev/schmarrn/lighty/DataProviders.java @@ -17,13 +17,23 @@ public static void put(ResourceLocation rl, OverlayDataProvider dataProvider) { DATA_PROVIDERS.put(rl, dataProvider); } + private static void updateConfig() { + ArrayList activeRls = new ArrayList<>(); + DATA_PROVIDERS.forEach((key, value) -> { + if (ACTIVE_PROVIDERS.contains(value)) { + activeRls.add(key); + } + }); + Config.ACTIVE_DATA_PROVIDERS.setValue(activeRls); + } + public static void activate(ResourceLocation rl) { if (DATA_PROVIDERS.containsKey(rl)) { ACTIVE_PROVIDERS.add(DATA_PROVIDERS.get(rl)); } else { Lighty.LOGGER.error("There is no OverlayDataProvider registered for {}! Not changing active OverlayDataProviders.", rl); } - Config.ACTIVE_DATA_PROVIDERS.setValue(DATA_PROVIDERS.keySet().stream().toList()); + updateConfig(); } public static void deactivate(ResourceLocation rl) { @@ -32,7 +42,7 @@ public static void deactivate(ResourceLocation rl) { } else { Lighty.LOGGER.error("There is no OverlayDataProvider registered for {}! Cannot remove {}.", rl, rl); } - Config.ACTIVE_DATA_PROVIDERS.setValue(DATA_PROVIDERS.keySet().stream().toList()); + updateConfig(); } public static void setLastActiveProviders() {