Skip to content

Commit

Permalink
fixed config gui not saving to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
FalsePattern committed Dec 28, 2024
1 parent 886ca5f commit f17e615
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ConfigurationManagerImpl {
private static final Map<Path, Configuration> configs = new HashMap<>();
private static final Map<String, Set<Class<?>>> modConfigs = new HashMap<>();
private static final Map<Configuration, Set<Class<?>>> configToClassMap = new HashMap<>();
private static final Map<Class<?>, ParsedConfiguration> parsedConfigMap = new HashMap<>();
private static final BiMap<String, Class<?>> serializedNames = HashBiMap.create();
Expand All @@ -82,6 +83,7 @@ public static void register(Class<?> configClass) throws ConfigException {
configToClassMap.computeIfAbsent(parsedConfig.rawConfig, (ignored) -> new HashSet<>()).add(configClass);
parsedConfigMap.put(configClass, parsedConfig);
serializedNames.put(parsedConfig.modid + "$" + parsedConfig.category, configClass);
modConfigs.computeIfAbsent(parsedConfig.modid, (x) -> new HashSet<>()).add(configClass);
}
}

Expand Down Expand Up @@ -286,14 +288,10 @@ public static void sendSyncRequest() throws IOException {

public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
init();
val rawConfig = configs.get(event.modID);
if (rawConfig == null) {
val configs = modConfigs.get(event.modID);
if (configs == null) {
return;
}
val configClasses = configToClassMap.get(rawConfig);
for (val clazz : configClasses) {
val config = parsedConfigMap.get(clazz);
config.configChanged();
}
configs.stream().map(parsedConfigMap::get).distinct().forEach(ParsedConfiguration::configChanged);
}
}

0 comments on commit f17e615

Please sign in to comment.