package dev.isxander.yacl.impl; import com.google.common.collect.ImmutableSet; import dev.isxander.yacl.api.*; import dev.isxander.yacl.gui.YACLScreen; import net.minecraft.text.Text; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.function.BiConsumer; import java.util.function.Function; public class ButtonOptionImpl implements ButtonOption { private final Text name; private final Text tooltip; private final BiConsumer action; private boolean available; private final Controller> controller; private final Binding> binding; public ButtonOptionImpl( @NotNull Text name, @Nullable Text tooltip, @NotNull BiConsumer action, boolean available, @NotNull Function>> controlGetter ) { this.name = name; this.tooltip = tooltip; this.action = action; this.available = available; this.controller = controlGetter.apply(this); this.binding = new EmptyBinderImpl(); } @Override public @NotNull Text name() { return name; } @Override public @NotNull Text tooltip() { return tooltip; } @Override public BiConsumer action() { return action; } @Override public boolean available() { return available; } @Override public void setAvailable(boolean available) { this.available = available; } @Override public @NotNull Controller> controller() { return controller; } @Override public @NotNull Binding> binding() { return binding; } @Override public @NotNull Class> typeClass() { throw new UnsupportedOperationException(); } @Override public @NotNull ImmutableSet flags() { return ImmutableSet.of(); } @Override public boolean requiresRestart() { return false; } @Override public boolean changed() { return false; } @Override public @NotNull BiConsumer pendingValue() { throw new UnsupportedOperationException(); } @Override public void requestSet(BiConsumer value) { throw new UnsupportedOperationException(); } @Override public boolean applyValue() { return false; } @Override public void forgetPendingValue() { } @Override public void requestSetDefault() { } @Override public boolean isPendingValueDefault() { throw new UnsupportedOperationException(); } @Override public void addListener(BiConsumer>, BiConsumer> changedListener) { } private static class EmptyBinderImpl implements Binding> { @Override public void setValue(BiConsumer value) { } @Override public BiConsumer getValue() { throw new UnsupportedOperationException(); } @Override public BiConsumer defaultValue() { throw new UnsupportedOperationException(); } } }