Package space.maxus.flare.ui.compose
Interface Selection<E>
- Type Parameters:
E- The type of selection value
- All Superinterfaces:
Composable,ComposableLike,Configurable<Selection<E>>,Disable,ProviderRendered
A selection is a component that houses a list of values. Only one list value can be selected.
See more in Flare docs: Selection
See more in Flare docs: Selection
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface space.maxus.flare.ui.compose.Configurable
Configurable.Configurator<S> -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> @NotNull Selection.Builder<E>builder(Collection<E> enumeration) Constructs a new selection builderLists all possible values in this selectionReturns the selected valuestatic <E> @NotNull Selection<E>of(@NotNull Collection<E> enumeration, ItemProvider provider, E selected) Constructs a new selectionstatic <E> @NotNull Selection<E>of(Collection<E> enumeration, org.apache.commons.lang3.concurrent.Computable<E, String> formatter) Constructs a new selectionstatic <E> @NotNull Selection<E>of(Collection<E> enumeration, ItemProvider provider) Constructs a new selectionstatic <E> @NotNull Selection<E>of(Collection<E> enumeration, ItemProvider provider, int selected) Constructs a new selection@NotNull ReactiveState<E>Returns the selected value reactive statestatic <E> @NotNull ItemProviderselector(String name, String description, List<E> enumeration, ReactiveState<E> selector, org.apache.commons.lang3.concurrent.Computable<E, String> mapper) Returns a reactive selector item provider with certain settingsstatic <E> @NotNull ItemStackBuilderselectorBuilder(String name, String description, List<E> enumeration, E value, org.apache.commons.lang3.concurrent.Computable<E, String> mapper) Returns a selector item builder with certain settingsstatic <E> @NotNull ItemStackBuilderselectorBuilder(String name, String description, List<E> enumeration, E value, org.apache.commons.lang3.concurrent.Computable<E, String> mapper, @Nullable org.bukkit.entity.Player player) Returns a selector item builder with certain settingsstatic <E> List<net.kyori.adventure.text.Component>selectorLore(@NotNull List<E> enumeration, E selected, org.apache.commons.lang3.concurrent.Computable<E, String> mapper) Builds lore list for a selectionvoidsetSelected(int index) Sets the selected valuevoidsetSelected(E value) Sets the selected valueMethods inherited from interface space.maxus.flare.ui.Composable
asComposable, bind, click, context, contextOrNull, destroy, drag, injectRoot, inside, into, leftClick, markDirty, restore, rightClick, root, shiftFrom, shiftInto, viewerMethods inherited from interface space.maxus.flare.ui.compose.Configurable
configure, configureTypedMethods inherited from interface space.maxus.flare.ui.compose.Disable
disabledState, isDisabled, isNotDisabled, setDisabledMethods inherited from interface space.maxus.flare.ui.compose.ProviderRendered
getProvider, renderAt
-
Method Details
-
selectorLore
static <E> List<net.kyori.adventure.text.Component> selectorLore(@NotNull @NotNull List<E> enumeration, E selected, org.apache.commons.lang3.concurrent.Computable<E, String> mapper) Builds lore list for a selection- Type Parameters:
E- The type of selection value- Parameters:
enumeration- The enumeration of valuesselected- Currently selected valuemapper- Mapper function that converts values to display strings- Returns:
- List of lore components
-
selector
@NotNull static <E> @NotNull ItemProvider selector(String name, String description, List<E> enumeration, ReactiveState<E> selector, org.apache.commons.lang3.concurrent.Computable<E, String> mapper) Returns a reactive selector item provider with certain settings- Type Parameters:
E- The type of selection value- Parameters:
name- Extra message in the item namedescription- Extra description in the loreenumeration- Enumeration of selection valuesselector- The selection reactive statemapper- Mapper function that converts values to display strings- Returns:
- A reactive selector item provider with certain settings
-
selectorBuilder
@NotNull static <E> @NotNull ItemStackBuilder selectorBuilder(String name, String description, List<E> enumeration, E value, org.apache.commons.lang3.concurrent.Computable<E, String> mapper) Returns a selector item builder with certain settings- Type Parameters:
E- The type of selection value- Parameters:
name- Extra message in the item namedescription- Extra description in the loreenumeration- Enumeration of selection valuesmapper- Mapper function that converts values to display stringsvalue- Currently selected value- Returns:
- A selector item builder with certain settings
-
selectorBuilder
@NotNull static <E> @NotNull ItemStackBuilder selectorBuilder(String name, String description, List<E> enumeration, E value, org.apache.commons.lang3.concurrent.Computable<E, String> mapper, @Nullable @Nullable org.bukkit.entity.Player player) Returns a selector item builder with certain settings- Type Parameters:
E- The type of selection value- Parameters:
name- Extra message in the item namedescription- Extra description in the loreenumeration- Enumeration of selection valuesmapper- Mapper function that converts values to display stringsplayer- Player for selectionvalue- Currently selected value- Returns:
- A selector item builder with certain settings
-
of
Constructs a new selection- Type Parameters:
E- The type of selection value- Parameters:
enumeration- Enumeration of all possible valuesprovider- The item provider- Returns:
- A new selection
-
of
@NotNull static <E> @NotNull Selection<E> of(Collection<E> enumeration, ItemProvider provider, int selected) Constructs a new selection- Type Parameters:
E- The type of selection value- Parameters:
enumeration- Enumeration of all possible valuesprovider- The item providerselected- Zero-based index of the selected item- Returns:
- A new selection
-
of
@Contract("_, _, _ -> new") @NotNull static <E> @NotNull Selection<E> of(@NotNull @NotNull Collection<E> enumeration, ItemProvider provider, E selected) Constructs a new selection- Type Parameters:
E- The type of selection value- Parameters:
enumeration- Enumeration of all possible valuesprovider- The item providerselected- The selected value- Returns:
- A new selection
-
of
@NotNull static <E> @NotNull Selection<E> of(Collection<E> enumeration, org.apache.commons.lang3.concurrent.Computable<E, String> formatter) Constructs a new selection- Type Parameters:
E- The type of selection value- Parameters:
enumeration- Enumeration of all possible valuesformatter- The formatter function that takes selection value and turns it to a display string- Returns:
- A new selection
-
builder
Constructs a new selection builder- Type Parameters:
E- The type of selection values- Parameters:
enumeration- Enumeration of all possible values- Returns:
- A new selection builder
-
enumeration
Lists all possible values in this selection- Returns:
- All possible values
-
getSelected
Returns the selected value- Returns:
- The selected value
-
setSelected
void setSelected(int index) Sets the selected value- Parameters:
index- Index of the selected value
-
setSelected
Sets the selected value- Parameters:
value- The new selected value
-
selectedState
Returns the selected value reactive state- Returns:
- The selected value reactive state
-