Class ScrollableItems
java.lang.Object
de.marcely.bedwars.tools.gui.ScrollableItems
-
Constructor Summary
ConstructorsConstructorDescriptionScrollableItems(ChestGUI gui, int minX, int maxX, int minY, int maxY) Construct a new element. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an item that shall be shown.voidDisables automatic redraw, afterdraw()has been called.voiddraw()Redraws the whole area.intGet the current page we are looking at.getItems()Get all items that shall be shown.intGet the maximum amount of pages the player can scroll through.voidsetCurrentPage(int page) Set the current page we are looking at.voidsetDefaultPageChangeItems(@Nullable Player player) Define default items (arrows with text) for the page change items.voidReplaces all existing items with new ones.voidSet the item that represents the button to go forward a page.voidsetPageChangeListener(@Nullable Consumer<Player> listener) Set the listener that gets called whenever a player changes the page.voidSet the item that represents the button to go back a page.
-
Constructor Details
-
ScrollableItems
Construct a new element.- Parameters:
gui- The GUI to later draw the items onminX- The minimum x slot at which the first item shall be atmaxX- The maximum x slot at which the last item of the row shall be atminY- The minimum y slot at which the first item of the column shall be atmaxY- The maximum y slot at which the last item shall be at- Throws:
IllegalStateException- if the area wouldn't fit inside a ChestGUIIllegalStateException- if min is greater than maxIllegalStateException- if the available area is 2 or smaller
-
-
Method Details
-
addItem
-
setItems
-
getItems
-
getMaxPages
public int getMaxPages()Get the maximum amount of pages the player can scroll through.- Returns:
- Amount of existing pages, minimum is always 1
-
setCurrentPage
public void setCurrentPage(int page) Set the current page we are looking at.Automatically draws in case
draw()has been called before.- Parameters:
page- The new current page. Starts at 0
-
getCurrentPage
public int getCurrentPage()Get the current page we are looking at.- Returns:
- The current page. Starts at 0
-
setPrevPageItem
-
setNextPageItem
-
setPageChangeListener
Set the listener that gets called whenever a player changes the page.May be useful for e.g. playing sounds.
By default, the "setupgui-click-switch" sound is played from sounds.yml.
- Parameters:
listener- The new listener, may benull
-
setDefaultPageChangeItems
Define default items (arrows with text) for the page change items.- Parameters:
player- The player whose language shall be used for the item's name. May benull
-
draw
public void draw()Redraws the whole area.You usually only have to call this once after adding all items and configuring it properly.
- Throws:
IllegalStateException- If no item for the prev / next page buttons has been set
-
disableRedraw
-