Package com.marcusslover.plus.lib.item
Class Button
java.lang.Object
com.marcusslover.plus.lib.item.Button
Represents a button in a menu.
Buttons are used to detect clicks and to display items.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a detectable area of a button.static interfaceRepresents a factory for creating items. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull Buttoncreate(int slot) Creates a button with the given slot.static @NotNull Buttoncreate(int x, int y) Creates a button with the given coordinates.static @NotNull Buttoncreate(int min_or_x, int max_or_y, boolean rawSlot) Creates a button with the given slots.static @NotNull Buttoncreate(int x1, int y1, int x2, int y2) Creates a button with the given coordinates.static @NotNull ButtonDeprecated.static @NotNull Buttoncreate(int x, int y, @NotNull Button.ItemFactory item) Creates a button with the given coordinates.static @NotNull ButtonDeprecated.static @NotNull Buttoncreate(int slot, @NotNull Button.ItemFactory item) Creates a button with the given slot.item(@Nullable Button.ItemFactory item) @NotNull Buttonslot(int slot) @NotNull Buttonslot(int x, int y) @NotNull Buttonslot(int min_or_x, int max_or_y, boolean rawSlot) @NotNull Buttonslot(int x1, int y1, int x2, int y2) inttoSlot()Converts the button to a slot.toSlots()Converts the button to a set of slots.static inttransformSlot(int y, int x) Transforms a y and x coordinate to a slot.static inttransformX(int slot) Transforms a slot to a x coordinate.static inttransformY(int slot) Transforms a slot to a y coordinate.booleanwithin(int slot) Checks if the given slot is within the button.
-
Constructor Details
-
Button
public Button()
-
-
Method Details
-
create
Creates a button with the given coordinates.- Parameters:
x- The x coordinatey- 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 coordinatey- The y coordinateitem- 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 coordinatey- The y coordinateitem- The item factory- Returns:
- The button
- Since:
- 4.0.10
-
create
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 slotitem- The item- Returns:
- The button
-
create
Creates a button with the given slot.- Parameters:
slot- The slotitem- The item factory- Returns:
- The button
- Since:
- 4.0.10
-
create
Creates a button with the given slots.- Parameters:
min_or_x- The minimum slot or minimum x coordinatemax_or_y- The maximum slot or maximum x coordinaterawSlot- True if the slots are raw slots (0-53) or false if they are x and y coordinates.- Returns:
- The button
-
create
Creates a button with the given coordinates. Works likecreate(int, int)but with a region.- Parameters:
x1- The minimum x coordinatey1- The minimum y coordinatex2- The maximum x coordinatey2- 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 coordinatex- The x coordinate- Returns:
- The slot
-
setItem
-
item
-
item
-
slot
-
slot
-
slot
-
slot
-
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
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
-