Package com.marcusslover.plus.lib.item
Class Canvas
java.lang.Object
com.marcusslover.plus.lib.item.Canvas
- All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder
A canvas is a representation of a menu.
It is used to customize the menu layout.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA decorator that fills all empty slots with a given item, except the edges.static classA basic populator implementation.static interfaceA button click.static interfaceA button drag.static classA button click context or some inventory related action.static interfaceA close inventory.static classA button drag context or some inventory related action.static classRepresents a dynamic supplier.static classA decorator that fills all edge slots with a given item.static classA full decorator that fills all empty slots with a given item.static interfaceA generic click.static interfaceA generic button drag.static interfaceRepresents a decorator that puts "free" items in the inventory.static interfaceA self-inventory click. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull CanvasAdd a button to the canvas.@NotNull Canvas.ClickContextbutton(@NotNull Button button, @Nullable Canvas.ButtonClick buttonClick) Add a button to the canvas.voidclear()Clears the canvas.@NotNull Canvas.ClickContextcloseInventory(@Nullable Canvas.CloseInventory closeInventory) Set the close inventory action.@NotNull Canvasdecorate(@NotNull Canvas.ItemDecorator decorator) Adds a new layer of decorating to the canvas.<T> @NotNull Supplier<@Nullable T> dynamicContent(@NotNull Class<T> type) Gets the dynamic content supplier.@NotNull Canvas.ClickContextgenericClick(@Nullable Canvas.GenericClick genericClick) Set the generic click action.@NotNull Canvas.DragContextgenericDrag(@Nullable Canvas.GenericDrag genericDrag) Set the generic drag action.@NotNull org.bukkit.inventory.Inventory<T> @NotNull Canvas.BasicPopulator<T> Starts the population of the elements on the canvas.@NotNull List<@NotNull Canvas.BasicPopulator<?>> Gets list of all populator contexts.<T> @NotNull CanvasregisterDynamicContent(@NotNull Class<T> type, @NotNull Supplier<T> supplier) Registers a dynamic content supplier.@NotNull CanvasremoveDecorator(@NotNull Canvas.ItemDecorator decorator) Removes a decorator from the canvas.@NotNull CanvasRemoves the first populator context.@NotNull CanvasRemoves the last populator context.@NotNull Canvas.ClickContextselfInventory(@Nullable Canvas.SelfInventoryClick selfInventory) Set the self-inventory action.@NotNull CanvasSet the title of the canvas.@NotNull CanvasSet the title of the canvas.@NotNull Canvastitle(@Nullable net.kyori.adventure.text.Component title) Set the title of the canvas.
-
Constructor Details
-
Canvas
public Canvas()
-
-
Method Details
-
title
Set the title of the canvas.- Parameters:
title- the title- Returns:
- the canvas
-
title
Set the title of the canvas.- Parameters:
title- the title- Returns:
- the canvas
-
title
Set the title of the canvas.- Parameters:
title- the title- Returns:
- the canvas
-
selfInventory
@NotNull public @NotNull Canvas.ClickContext selfInventory(@Nullable @Nullable Canvas.SelfInventoryClick selfInventory) Set the self-inventory action. This action is called when the player clicks on the inventory.- Parameters:
selfInventory- the self-inventory action- Returns:
- the click context associated with the self inventory action
-
genericClick
@NotNull public @NotNull Canvas.ClickContext genericClick(@Nullable @Nullable Canvas.GenericClick genericClick) Set the generic click action. This action is called when the player clicks on the inventory.- Parameters:
genericClick- the generic click action- Returns:
- the click context associated with the generic click action
-
genericDrag
@NotNull public @NotNull Canvas.DragContext genericDrag(@Nullable @Nullable Canvas.GenericDrag genericDrag) Set the generic drag action. This action is called when the player drags on the inventory.- Parameters:
genericDrag- the generic drag action- Returns:
- the drag context associated with the generic drag action
-
closeInventory
@NotNull public @NotNull Canvas.ClickContext closeInventory(@Nullable @Nullable Canvas.CloseInventory closeInventory) Set the close inventory action. This action is called when the player closes the inventory.- Parameters:
closeInventory- the close inventory action- Returns:
- the canvas
-
button
@NotNull public @NotNull Canvas.ClickContext button(@NotNull @NotNull Button button, @Nullable @Nullable Canvas.ButtonClick buttonClick) Add a button to the canvas.- Parameters:
button- the buttonbuttonClick- the button click- Returns:
- the click context associated with the button
-
button
Add a button to the canvas.- Parameters:
button- the button- Returns:
- the canvas
-
decorate
Adds a new layer of decorating to the canvas.- Parameters:
decorator- the decorator- Returns:
- the canvas
- See Also:
-
removeDecorator
Removes a decorator from the canvas.- Parameters:
decorator- the decorator- Returns:
- the canvas
-
populate
Starts the population of the elements on the canvas.- Type Parameters:
T- the type of the elements- Parameters:
elements- the elements- Returns:
- the canvas
-
removeLastPopulator
Removes the last populator context.- Returns:
- the canvas
- Throws:
NoSuchElementException- if there is no populator context
-
removeFirstPopulator
Removes the first populator context.- Returns:
- the canvas
- Throws:
NoSuchElementException- if there is no populator context
-
populatorList
Gets list of all populator contexts.- Returns:
- the list of all populator contexts
-
getInventory
@NotNull public @NotNull org.bukkit.inventory.Inventory getInventory()- Specified by:
getInventoryin interfaceorg.bukkit.inventory.InventoryHolder
-
clear
public void clear()Clears the canvas. -
registerDynamicContent
@NotNull public <T> @NotNull Canvas registerDynamicContent(@NotNull @NotNull Class<T> type, @NotNull @NotNull Supplier<T> supplier) Registers a dynamic content supplier.- Type Parameters:
T- the type of the content- Parameters:
type- Type of the contentsupplier- Supplier of the content- Returns:
- The canvas
-
dynamicContent
Gets the dynamic content supplier.- Type Parameters:
T- the type of the content- Parameters:
type- Type of the content- Returns:
- The supplier
-