From 11ab4e400a69e019bcdd00de449d44aa75b92099 Mon Sep 17 00:00:00 2001 From: isXander Date: Mon, 24 Jul 2023 15:58:24 +0100 Subject: Fix the name of the list being present on every entry --- .../yacl3/impl/HiddenNameListOptionEntry.java | 109 +++++++++++++++++++++ .../isxander/yacl3/impl/ListOptionEntryImpl.java | 4 +- 2 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/dev/isxander/yacl3/impl/HiddenNameListOptionEntry.java (limited to 'common/src/main/java/dev') diff --git a/common/src/main/java/dev/isxander/yacl3/impl/HiddenNameListOptionEntry.java b/common/src/main/java/dev/isxander/yacl3/impl/HiddenNameListOptionEntry.java new file mode 100644 index 0000000..6ff2669 --- /dev/null +++ b/common/src/main/java/dev/isxander/yacl3/impl/HiddenNameListOptionEntry.java @@ -0,0 +1,109 @@ +package dev.isxander.yacl3.impl; + +import com.google.common.collect.ImmutableSet; +import dev.isxander.yacl3.api.*; +import net.minecraft.network.chat.Component; +import org.jetbrains.annotations.NotNull; + +import java.util.function.BiConsumer; + +public class HiddenNameListOptionEntry implements ListOptionEntry { + private final ListOptionEntry option; + + public HiddenNameListOptionEntry(ListOptionEntry option) { + this.option = option; + } + + @Override + public @NotNull Component name() { + return Component.empty(); + } + + @Override + public @NotNull OptionDescription description() { + return option.description(); + } + + @Override + @Deprecated + public @NotNull Component tooltip() { + return option.tooltip(); + } + + @Override + public @NotNull Controller controller() { + return option.controller(); + } + + @Override + public @NotNull Binding binding() { + return option.binding(); + } + + @Override + public boolean available() { + return option.available(); + } + + @Override + public void setAvailable(boolean available) { + option.setAvailable(available); + } + + @Override + public ListOption parentGroup() { + return option.parentGroup(); + } + + @Override + public @NotNull ImmutableSet flags() { + return option.flags(); + } + + @Override + public boolean changed() { + return option.changed(); + } + + @Override + public @NotNull T pendingValue() { + return option.pendingValue(); + } + + @Override + public void requestSet(T value) { + option.requestSet(value); + } + + @Override + public boolean applyValue() { + return option.applyValue(); + } + + @Override + public void forgetPendingValue() { + option.forgetPendingValue(); + } + + @Override + public void requestSetDefault() { + option.requestSetDefault(); + } + + @Override + public boolean isPendingValueDefault() { + return option.isPendingValueDefault(); + } + + @Override + public boolean canResetToDefault() { + return option.canResetToDefault(); + } + + @Override + public void addListener(BiConsumer, T> changedListener) { + option.addListener(changedListener); + } + + +} diff --git a/common/src/main/java/dev/isxander/yacl3/impl/ListOptionEntryImpl.java b/common/src/main/java/dev/isxander/yacl3/impl/ListOptionEntryImpl.java index d5a9218..bdb8de8 100644 --- a/common/src/main/java/dev/isxander/yacl3/impl/ListOptionEntryImpl.java +++ b/common/src/main/java/dev/isxander/yacl3/impl/ListOptionEntryImpl.java @@ -25,7 +25,7 @@ public final class ListOptionEntryImpl implements ListOptionEntry { this.group = group; this.value = initialValue; this.binding = new EntryBinding(); - this.controller = new EntryController<>(controlGetter.apply(this), this); + this.controller = new EntryController<>(controlGetter.apply(new HiddenNameListOptionEntry<>(this)), this); } @Override @@ -40,7 +40,7 @@ public final class ListOptionEntryImpl implements ListOptionEntry { @Override public @NotNull Component tooltip() { - return Component.empty(); + return group.tooltip(); } @Override -- cgit