Package studio.mevera.lotus.api.button
Record Class SpanningButton
java.lang.Object
java.lang.Record
studio.mevera.lotus.api.button.SpanningButton
- All Implemented Interfaces:
Button
public record SpanningButton(@NotNull org.bukkit.inventory.ItemStack item, @NotNull Set<Slot> footprint, @NotNull ClickAction action, @NotNull DataRegistry data)
extends Record
implements Button
A single logical button whose visual presence and click target span multiple slots — typically
used for banners, multi-cell icons, region selectors or "tile" art that should read as one
element to the user.
The footprint() is the immutable set of slots this button claims. Placement is most
conveniently done via ContentEditor.placeSpanning(SpanningButton),
which writes the same instance to every slot in the footprint. Because the Content
map is keyed by Slot, every footprint slot resolves back to this same instance, and
Bukkit will render item() in each one.
On click, action() fires once per click event regardless of which slot in the
footprint was clicked. The originating slot remains available via
InventoryClickEvent.getSlot() should the action wish to discriminate.
Lifecycle note: removing a spanning button should be done by clearing every slot in its footprint — clearing only one leaves the remainder visible but orphaned.
-
Constructor Summary
ConstructorsConstructorDescriptionSpanningButton(@NotNull org.bukkit.inventory.ItemStack item, @NotNull Set<Slot> footprint, @NotNull ClickAction action, @NotNull DataRegistry data) Creates an instance of aSpanningButtonrecord class. -
Method Summary
Modifier and TypeMethodDescription@NotNull ClickActionaction()Returns the value of theactionrecord component.@NotNull DataRegistrydata()Returns the value of thedatarecord component.voiddispatch(@NotNull MenuView<?, ?> view, @NotNull org.bukkit.event.inventory.InventoryClickEvent event) final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefootprintrecord component.final inthashCode()Returns a hash code value for this object.@NotNull org.bukkit.inventory.ItemStackitem()Returns the value of theitemrecord component.final StringtoString()Returns a string representation of this record class.@NotNull SpanningButtonwithItem(@NotNull org.bukkit.inventory.ItemStack item)
-
Constructor Details
-
SpanningButton
public SpanningButton(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull Set<Slot> footprint, @NotNull @NotNull ClickAction action, @NotNull @NotNull DataRegistry data) Creates an instance of aSpanningButtonrecord class.- Parameters:
item- the value for theitemrecord componentfootprint- the value for thefootprintrecord componentaction- the value for theactionrecord componentdata- the value for thedatarecord component
-
-
Method Details
-
withItem
@NotNull public @NotNull SpanningButton withItem(@NotNull @NotNull org.bukkit.inventory.ItemStack item) -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
item
@NotNull public @NotNull org.bukkit.inventory.ItemStack item()Returns the value of theitemrecord component. -
footprint
Returns the value of thefootprintrecord component.- Returns:
- the value of the
footprintrecord component
-
action
Returns the value of theactionrecord component.- Returns:
- the value of the
actionrecord component
-
data
Returns the value of thedatarecord component.
-