69
69
@ NoArgsConstructor (access = AccessLevel .PRIVATE )
70
70
public final class ConfigurationManagerImpl {
71
71
private static final Map <Path , Configuration > configs = new HashMap <>();
72
+ private static final Map <String , Set <Class <?>>> modConfigs = new HashMap <>();
72
73
private static final Map <Configuration , Set <Class <?>>> configToClassMap = new HashMap <>();
73
74
private static final Map <Class <?>, ParsedConfiguration > parsedConfigMap = new HashMap <>();
74
75
private static final BiMap <String , Class <?>> serializedNames = HashBiMap .create ();
@@ -82,6 +83,7 @@ public static void register(Class<?> configClass) throws ConfigException {
82
83
configToClassMap .computeIfAbsent (parsedConfig .rawConfig , (ignored ) -> new HashSet <>()).add (configClass );
83
84
parsedConfigMap .put (configClass , parsedConfig );
84
85
serializedNames .put (parsedConfig .modid + "$" + parsedConfig .category , configClass );
86
+ modConfigs .computeIfAbsent (parsedConfig .modid , (x ) -> new HashSet <>()).add (configClass );
85
87
}
86
88
}
87
89
@@ -286,14 +288,10 @@ public static void sendSyncRequest() throws IOException {
286
288
287
289
public static void onConfigChanged (ConfigChangedEvent .OnConfigChangedEvent event ) {
288
290
init ();
289
- val rawConfig = configs .get (event .modID );
290
- if (rawConfig == null ) {
291
+ val configs = modConfigs .get (event .modID );
292
+ if (configs == null ) {
291
293
return ;
292
294
}
293
- val configClasses = configToClassMap .get (rawConfig );
294
- for (val clazz : configClasses ) {
295
- val config = parsedConfigMap .get (clazz );
296
- config .configChanged ();
297
- }
295
+ configs .stream ().map (parsedConfigMap ::get ).distinct ().forEach (ParsedConfiguration ::configChanged );
298
296
}
299
297
}
0 commit comments