clean: improve entry access further

This commit is contained in:
Martin Prokoph
2025-04-05 12:02:58 +02:00
parent ee705b2cbd
commit 64be14f136

View File

@@ -174,7 +174,6 @@ public abstract class MidnightConfig {
}; };
info.function = new AbstractMap.SimpleEntry<ButtonWidget.PressAction, Function<Object, Text>>(button -> { info.function = new AbstractMap.SimpleEntry<ButtonWidget.PressAction, Function<Object, Text>>(button -> {
int index = values.indexOf(info.value) + 1; int index = values.indexOf(info.value) + 1;
//info.value = values.get(index >= values.size() ? 0 : index); button.setMessage(func.apply(info.value));
info.setValue(values.get(index >= values.size() ? 0 : index)); info.setValue(values.get(index >= values.size() ? 0 : index));
button.setMessage(func.apply(info.value)); button.setMessage(func.apply(info.value));
}, func); }, func);
@@ -250,7 +249,7 @@ public abstract class MidnightConfig {
this.parent = parent; this.modid = modid; this.parent = parent; this.modid = modid;
this.translationPrefix = modid + ".midnightconfig."; this.translationPrefix = modid + ".midnightconfig.";
loadValuesFromJson(modid); loadValuesFromJson(modid);
entries.forEach((id, info) -> { entries.values().forEach(info -> {
if (info.modid.equals(modid)) { if (info.modid.equals(modid)) {
String tabId = info.entry != null ? info.entry.category() : info.comment.category(); String tabId = info.entry != null ? info.entry.category() : info.comment.category();
String name = translationPrefix + "category." + tabId; String name = translationPrefix + "category." + tabId;
@@ -335,7 +334,7 @@ public abstract class MidnightConfig {
this.list.clear(); fillList(); this.list.clear(); fillList();
} }
public void fillList() { public void fillList() {
for (EntryInfo info : entries.sequencedValues()) { for (EntryInfo info : entries.values()) {
if (!info.conditionsMet) { if (!info.conditionsMet) {
boolean visibleButLocked = false; boolean visibleButLocked = false;
for (Condition condition : info.conditions) { for (Condition condition : info.conditions) {