Interface Composable

All Superinterfaces:
ComposableLike
All Known Subinterfaces:
Button, Checkbox, Composition, ContainerSlot, GoBackButton, Modal, PaginationDisplay, Placeholder, ProgressBar, ProviderRendered, Selection<E>, Slideshow, Tabulation, TextInput
All Known Implementing Classes:
FunctionComposable, RootReferencing

public interface Composable extends ComposableLike
Represents a Component that can be rendered inside an inventory.
If you wish to implement your own composable, it is not recommended to implement this interface directly, instead, have a look at FunctionComposable
  • Method Summary

    Modifier and Type
    Method
    Description
    default Composable
    Converts self to a composable
    default Composable
    bind(ReactiveState<?> state)
    Binds provided ReactiveState to this Composable.
    default void
    click(@NotNull org.bukkit.event.inventory.InventoryClickEvent e)
    Called each time this item is clicked, no matter if it is a right click, left click, middle click, etc.
    default <T> T
    Attempts to get context of this composable's frame.
    default <T> T
    Attempts to get context of this composable's frame.
    default void
    Destroys this composable and its underlying resources.
    default boolean
    drag(@NotNull Map<Slot,org.bukkit.inventory.ItemStack> newItems, @NotNull org.bukkit.event.inventory.InventoryDragEvent e)
    Called when items are dragged across this composable inside interface.
    void
    Injects frame into this component, the frame can then be retrieved from root()
    default @NotNull PackedComposable
    inside(@NotNull ComposableSpace space)
    Fits this composable inside the provided space, essentially returning a pair of this component and the space in the form of a PackedComposable.
    default <T extends Composable>
    Composable
    into(ReactiveState<T> state)
    Sets provided ReactiveState value to this Composable reference.
    default boolean
    leftClick(@NotNull org.bukkit.event.inventory.InventoryClickEvent e)
    Called when this component is left clicked inside interface
    default void
    Marks this component dirty, meaning its area will be redrawn next tick.
    org.bukkit.inventory.ItemStack
    renderAt(Slot slot)
    Renders this component at the provided slot.
    default void
    Restores this composable to its previous state.
    default boolean
    rightClick(@NotNull org.bukkit.event.inventory.InventoryClickEvent e)
    Called when this component is right clicked inside interface
    Returns the frame this component belongs to
    default boolean
    shiftFrom(@NotNull org.bukkit.event.inventory.InventoryClickEvent e)
    Called when this component is shift clicked inside interface
    default boolean
    shiftInto(@NotNull org.bukkit.inventory.ItemStack stack, @NotNull org.bukkit.event.inventory.InventoryClickEvent e)
    Called when this component is attempted to put items into by shift click.
    default org.bukkit.entity.Player
    Gets the current viewer of this composable
  • Method Details

    • root

      Frame root()
      Returns the frame this component belongs to
      Returns:
      The frame this component belongs to
    • injectRoot

      @Internal void injectRoot(Frame root)
      Injects frame into this component, the frame can then be retrieved from root()
      Parameters:
      root - Frame to be injected
    • renderAt

      org.bukkit.inventory.ItemStack renderAt(Slot slot)
      Renders this component at the provided slot.
      Parameters:
      slot - Slot to render at
      Returns:
      The rendered item stack
    • destroy

      @OverrideOnly default void destroy()
      Destroys this composable and its underlying resources. Overridden by implementors.
    • restore

      @OverrideOnly default void restore()
      Restores this composable to its previous state. Overridden by implementors.
    • inside

      @NotNull default @NotNull PackedComposable inside(@NotNull @NotNull ComposableSpace space)
      Fits this composable inside the provided space, essentially returning a pair of this component and the space in the form of a PackedComposable.
      Specified by:
      inside in interface ComposableLike
      Parameters:
      space - Space to fit inside
      Returns:
      A pair of this component and the space in the form of a PackedComposable
    • rightClick

      @OverrideOnly default boolean rightClick(@NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent e)
      Called when this component is right clicked inside interface
      Parameters:
      e - The click event
      Returns:
      True if the event should be cancelled, false otherwise
    • leftClick

      @OverrideOnly default boolean leftClick(@NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent e)
      Called when this component is left clicked inside interface
      Parameters:
      e - The click event
      Returns:
      True if the event should be cancelled, false otherwise
    • shiftFrom

      @OverrideOnly default boolean shiftFrom(@NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent e)
      Called when this component is shift clicked inside interface
      Parameters:
      e - The click event
      Returns:
      True if the event should be cancelled, false otherwise
    • shiftInto

      @OverrideOnly default boolean shiftInto(@NotNull @NotNull org.bukkit.inventory.ItemStack stack, @NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent e)
      Called when this component is attempted to put items into by shift click. This means that a player clicked on an item inside their inventory, and Flare attempts to fit item inside this composable.
      Parameters:
      e - The click event
      stack - Stack that is attempted to be moved.
      Returns:
      True if the event should be cancelled, false otherwise
    • click

      @OverrideOnly default void click(@NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent e)
      Called each time this item is clicked, no matter if it is a right click, left click, middle click, etc.
      Parameters:
      e - The click event
    • drag

      @OverrideOnly @Experimental default boolean drag(@NotNull @NotNull Map<Slot,org.bukkit.inventory.ItemStack> newItems, @NotNull @NotNull org.bukkit.event.inventory.InventoryDragEvent e)
      Called when items are dragged across this composable inside interface. This method is currently experimental and may not work correctly
      Parameters:
      newItems - Items that are dragged inside this composable's space
      e - The drag event
      Returns:
      True if the event should be cancelled, false otherwise.
    • markDirty

      default void markDirty()
      Marks this component dirty, meaning its area will be redrawn next tick.
    • bind

      default Composable bind(ReactiveState<?> state)
      Binds provided ReactiveState to this Composable. This means that every time the ReactiveState changes its value, this component will be marked dirty.

      Not to be confused with into(ReactiveState).

      Parameters:
      state - The state to be bound
      Returns:
      This composable
    • into

      default <T extends Composable> Composable into(ReactiveState<T> state)
      Sets provided ReactiveState value to this Composable reference.

      Not to be confused with bind(ReactiveState).

      Type Parameters:
      T - The generic type of this composable
      Parameters:
      state - The state to be set
      Returns:
      This composable
    • context

      @NotNull default <T> T context()
      Attempts to get context of this composable's frame. Throws an exception if it is null.
      Type Parameters:
      T - Expected type of context
      Returns:
      Context of provided type
    • contextOrNull

      @Nullable default <T> T contextOrNull()
      Attempts to get context of this composable's frame.
      Type Parameters:
      T - Expected type of context
      Returns:
      Context of provided type or null.
    • viewer

      default org.bukkit.entity.Player viewer()
      Gets the current viewer of this composable
      Returns:
      Current viewer of this composable
    • asComposable

      default Composable asComposable()
      Description copied from interface: ComposableLike
      Converts self to a composable
      Specified by:
      asComposable in interface ComposableLike
      Returns:
      The composable