diff --git a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java index 1be82dc3ec..a68676b637 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java @@ -55,17 +55,27 @@ import com.google.common.collect.ObjectArrays; */ public class ForgeConfigSpec extends UnmodifiableConfigWrapper implements IConfigSpec//TODO: Remove extends and pipe everything through getSpec/getValues? { - private Map, String> levelComments = new HashMap<>(); + private Map, String> levelComments; + private Map, String> levelTranslationKeys; private UnmodifiableConfig values; private Config childConfig; private boolean isCorrecting = false; - private ForgeConfigSpec(UnmodifiableConfig storage, UnmodifiableConfig values, Map, String> levelComments) { + private ForgeConfigSpec(UnmodifiableConfig storage, UnmodifiableConfig values, Map, String> levelComments, Map, String> levelTranslationKeys) { super(storage); this.values = values; this.levelComments = levelComments; + this.levelTranslationKeys = levelTranslationKeys; + } + + public String getLevelComment(List path) { + return levelComments.get(path); + } + + public String getLevelTranslationKey(List path) { + return levelTranslationKeys.get(path); } public void setConfig(CommentedConfig config) { @@ -277,6 +287,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper, String> levelComments = new HashMap<>(); + private Map, String> levelTranslationKeys = new HashMap<>(); private List currentPath = new ArrayList<>(); private List> values = new ArrayList<>(); private boolean hasInvalidComment = false; @@ -580,6 +591,10 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper(currentPath), context.buildComment()); context.setComment(); // Set to empty } + if (context.getTranslationKey() != null) { + levelTranslationKeys.put(new ArrayList(currentPath), context.getTranslationKey()); + context.setTranslationKey(null); + } context.ensureEmpty(); return this; } @@ -607,7 +622,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper valueCfg.set(v.getPath(), v)); - ForgeConfigSpec ret = new ForgeConfigSpec(storage, valueCfg, levelComments); + ForgeConfigSpec ret = new ForgeConfigSpec(storage, valueCfg, levelComments, levelTranslationKeys); values.forEach(v -> v.spec = ret); return ret; }