Class ToggleButton
java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
com.github.stefvanschie.inventoryframework.pane.component.ToggleButton
A button that toggles between an enabled and disabled state.
- Since:
- 0.5.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.github.stefvanschie.inventoryframework.pane.Pane
Pane.Priority
-
Field Summary
-
Constructor Summary
ConstructorDescriptionToggleButton
(int length, int height) ToggleButton
(int length, int height, boolean enabled) ToggleButton
(int length, int height, boolean enabled, @NotNull Plugin plugin) Creates a new toggle buttonToggleButton
(int x, int y, int length, int height) ToggleButton
(int x, int y, int length, int height, boolean enabled) ToggleButton
(int x, int y, int length, int height, boolean enabled, @NotNull Plugin plugin) Creates a new toggle buttonToggleButton
(int x, int y, int length, int height, @NotNull Pane.Priority priority) ToggleButton
(int x, int y, int length, int height, @NotNull Pane.Priority priority, boolean enabled) ToggleButton
(int x, int y, int length, int height, @NotNull Pane.Priority priority, boolean enabled, @NotNull Plugin plugin) Creates a new toggle buttonToggleButton
(int x, int y, int length, int height, @NotNull Pane.Priority priority, @NotNull Plugin plugin) Creates a new toggle buttonToggleButton
(int x, int y, int length, int height, @NotNull Plugin plugin) Creates a new toggle buttonToggleButton
(int length, int height, @NotNull Plugin plugin) Creates a new toggle buttonToggleButton
(@NotNull Slot slot, int length, int height) Creates a new toggle buttonToggleButton
(@NotNull Slot slot, int length, int height, boolean enabled) Creates a new toggle buttonToggleButton
(@NotNull Slot slot, int length, int height, boolean enabled, @NotNull Plugin plugin) Creates a new toggle buttonToggleButton
(@NotNull Slot slot, int length, int height, @NotNull Pane.Priority priority) Creates a new toggle buttonToggleButton
(@NotNull Slot slot, int length, int height, @NotNull Pane.Priority priority, boolean enabled) Creates a new toggle buttonToggleButton
(@NotNull Slot slot, int length, int height, @NotNull Pane.Priority priority, boolean enabled, @NotNull Plugin plugin) Creates a new toggle buttonToggleButton
(@NotNull Slot slot, int length, int height, @NotNull Pane.Priority priority, @NotNull Plugin plugin) Creates a new toggle buttonToggleButton
(@NotNull Slot slot, int length, int height, @NotNull Plugin plugin) Creates a new toggle button -
Method Summary
Modifier and TypeMethodDescriptionvoid
allowToggle
(boolean allowToggle) Sets whether this toggle button can be toggled.void
clear()
Clears the entire pane of any items/panes.boolean
click
(@NotNull Gui gui, @NotNull InventoryComponent inventoryComponent, @NotNull InventoryClickEvent event, int slot, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Called whenever there is being clicked on this pane@NotNull ToggleButton
copy()
Makes a copy of this pane and returns it.void
display
(@NotNull InventoryComponent inventoryComponent, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Has to set all the items in the right spot inside the inventory@NotNull Collection
<GuiItem> getItems()
Gets all the items in this pane and all underlying panes.@NotNull Collection
<Pane> getPanes()
Gets all the panes in this panes, including any child panes from other panes.boolean
Gets whether this toggle button is currently enabled or disabled.static @NotNull ToggleButton
Deprecated.static @NotNull ToggleButton
Loads a toggle button from an XML elementvoid
setDisabledItem
(@NotNull GuiItem item) Sets the item to use when the button is set to disabledvoid
setEnabledItem
(@NotNull GuiItem item) Sets the item to use when the button is set to enabledvoid
setHeight
(int height) Set the height of this panevoid
setLength
(int length) Set the length of this panevoid
toggle()
Toggles between the enabled and disabled statesMethods inherited from class com.github.stefvanschie.inventoryframework.pane.Pane
callOnClick, createBorder, createBorder, findMatchingItem, getHeight, getLength, getPriority, getSlot, getUUID, getX, getY, isVisible, load, loadItem, loadItem, matchesItem, registerProperty, setOnClick, setPriority, setSlot, setVisible, setX, setY
-
Constructor Details
-
ToggleButton
public ToggleButton(@NotNull @NotNull Slot slot, int length, int height, @NotNull @NotNull Pane.Priority priority, boolean enabled, @NotNull @NotNull Plugin plugin) Creates a new toggle button- Parameters:
slot
- the slotlength
- the lengthheight
- the heightpriority
- the priorityenabled
- whether the button should start in its enabled or disabled stateplugin
- the plugin that will be the owner of this button's items- Since:
- 0.10.8
- See Also:
-
ToggleButton
public ToggleButton(int x, int y, int length, int height, @NotNull @NotNull Pane.Priority priority, boolean enabled, @NotNull @NotNull Plugin plugin) Creates a new toggle button- Parameters:
x
- the x coordinatey
- the y coordinatelength
- the lengthheight
- the heightpriority
- the priorityenabled
- whether the button should start in its enabled or disabled stateplugin
- the plugin that will be the owner of this button's items- Since:
- 0.10.8
- See Also:
-
ToggleButton
public ToggleButton(@NotNull @NotNull Slot slot, int length, int height, @NotNull @NotNull Pane.Priority priority, @NotNull @NotNull Plugin plugin) Creates a new toggle button- Parameters:
slot
- the slotlength
- the lengthheight
- the heightpriority
- the priorityplugin
- the plugin that will be the owner of this button's items- Since:
- 0.10.8
- See Also:
-
ToggleButton
public ToggleButton(int x, int y, int length, int height, @NotNull @NotNull Pane.Priority priority, @NotNull @NotNull Plugin plugin) Creates a new toggle button- Parameters:
x
- the x coordinatey
- the y coordinatelength
- the lengthheight
- the heightpriority
- the priorityplugin
- the plugin that will be the owner of this button's items- Since:
- 0.10.8
- See Also:
-
ToggleButton
public ToggleButton(@NotNull @NotNull Slot slot, int length, int height, boolean enabled, @NotNull @NotNull Plugin plugin) Creates a new toggle button- Parameters:
slot
- the slotlength
- the lengthheight
- the heightenabled
- whether the button should start in its enabled or disabled stateplugin
- the plugin that will be the owner of this button's items- Since:
- 0.10.8
- See Also:
-
ToggleButton
public ToggleButton(int x, int y, int length, int height, boolean enabled, @NotNull @NotNull Plugin plugin) Creates a new toggle button- Parameters:
x
- the x coordinatey
- the y coordinatelength
- the lengthheight
- the heightenabled
- whether the button should start in its enabled or disabled stateplugin
- the plugin that will be the owner of this button's items- Since:
- 0.10.8
- See Also:
-
ToggleButton
public ToggleButton(@NotNull @NotNull Slot slot, int length, int height, @NotNull @NotNull Plugin plugin) Creates a new toggle button- Parameters:
slot
- the slotlength
- the lengthheight
- the heightplugin
- the plugin that will be the owner of this button's items- Since:
- 0.10.8
- See Also:
-
ToggleButton
Creates a new toggle button- Parameters:
x
- the x coordinatey
- the y coordinatelength
- the lengthheight
- the heightplugin
- the plugin that will be the owner of this button's items- Since:
- 0.10.8
- See Also:
-
ToggleButton
Creates a new toggle button- Parameters:
length
- the lengthheight
- the heightenabled
- whether the button should start in its enabled or disabled stateplugin
- the plugin that will be the owner of this button's items- Since:
- 0.10.8
- See Also:
-
ToggleButton
Creates a new toggle button- Parameters:
length
- the lengthheight
- the heightplugin
- the plugin that will be the owner of this button's items- Since:
- 0.10.8
- See Also:
-
ToggleButton
public ToggleButton(@NotNull @NotNull Slot slot, int length, int height, @NotNull @NotNull Pane.Priority priority, boolean enabled) Creates a new toggle button- Parameters:
slot
- the slotlength
- the lengthheight
- the heightpriority
- the priorityenabled
- whether the button should start in its enabled or disabled state- Since:
- 0.10.8
-
ToggleButton
public ToggleButton(int x, int y, int length, int height, @NotNull @NotNull Pane.Priority priority, boolean enabled) -
ToggleButton
public ToggleButton(@NotNull @NotNull Slot slot, int length, int height, @NotNull @NotNull Pane.Priority priority) Creates a new toggle button- Parameters:
slot
- the slotlength
- the lengthheight
- the heightpriority
- the priority- Since:
- 0.10.8
-
ToggleButton
-
ToggleButton
Creates a new toggle button- Parameters:
slot
- the slotlength
- the lengthheight
- the heightenabled
- whether the button should start in its enabled or disabled state- Since:
- 0.10.8
-
ToggleButton
public ToggleButton(int x, int y, int length, int height, boolean enabled) -
ToggleButton
Creates a new toggle button- Parameters:
slot
- the slotlength
- the lengthheight
- the height- Since:
- 0.10.8
-
ToggleButton
public ToggleButton(int x, int y, int length, int height) -
ToggleButton
public ToggleButton(int length, int height, boolean enabled) -
ToggleButton
public ToggleButton(int length, int height)
-
-
Method Details
-
display
public void display(@NotNull @NotNull InventoryComponent inventoryComponent, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Description copied from class:Pane
Has to set all the items in the right spot inside the inventory- Specified by:
display
in classPane
- Parameters:
inventoryComponent
- the inventory component in which the items should be displayedpaneOffsetX
- the pane's offset on the x axispaneOffsetY
- the pane's offset on the y axismaxLength
- the maximum length of the panemaxHeight
- the maximum height of the pane
-
click
public boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull InventoryComponent inventoryComponent, @NotNull @NotNull InventoryClickEvent event, int slot, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Description copied from class:Pane
Called whenever there is being clicked on this pane- Specified by:
click
in classPane
- Parameters:
gui
- the gui in which was clickedinventoryComponent
- the inventory component in which this pane residesevent
- the event that occurred while clicking on this itemslot
- the slot that was clicked inpaneOffsetX
- the pane's offset on the x axispaneOffsetY
- the pane's offset on the y axismaxLength
- the maximum length of the panemaxHeight
- the maximum height of the pane- Returns:
- whether the item was found or not
-
copy
Description copied from class:Pane
Makes a copy of this pane and returns it. This makes a deep copy of the pane. This entails that the underlying panes and/or items will be copied as well. The returned pane will never be reference equal to the current pane. -
setLength
public void setLength(int length) Description copied from class:Pane
Set the length of this pane -
setHeight
public void setHeight(int height) Description copied from class:Pane
Set the height of this pane -
setDisabledItem
Sets the item to use when the button is set to disabled- Parameters:
item
- the disabled item- Since:
- 0.5.0
-
setEnabledItem
Sets the item to use when the button is set to enabled- Parameters:
item
- the enabled item- Since:
- 0.5.0
-
getItems
Description copied from class:Pane
Gets all the items in this pane and all underlying panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.) -
getPanes
Description copied from class:Pane
Gets all the panes in this panes, including any child panes from other panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.) -
allowToggle
public void allowToggle(boolean allowToggle) Sets whether this toggle button can be toggled. This only prevents players from toggling the button and does not prevent toggling the button programmatically with methods such astoggle()
.- Parameters:
allowToggle
- whether this button can be toggled- Since:
- 0.10.8
-
isEnabled
@Contract(pure=true) public boolean isEnabled()Gets whether this toggle button is currently enabled or disabled.- Returns:
- whether the button is enabled or disabled
- Since:
- 0.9.6
-
toggle
public void toggle()Toggles between the enabled and disabled states- Since:
- 0.5.0
-
clear
public void clear()Description copied from class:Pane
Clears the entire pane of any items/panes. Underlying panes will not be cleared. -
load
@NotNull @Contract(pure=true) public static @NotNull ToggleButton load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element, @NotNull @NotNull Plugin plugin) Loads a toggle button from an XML element- Parameters:
instance
- the instance classelement
- the elementplugin
- the plugin that will be the owner of the underlying items- Returns:
- the toggle button
- Since:
- 0.10.8
-
load
@NotNull @Contract(pure=true) @Deprecated public static @NotNull ToggleButton load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element) Deprecated.this method is no longer used internally and has been superseded byload(Object, Element, Plugin)
Loads a toggle button from an XML element- Parameters:
instance
- the instance classelement
- the element- Returns:
- the toggle button
- Since:
- 0.5.0
-
load(Object, Element, Plugin)