Skip to content

Commit

Permalink
fix dataprovider config save issue
Browse files Browse the repository at this point in the history
  • Loading branch information
andi-makes committed Oct 28, 2024
1 parent 882a3e0 commit 38193e9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions common/src/main/java/dev/schmarrn/lighty/DataProviders.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,23 @@ public static void put(ResourceLocation rl, OverlayDataProvider dataProvider) {
DATA_PROVIDERS.put(rl, dataProvider);
}

private static void updateConfig() {
ArrayList<ResourceLocation> 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) {
Expand All @@ -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() {
Expand Down

0 comments on commit 38193e9

Please sign in to comment.