Record Class CompositeButton
- All Implemented Interfaces:
Button
Button
algebra: the composite IS-A Button and HAS-A list of Buttons.
Use this when one click should perform several independent effects without forcing the caller
to manually compose ClickActions — for example "play a sound + send a message + run
a command" can be three small ClickableButtons combined into one composite.
The composite owns its own item(); child items are ignored for rendering. This keeps
"what the user sees" decoupled from "what happens on click", which is the whole point of the
pattern in this context.
Caveats: children that mutate the view (notably TransformingButton, which
replaces the slot's button on click) compose unpredictably — the first such child wins and
subsequent children dispatch against a button that is no longer in the view. Prefer
StaticButton and ClickableButton children for predictable composition.
-
Constructor Summary
ConstructorsConstructorDescriptionCompositeButton(@NotNull org.bukkit.inventory.ItemStack item, @NotNull List<Button> children, @NotNull DataRegistry data) Creates an instance of aCompositeButtonrecord class. -
Method Summary
Modifier and TypeMethodDescriptionchildren()Returns the value of thechildrenrecord 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.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 CompositeButtonwithItem(@NotNull org.bukkit.inventory.ItemStack item)
-
Constructor Details
-
CompositeButton
public CompositeButton(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull List<Button> children, @NotNull @NotNull DataRegistry data) Creates an instance of aCompositeButtonrecord class.- Parameters:
item- the value for theitemrecord componentchildren- the value for thechildrenrecord componentdata- the value for thedatarecord component
-
-
Method Details
-
withItem
@NotNull public @NotNull CompositeButton 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. -
children
Returns the value of thechildrenrecord component.- Returns:
- the value of the
childrenrecord component
-
data
Returns the value of thedatarecord component.
-