Package de.studiocode.invui.gui
Interface GUI
- All Superinterfaces:
GUIParent
- All Known Implementing Classes:
BaseGUI,PagedGUI,ScrollGUI,SimpleGUI,SimplePagedItemsGUI,SimplePagedNestedGUI,SimpleScrollItemsGUI,SimpleScrollNestedGUI,SimpleScrollVIGUI,SimpleTabGUI,TabGUI
A GUI is a container for width * height
Each
A
In order to create an
SlotElements.Each
SlotElement can either be an Item,
a reference to a VirtualInventory's or another GUI's
slot index.A
GUI is not an Inventory, nor does
it access one. It just contains SlotElements and their positions.In order to create an
Inventory which is visible
to players, you will need to use a Window.-
Method Summary
Modifier and TypeMethodDescriptionvoidAddsItems to the gui.voidvoidapplyStructure(Structure structure) voidCancels the runningAnimationif there is one.voidvoidvoidvoidfillBorders(@Nullable Item item, boolean replaceExisting) voidfillColumn(int column, @Nullable Item item, boolean replaceExisting) Fills one column with a specificItemvoidfillRectangle(int x, int y, int width, int height, @Nullable Item item, boolean replaceExisting) voidfillRectangle(int x, int y, int width, @NotNull VirtualInventory virtualInventory, boolean replaceExisting) Fills a rectangle of aVirtualInventoryin thisGUI.voidfillRectangle(int x, int y, int width, @NotNull VirtualInventory virtualInventory, @Nullable ItemProvider background, boolean replaceExisting) Fills a rectangle of aVirtualInventoryin thisGUI.voidfillRectangle(int x, int y, @NotNull GUI gui, boolean replaceExisting) voidFills one row with a specificItemSet<org.bukkit.entity.Player>Finds allPlayers that are currently seeing thisWindow.Gets theItemProviderthat will be used if nothing else is placed on a slot.intGets the height of theGUIgetItem(int index) Gets theItemplaced on that slot.getItem(int x, int y) Gets theItemon these coordinates.Gets allGUIParents.intgetSize()Gets the size of theGUI.getSlotElement(int index) Gets theSlotElementplaced on that slot.getSlotElement(int x, int y) Gets theSlotElementon these coordinates.Gets allSlotElements of thisGUIin an Array.intgetWidth()Gets the width of theGUIvoidhandleClick(int slot, org.bukkit.entity.Player player, org.bukkit.event.inventory.ClickType clickType, org.bukkit.event.inventory.InventoryClickEvent event) A method called if a slot in theInventoryhas been clicked.booleanhandleItemDrag(UpdateReason updateReason, int slot, org.bukkit.inventory.ItemStack oldStack, org.bukkit.inventory.ItemStack newStack) A method called when anItemStackhas been dragged over theGUI.voidhandleItemShift(org.bukkit.event.inventory.InventoryClickEvent event) A method called when anItemStackhas been shift-clicked into thisGUI.booleanhasSlotElement(int index) Gets if there is aSlotElementplaced on that slot.booleanhasSlotElement(int x, int y) Gets if there is aSlotElementon these coordinates.voidplayAnimation(@NotNull Animation animation, @Nullable Predicate<SlotElement> filter) Plays anAnimation.voidremove(int index) Remove theItemwhich are placed on these slots.voidremove(int x, int y) Removes anItemby its coordinates.voidremoveParent(@NotNull GUIParent parent) voidsetBackground(@Nullable ItemProvider itemProvider) Sets theItemProviderthat will be used if nothing else is placed on a slot.voidSets theItemon these coordinates.voidSets theItemon that slotvoidsetSlotElement(int x, int y, @Nullable SlotElement slotElement) Sets theSlotElementon these coordinates.voidsetSlotElement(int index, @Nullable SlotElement slotElement) Sets theSlotElementon these coordinates.Methods inherited from interface de.studiocode.invui.gui.GUIParent
handleSlotElementUpdate
-
Method Details
-
getSize
int getSize()Gets the size of theGUI.- Returns:
- The size of the gui.
-
getWidth
int getWidth()Gets the width of theGUI- Returns:
- The width of the
GUI
-
getHeight
int getHeight()Gets the height of theGUI- Returns:
- The height of the
GUI
-
setSlotElement
Sets theSlotElementon these coordinates. If you need to set anItem, please usesetItem(int, int, Item)instead.- Parameters:
x- The x coordinatey- The y coordinateslotElement- TheSlotElementto be placed there.
-
setSlotElement
Sets theSlotElementon these coordinates. If you need to set anItem, please usesetItem(int, Item)instead.- Parameters:
index- The slot indexslotElement- TheSlotElementto be placed there.
-
getSlotElement
Gets theSlotElementon these coordinates.- Parameters:
x- The x coordinatey- The y coordinate- Returns:
- The
SlotElementplaced there
-
getSlotElement
Gets theSlotElementplaced on that slot.- Parameters:
index- The slot index- Returns:
- The
SlotElementplaced on that slot
-
hasSlotElement
boolean hasSlotElement(int x, int y) Gets if there is aSlotElementon these coordinates.- Parameters:
x- The x coordinatey- The y coordinate- Returns:
- If there is a
SlotElementplaced there
-
hasSlotElement
boolean hasSlotElement(int index) Gets if there is aSlotElementplaced on that slot.- Parameters:
index- The slot index- Returns:
- If there is a
SlotElementplaced there
-
getSlotElements
SlotElement[] getSlotElements()Gets allSlotElements of thisGUIin an Array.- Returns:
- All
SlotElements of thisGUI
-
setItem
Sets theItemon these coordinates. -
setItem
Sets theItemon that slot -
getItem
Gets theItemon these coordinates.- Parameters:
x- The x coordinatey- The y coordinate- Returns:
- The
Itemwhich is placed on that slot or null if there isn't one
-
getItem
Gets theItemplaced on that slot.- Parameters:
index- The slot index- Returns:
- The
Itemwhich is placed on that slot or null if there isn't one
-
addItems
AddsItems to the gui.- Parameters:
items- TheItems that should be added to the gui
-
getBackground
ItemProvider getBackground()Gets theItemProviderthat will be used if nothing else is placed on a slot.- Returns:
- The
ItemProvider
-
setBackground
Sets theItemProviderthat will be used if nothing else is placed on a slot.- Parameters:
itemProvider- TheItemProvider
-
remove
void remove(int x, int y) Removes anItemby its coordinates.- Parameters:
x- The x coordinatey- The y coordinate
-
remove
void remove(int index) Remove theItemwhich are placed on these slots.- Parameters:
index- The slot index of theItems that should be removed
-
applyStructure
- Parameters:
structure- The structure
-
handleClick
void handleClick(int slot, org.bukkit.entity.Player player, org.bukkit.event.inventory.ClickType clickType, org.bukkit.event.inventory.InventoryClickEvent event) A method called if a slot in theInventoryhas been clicked.- Parameters:
slot- The slot that has been clickedplayer- ThePlayerthat clickedclickType- TheClickTypeevent- TheInventoryClickEvent
-
handleItemShift
void handleItemShift(org.bukkit.event.inventory.InventoryClickEvent event) A method called when anItemStackhas been shift-clicked into thisGUI.- Parameters:
event- TheInventoryClickEventassociated with this action
-
handleItemDrag
boolean handleItemDrag(UpdateReason updateReason, int slot, org.bukkit.inventory.ItemStack oldStack, org.bukkit.inventory.ItemStack newStack) A method called when anItemStackhas been dragged over theGUI.- Parameters:
updateReason- The reason for this item update.slot- The slot indexoldStack- TheItemStackthat was previously on that slotnewStack- The newItemStackthat would be there if the action isn't cancelled- Returns:
- If the action has been cancelled
-
addParent
- Parameters:
parent- TheGUIParentto add
-
removeParent
- Parameters:
parent- TheGUIParentto remove
-
getParents
Gets allGUIParents. -
findAllWindows
-
findAllCurrentViewers
Set<org.bukkit.entity.Player> findAllCurrentViewers()Finds allPlayers that are currently seeing thisWindow.- Returns:
- The list of
Players that are currently seeing thisWindow
-
closeForAllViewers
void closeForAllViewers()Closes the openInventoryfor all viewers ofWindows where thisGUIis displayed. Does not actually call theWindow.close(boolean)method, which will be indirectly invoked by theInventoryCloseEventif theWindowis set to close on that event. -
playAnimation
void playAnimation(@NotNull @NotNull Animation animation, @Nullable @Nullable Predicate<SlotElement> filter) Plays anAnimation.- Parameters:
animation- TheAnimationto play.filter- The filter that selects whichSlotElements should be animated.
-
cancelAnimation
void cancelAnimation()Cancels the runningAnimationif there is one. -
fill
-
fill
-
fillRow
Fills one row with a specificItem -
fillColumn
Fills one column with a specificItem -
fillBorders
-
fillRectangle
void fillRectangle(int x, int y, int width, int height, @Nullable @Nullable Item item, boolean replaceExisting) - Parameters:
x- The x coordinate where the rectangle should start.y- The y coordinate where the rectangle should start.width- The width of the rectangle.height- The height of the rectangleitem- TheItemthat should be used or null to remove an existing item.replaceExisting- If existingItems should be replaced.
-
fillRectangle
- Parameters:
x- The x coordinate where the rectangle should starty- The y coordinate where the rectangle should startgui- TheGUIto be put into thisGUIreplaceExisting- If existingSlotElements should be replaced.
-
fillRectangle
void fillRectangle(int x, int y, int width, @NotNull @NotNull VirtualInventory virtualInventory, boolean replaceExisting) Fills a rectangle of aVirtualInventoryin thisGUI.- Parameters:
x- The x coordinate where the rectangle should starty- The y coordinate where the rectangle should startwidth- The line length of the rectangle. (VirtualInventory does not define a width)virtualInventory- TheVirtualInventoryto be put into thisGUI.replaceExisting- If existingSlotElements should be replaced.
-
fillRectangle
void fillRectangle(int x, int y, int width, @NotNull @NotNull VirtualInventory virtualInventory, @Nullable @Nullable ItemProvider background, boolean replaceExisting) Fills a rectangle of aVirtualInventoryin thisGUI.- Parameters:
x- The x coordinate where the rectangle should starty- The y coordinate where the rectangle should startwidth- The line length of the rectangle. (VirtualInventory does not define a width)virtualInventory- TheVirtualInventoryto be put into thisGUI.background- TheItemProviderfor empty slots of theVirtualInventoryreplaceExisting- If existingSlotElements should be replaced.
-