Package space.maxus.flare.ui
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
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
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 TypeMethodDescriptiondefault ComposableConverts self to a composabledefault Composablebind(ReactiveState<?> state) Binds provided ReactiveState to this Composable.default voidclick(@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> Tcontext()Attempts to get context of this composable's frame.default <T> TAttempts to get context of this composable's frame.default voiddestroy()Destroys this composable and its underlying resources.default booleandrag(@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.voidinjectRoot(Frame root) Injects frame into this component, the frame can then be retrieved fromroot()default @NotNull PackedComposableinside(@NotNull ComposableSpace space) Fits this composable inside the provided space, essentially returning a pair of this component and the space in the form of aPackedComposable.default <T extends Composable>
Composableinto(ReactiveState<T> state) Sets provided ReactiveState value to this Composable reference.default booleanleftClick(@NotNull org.bukkit.event.inventory.InventoryClickEvent e) Called when this component is left clicked inside interfacedefault voidMarks this component dirty, meaning its area will be redrawn next tick.org.bukkit.inventory.ItemStackRenders this component at the provided slot.default voidrestore()Restores this composable to its previous state.default booleanrightClick(@NotNull org.bukkit.event.inventory.InventoryClickEvent e) Called when this component is right clicked inside interfaceroot()Returns the frame this component belongs todefault booleanshiftFrom(@NotNull org.bukkit.event.inventory.InventoryClickEvent e) Called when this component is shift clicked inside interfacedefault booleanshiftInto(@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.Playerviewer()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
Injects frame into this component, the frame can then be retrieved fromroot()- Parameters:
root- Frame to be injected
-
renderAt
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
Fits this composable inside the provided space, essentially returning a pair of this component and the space in the form of aPackedComposable.- Specified by:
insidein interfaceComposableLike- 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 eventstack- 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 spacee- 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
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
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
Description copied from interface:ComposableLikeConverts self to a composable- Specified by:
asComposablein interfaceComposableLike- Returns:
- The composable
-