Skip to content

Commit

Permalink
don't merge configs in different subfolders (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyfts authored Sep 1, 2024
1 parent 071cb88 commit 0b01adb
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void registerConfig(Class<?> configClass) throws ConfigException {
val modid = cfg.modid();
val filename = Optional.of(cfg.filename().trim()).filter(s -> !s.isEmpty()).orElse(modid);

Configuration rawConfig = configs.computeIfAbsent(modid + "|" + filename, (ignored) -> {
Configuration rawConfig = configs.computeIfAbsent(getConfigKey(cfg), (ignored) -> {
Path newConfigDir = configDir;
if (!cfg.configSubDirectory().trim().isEmpty()) {
newConfigDir = newConfigDir.resolve(cfg.configSubDirectory().trim());
Expand Down Expand Up @@ -231,9 +231,7 @@ public static List<IConfigElement> getConfigElements(Class<?> configClass) throw
init();
val cfg = Optional.ofNullable(configClass.getAnnotation(Config.class)).orElseThrow(
() -> new ConfigException("Class " + configClass.getName() + " does not have a @Config annotation!"));
val modid = cfg.modid();
val filename = Optional.of(cfg.filename().trim()).filter(s -> !s.isEmpty()).orElse(modid);
val rawConfig = Optional.ofNullable(configs.get(modid + "|" + filename)).map(
val rawConfig = Optional.ofNullable(configs.get(getConfigKey(cfg))).map(
(conf) -> Optional.ofNullable(configToCategoryClassMap.get(conf))
.map((map) -> map.get(cfg.category().trim()).contains(configClass)).orElse(false) ? conf : null)
.orElseThrow(
Expand Down Expand Up @@ -267,6 +265,10 @@ public static List<IConfigElement> getConfigElementsMulti(Class<?>... configClas
}
}

private static String getConfigKey(Config cfg) {
return cfg.modid() + "|" + cfg.configSubDirectory() + "|" + cfg.filename();
}

private static File minecraftHome() {
return Launch.minecraftHome != null ? Launch.minecraftHome : new File(".");
}
Expand Down

0 comments on commit 0b01adb

Please sign in to comment.