Class Canvas

java.lang.Object
com.marcusslover.plus.lib.item.Canvas
All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder

public class Canvas extends Object implements org.bukkit.inventory.InventoryHolder
A canvas is a representation of a menu. It is used to customize the menu layout.
  • Constructor Details

    • Canvas

      public Canvas()
  • Method Details

    • title

      @NotNull public @NotNull Canvas title(@Nullable @Nullable net.kyori.adventure.text.Component title)
      Set the title of the canvas.
      Parameters:
      title - the title
      Returns:
      the canvas
    • title

      @NotNull public @NotNull Canvas title(@Nullable @Nullable Text title)
      Set the title of the canvas.
      Parameters:
      title - the title
      Returns:
      the canvas
    • title

      @NotNull public @NotNull Canvas title(@Nullable @Nullable String 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
    • 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 button
      buttonClick - the button click
      Returns:
      the click context associated with the button
    • button

      @NotNull public @NotNull Canvas button(@NotNull @NotNull Button button)
      Add a button to the canvas.
      Parameters:
      button - the button
      Returns:
      the canvas
    • decorate

      @NotNull public @NotNull Canvas decorate(@NotNull @NotNull Canvas.ItemDecorator decorator)
      Adds a new layer of decorating to the canvas.
      Parameters:
      decorator - the decorator
      Returns:
      the canvas
      See Also:
    • removeDecorator

      @NotNull public @NotNull Canvas removeDecorator(@NotNull @NotNull Canvas.ItemDecorator decorator)
      Removes a decorator from the canvas.
      Parameters:
      decorator - the decorator
      Returns:
      the canvas
    • populate

      @NotNull public <T> @NotNull Canvas.PopulatorContext<T> populate(@NotNull @NotNull List<T> elements)
      Starts the population of the elements on the canvas.
      Type Parameters:
      T - the type of the elements
      Parameters:
      elements - the elements
      Returns:
      the canvas
    • removeLastPopulatorContext

      @NotNull public @NotNull Canvas removeLastPopulatorContext() throws NoSuchElementException
      Removes the last populator context.
      Returns:
      the canvas
      Throws:
      NoSuchElementException - if there is no populator context
    • removeFirstPopulatorContext

      @NotNull public @NotNull Canvas removeFirstPopulatorContext() throws NoSuchElementException
      Removes the first populator context.
      Returns:
      the canvas
      Throws:
      NoSuchElementException - if there is no populator context
    • populatorContexts

      @NotNull public @NotNull List<@NotNull Canvas.PopulatorContext<?>> populatorContexts()
      Gets list of all populator contexts.
      Returns:
      the list of all populator contexts
    • getInventory

      @NotNull public @NotNull org.bukkit.inventory.Inventory getInventory()
      Specified by:
      getInventory in interface org.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 content
      supplier - Supplier of the content
      Returns:
      The canvas
    • dynamicContent

      @NotNull public <T> @NotNull Supplier<@Nullable T> dynamicContent(@NotNull @NotNull Class<T> type)
      Gets the dynamic content supplier.
      Type Parameters:
      T - the type of the content
      Parameters:
      type - Type of the content
      Returns:
      The supplier