Skip to content

Commit

Permalink
move important members of option builder subinterfaces more useful
Browse files Browse the repository at this point in the history
  • Loading branch information
douira committed Oct 26, 2024
1 parent 6fd07b4 commit 6e76e4c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
import java.util.function.Supplier;

public interface EnumOptionBuilder<E extends Enum<E>> extends OptionBuilder<E> {
static <E extends Enum<E>> Function<E, Component> nameProviderFrom(Component... names) {
return e -> names[e.ordinal()];
}

EnumOptionBuilder<E> setAllowedValues(Set<E> allowedValues);

EnumOptionBuilder<E> setAllowedValuesProvider(Function<ConfigState, Set<E>> provider, ResourceLocation... dependencies);

EnumOptionBuilder<E> setElementNameProvider(Function<E, Component> provider);

@Override
EnumOptionBuilder<E> setName(Component name);

Expand Down Expand Up @@ -48,14 +58,4 @@ public interface EnumOptionBuilder<E extends Enum<E>> extends OptionBuilder<E> {

@Override
EnumOptionBuilder<E> setBinding(OptionBinding<E> binding);

EnumOptionBuilder<E> setAllowedValues(Set<E> allowedValues);

EnumOptionBuilder<E> setAllowedValuesProvider(Function<ConfigState, Set<E>> provider, ResourceLocation... dependencies);

EnumOptionBuilder<E> setElementNameProvider(Function<E, Component> provider);

static <E extends Enum<E>> Function<E, Component> nameProviderFrom(Component... names) {
return e -> names[e.ordinal()];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
import java.util.function.Supplier;

public interface IntegerOptionBuilder extends OptionBuilder<Integer> {
IntegerOptionBuilder setRange(int min, int max, int step);

IntegerOptionBuilder setRange(Range range);

IntegerOptionBuilder setRangeProvider(Function<ConfigState, Range> provider, ResourceLocation... dependencies);

IntegerOptionBuilder setValueFormatter(ControlValueFormatter formatter);

@Override
IntegerOptionBuilder setName(Component name);

Expand Down Expand Up @@ -45,12 +53,4 @@ public interface IntegerOptionBuilder extends OptionBuilder<Integer> {

@Override
IntegerOptionBuilder setBinding(OptionBinding<Integer> binding);

IntegerOptionBuilder setRange(int min, int max, int step);

IntegerOptionBuilder setRange(Range range);

IntegerOptionBuilder setRangeProvider(Function<ConfigState, Range> provider, ResourceLocation... dependencies);

IntegerOptionBuilder setValueFormatter(ControlValueFormatter formatter);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public IntegerOptionBuilder setRangeProvider(Function<ConfigState, Range> provid
return this;
}

@Override
public IntegerOptionBuilder setValueFormatter(ControlValueFormatter formatter) {
this.valueFormatter = formatter;
return this;
}

@Override
public IntegerOptionBuilder setName(Component name) {
super.setName(name);
Expand Down Expand Up @@ -128,10 +134,4 @@ public IntegerOptionBuilder setBinding(OptionBinding<Integer> binding) {
super.setBinding(binding);
return this;
}

@Override
public IntegerOptionBuilder setValueFormatter(ControlValueFormatter formatter) {
this.valueFormatter = formatter;
return this;
}
}

0 comments on commit 6e76e4c

Please sign in to comment.