Interface Selection<E>

Type Parameters:
E - The type of selection value
All Superinterfaces:
Composable, ComposableLike, Configurable<Selection<E>>, Disable, ProviderRendered

public interface Selection<E> extends Disable, ProviderRendered, Configurable<Selection<E>>
A selection is a component that houses a list of values. Only one list value can be selected.
See more in Flare docs: Selection
  • 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 values
      selected - Currently selected value
      mapper - 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 name
      description - Extra description in the lore
      enumeration - Enumeration of selection values
      selector - The selection reactive state
      mapper - 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 name
      description - Extra description in the lore
      enumeration - Enumeration of selection values
      mapper - Mapper function that converts values to display strings
      value - 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 name
      description - Extra description in the lore
      enumeration - Enumeration of selection values
      mapper - Mapper function that converts values to display strings
      player - Player for selection
      value - Currently selected value
      Returns:
      A selector item builder with certain settings
    • of

      @NotNull static <E> @NotNull Selection<E> of(Collection<E> enumeration, ItemProvider provider)
      Constructs a new selection
      Type Parameters:
      E - The type of selection value
      Parameters:
      enumeration - Enumeration of all possible values
      provider - 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 values
      provider - The item provider
      selected - 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 values
      provider - The item provider
      selected - 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 values
      formatter - The formatter function that takes selection value and turns it to a display string
      Returns:
      A new selection
    • builder

      @NotNull static <E> @NotNull Selection.Builder<E> builder(Collection<E> enumeration)
      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

      List<E> enumeration()
      Lists all possible values in this selection
      Returns:
      All possible values
    • getSelected

      @NotNull E 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

      void setSelected(E value)
      Sets the selected value
      Parameters:
      value - The new selected value
    • selectedState

      @NotNull @NotNull ReactiveState<E> selectedState()
      Returns the selected value reactive state
      Returns:
      The selected value reactive state