6969@ NoArgsConstructor (access = AccessLevel .PRIVATE )
7070public final class ConfigurationManagerImpl {
7171 private static final Map <Path , Configuration > configs = new HashMap <>();
72+ private static final Map <String , Set <Class <?>>> modConfigs = new HashMap <>();
7273 private static final Map <Configuration , Set <Class <?>>> configToClassMap = new HashMap <>();
7374 private static final Map <Class <?>, ParsedConfiguration > parsedConfigMap = new HashMap <>();
7475 private static final BiMap <String , Class <?>> serializedNames = HashBiMap .create ();
@@ -82,6 +83,7 @@ public static void register(Class<?> configClass) throws ConfigException {
8283 configToClassMap .computeIfAbsent (parsedConfig .rawConfig , (ignored ) -> new HashSet <>()).add (configClass );
8384 parsedConfigMap .put (configClass , parsedConfig );
8485 serializedNames .put (parsedConfig .modid + "$" + parsedConfig .category , configClass );
86+ modConfigs .computeIfAbsent (parsedConfig .modid , (x ) -> new HashSet <>()).add (configClass );
8587 }
8688 }
8789
@@ -286,14 +288,10 @@ public static void sendSyncRequest() throws IOException {
286288
287289 public static void onConfigChanged (ConfigChangedEvent .OnConfigChangedEvent event ) {
288290 init ();
289- val rawConfig = configs .get (event .modID );
290- if (rawConfig == null ) {
291+ val configs = modConfigs .get (event .modID );
292+ if (configs == null ) {
291293 return ;
292294 }
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 );
298296 }
299297}
0 commit comments