mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-13 00:15:08 +01:00
clean: some code cleanup
This commit is contained in:
@@ -187,11 +187,9 @@ public abstract class MidnightConfig {
|
||||
}
|
||||
|
||||
private static Text getEnumTranslatableText(Object value, String modid, EntryInfo info) {
|
||||
if (value instanceof TranslatableOption translatableOption) {
|
||||
return translatableOption.getText();
|
||||
}
|
||||
if (value instanceof TranslatableOption translatableOption) return translatableOption.getText();
|
||||
|
||||
String translationKey = modid + ".midnightconfig.enum." + info.dataType.getSimpleName() + "." + info.toTemporaryValue();
|
||||
String translationKey = "%s.midnightconfig.enum.%s.%s".formatted(modid, info.dataType.getSimpleName(), info.toTemporaryValue());
|
||||
return I18n.hasTranslation(translationKey) ? Text.translatable(translationKey) : Text.literal(info.toTemporaryValue());
|
||||
}
|
||||
|
||||
@@ -257,7 +255,7 @@ public abstract class MidnightConfig {
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class MidnightConfigScreen extends Screen {
|
||||
protected MidnightConfigScreen(Screen parent, String modid) {
|
||||
super(Text.translatable(modid + ".midnightconfig." + "title"));
|
||||
super(Text.translatable(modid + ".midnightconfig.title"));
|
||||
this.parent = parent; this.modid = modid;
|
||||
this.translationPrefix = modid + ".midnightconfig.";
|
||||
loadValuesFromJson(modid);
|
||||
|
||||
@@ -40,35 +40,6 @@ public class MidnightConfigExample extends MidnightConfig {
|
||||
QUILT, FABRIC, FORGE, NEOFORGE, VANILLA
|
||||
}
|
||||
@Entry(category = TEXT) public static GraphicsSteps graphicsSteps = GraphicsSteps.FABULOUS; // Example for an enum option with TranslatableOption
|
||||
public enum GraphicsSteps implements TranslatableOption {
|
||||
FAST(0, "options.graphics.fast"),
|
||||
FANCY(1, "options.graphics.fancy"),
|
||||
FABULOUS(2, "options.graphics.fabulous");
|
||||
|
||||
private final int id;
|
||||
private final String translationKey;
|
||||
|
||||
GraphicsSteps(int id, String translationKey) {
|
||||
this.id = id;
|
||||
this.translationKey = translationKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getText() {
|
||||
MutableText mutableText = Text.translatable(this.getTranslationKey());
|
||||
return this == GraphicsSteps.FABULOUS ? mutableText.formatted(Formatting.ITALIC).formatted(Formatting.AQUA) : mutableText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey() {
|
||||
return this.translationKey;
|
||||
}
|
||||
}
|
||||
|
||||
@Comment(category = TEXT, name = "§nMidnightLib Wiki", centered = true, url = "https://www.midnightdust.eu/wiki/midnightlib/") public static Comment wiki; // Example for a comment with a url
|
||||
|
||||
@@ -155,6 +126,36 @@ public class MidnightConfigExample extends MidnightConfig {
|
||||
|
||||
public static int imposter = 16777215; // - Entries without an @Entry or @Comment annotation are ignored
|
||||
|
||||
public enum GraphicsSteps implements TranslatableOption {
|
||||
FAST(0, "options.graphics.fast"),
|
||||
FANCY(1, "options.graphics.fancy"),
|
||||
FABULOUS(2, "options.graphics.fabulous");
|
||||
|
||||
private final int id;
|
||||
private final String translationKey;
|
||||
|
||||
GraphicsSteps(int id, String translationKey) {
|
||||
this.id = id;
|
||||
this.translationKey = translationKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getText() {
|
||||
MutableText mutableText = Text.translatable(this.getTranslationKey());
|
||||
return this == GraphicsSteps.FABULOUS ? mutableText.formatted(Formatting.ITALIC).formatted(Formatting.AQUA) : mutableText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey() {
|
||||
return this.translationKey;
|
||||
}
|
||||
}
|
||||
|
||||
@Condition(requiredModId = "thismoddoesnotexist")
|
||||
@Comment(category = EXTRAS) public static Comment iAmJustADummy; // We only have this to initialize an empty tab for the keybinds below
|
||||
|
||||
|
||||
Reference in New Issue
Block a user