Class Button

java.lang.Object
com.marcusslover.plus.lib.item.Button

public class Button extends Object
Represents a button in a menu. Buttons are used to detect clicks and to display items.
  • Constructor Details

    • Button

      public Button()
  • Method Details

    • create

      @NotNull public static @NotNull Button create(int x, int y)
      Creates a button with the given coordinates.
      Parameters:
      x - The x coordinate
      y - The y coordinate
      Returns:
      The button
    • create

      @Deprecated(forRemoval=false) @NotNull public static @NotNull Button create(int x, int y, @Nullable @Nullable Item item)
      Deprecated.
      Creates a button with the given coordinates. Deprecated, use dynamically created items instead.
      Parameters:
      x - The x coordinate
      y - The y coordinate
      item - The item
      Returns:
      The button
    • create

      @NotNull public static @NotNull Button create(int x, int y, @NotNull @NotNull Button.ItemFactory item)
      Creates a button with the given coordinates.
      Parameters:
      x - The x coordinate
      y - The y coordinate
      item - The item factory
      Returns:
      The button
      Since:
      4.0.10
    • create

      @NotNull public static @NotNull Button create(int slot)
      Creates a button with the given slot.
      Parameters:
      slot - The slot
      Returns:
      The button
    • create

      @Deprecated(forRemoval=false) @NotNull public static @NotNull Button create(int slot, @Nullable @Nullable Item item)
      Deprecated.
      Creates a button with the given slot. Deprecated, use dynamically created items instead.
      Parameters:
      slot - The slot
      item - The item
      Returns:
      The button
    • create

      @NotNull public static @NotNull Button create(int slot, @NotNull @NotNull Button.ItemFactory item)
      Creates a button with the given slot.
      Parameters:
      slot - The slot
      item - The item factory
      Returns:
      The button
      Since:
      4.0.10
    • create

      @NotNull public static @NotNull Button create(int min_or_x, int max_or_y, boolean rawSlot)
      Creates a button with the given slots.
      Parameters:
      min_or_x - The minimum slot or minimum x coordinate
      max_or_y - The maximum slot or maximum x coordinate
      rawSlot - True if the slots are raw slots (0-53) or false if they are x and y coordinates.
      Returns:
      The button
    • create

      @NotNull public static @NotNull Button create(int x1, int y1, int x2, int y2)
      Creates a button with the given coordinates. Works like create(int, int) but with a region.
      Parameters:
      x1 - The minimum x coordinate
      y1 - The minimum y coordinate
      x2 - The maximum x coordinate
      y2 - The maximum y coordinate
      Returns:
      The button
    • transformY

      public static int transformY(int slot)
      Transforms a slot to a y coordinate.
      Parameters:
      slot - The slot
      Returns:
      The y coordinate
    • transformX

      public static int transformX(int slot)
      Transforms a slot to a x coordinate.
      Parameters:
      slot - The slot
      Returns:
      The x coordinate
    • transformSlot

      public static int transformSlot(int y, int x)
      Transforms a y and x coordinate to a slot.
      Parameters:
      y - The y coordinate
      x - The x coordinate
      Returns:
      The slot
    • setItem

      public Button setItem(@Nullable @Nullable Item item)
    • item

      public Button item(@Nullable @Nullable Item item)
    • item

      public Button item(@Nullable @Nullable Button.ItemFactory item)
    • slot

      @NotNull public @NotNull Button slot(int slot)
    • slot

      @NotNull public @NotNull Button slot(int x, int y)
    • slot

      @NotNull public @NotNull Button slot(int min_or_x, int max_or_y, boolean rawSlot)
    • slot

      @NotNull public @NotNull Button slot(int x1, int y1, int x2, int y2)
    • within

      public boolean within(int slot)
      Checks if the given slot is within the button.
      Parameters:
      slot - The slot
      Returns:
      True if the slot is within the button
    • toSlot

      public int toSlot()
      Converts the button to a slot. If the button is not a single point, -1 will be returned.
      Returns:
      The slot
    • toSlots

      @NotNull public @NotNull Set<Integer> toSlots()
      Converts the button to a set of slots. If the button is a single point, a set with only one slot will be returned.
      Returns:
      The slots