Skip to content

Commit c8d1d8d

Browse files
authored
Add ability to add descriptions to autogen groups (#324)
1 parent e868c71 commit c8d1d8d

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/main/java/dev/isxander/yacl3/config/v2/impl/ConfigClassHandlerImpl.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import dev.isxander.yacl3.config.v2.impl.autogen.YACLAutoGenException;
1111
import dev.isxander.yacl3.impl.utils.YACLConstants;
1212
import dev.isxander.yacl3.platform.YACLPlatform;
13+
import net.minecraft.locale.Language;
1314
import net.minecraft.network.chat.Component;
1415
import net.minecraft.resources.Identifier;
1516
import org.apache.commons.lang3.Validate;
@@ -134,8 +135,14 @@ public YetAnotherConfigLib generateGui() {
134135
OptionAddable group = groups.groups().computeIfAbsent(autoGen.group().orElse(""), k -> {
135136
if (k.isEmpty())
136137
return groups.category();
137-
return OptionGroup.createBuilder()
138-
.name(Component.translatable("yacl3.config.%s.category.%s.group.%s".formatted(id().toString(), autoGen.category(), k)));
138+
String groupKey = "yacl3.config.%s.category.%s.group.%s".formatted(id().toString(), autoGen.category(), k);
139+
OptionGroup.Builder groupBuilder = OptionGroup.createBuilder()
140+
.name(Component.translatable(groupKey));
141+
String descriptionKey = groupKey + ".desc";
142+
if (Language.getInstance().has(descriptionKey)) {
143+
groupBuilder.description(OptionDescription.of(Component.translatable(descriptionKey)));
144+
}
145+
return groupBuilder;
139146
});
140147

141148
Option<?> option;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"yacl3.config.yacl3-test:config.category.test.group.master_test": "My group!",
3+
"yacl3.config.yacl3-test:config.category.test.group.master_test.desc": "This group has a description via a translation key."
4+
}

0 commit comments

Comments
 (0)