Package xyz.xenondevs.invui.item.impl
Class CycleItem
java.lang.Object
xyz.xenondevs.invui.item.impl.AbstractItem
xyz.xenondevs.invui.item.impl.CycleItem
- All Implemented Interfaces:
Item
An
Item that cycles through a predefined array of ItemProviders when clicked.-
Constructor Summary
ConstructorsConstructorDescriptionCycleItem(int startState, @NotNull ItemProvider... states) CycleItem(@NotNull ItemProvider... states) -
Method Summary
Modifier and TypeMethodDescriptionvoidcycle(boolean forward) Gets theItemProvider.intgetState()voidhandleClick(@NotNull org.bukkit.event.inventory.ClickType clickType, @NotNull org.bukkit.entity.Player player, @NotNull org.bukkit.event.inventory.InventoryClickEvent event) A method called if theItemStackassociated to thisItemhas been clicked by a player.protected voidhandleStateChange(@Nullable org.bukkit.entity.Player player, int state) static CycleItemwithStateChangeHandler(BiConsumer<org.bukkit.entity.Player, Integer> stateChangeHandler, int startState, @NotNull ItemProvider... states) static CycleItemwithStateChangeHandler(BiConsumer<org.bukkit.entity.Player, Integer> stateChangeHandler, @NotNull ItemProvider... states) Methods inherited from class xyz.xenondevs.invui.item.impl.AbstractItem
addWindow, getWindows, notifyWindows, removeWindowMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface xyz.xenondevs.invui.item.Item
getItemProvider
-
Constructor Details
-
CycleItem
-
CycleItem
-
-
Method Details
-
withStateChangeHandler
public static CycleItem withStateChangeHandler(BiConsumer<org.bukkit.entity.Player, Integer> stateChangeHandler, @NotNull @NotNull ItemProvider... states) -
withStateChangeHandler
public static CycleItem withStateChangeHandler(BiConsumer<org.bukkit.entity.Player, Integer> stateChangeHandler, int startState, @NotNull @NotNull ItemProvider... states) -
getItemProvider
Description copied from interface:ItemGets theItemProvider. This method gets called every time aWindowis notified (Item.notifyWindows()).- Returns:
- The
ItemProvider
-
handleClick
public void handleClick(@NotNull @NotNull org.bukkit.event.inventory.ClickType clickType, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent event) Description copied from interface:ItemA method called if theItemStackassociated to thisItemhas been clicked by a player.- Parameters:
clickType- TheClickTypethePlayerperformed.player- ThePlayerwho clicked on theItemStack.event- TheInventoryClickEventassociated with this click.
-
cycle
public void cycle(boolean forward) -
handleStateChange
protected void handleStateChange(@Nullable @Nullable org.bukkit.entity.Player player, int state) -
getState
public int getState()
-