Package de.studiocode.invui.gui.impl
Class BaseGUI
java.lang.Object
de.studiocode.invui.gui.impl.BaseGUI
- All Implemented Interfaces:
Controllable,GUI,GUIParent
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAddsItems to the gui.voidvoidapplyStructure(Structure structure) voidCancels the runningAnimationif there is one.voidvoidvoidvoidvoidfillBorders(@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.protected LinkedHashSet<VirtualInventory>getAllVirtualInventories(VirtualInventory... ignored) 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 slotNumber, 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.voidhandleSlotElementUpdate(GUI child, int slotIndex) Called by the childGUIto report an update of aSlotElement.protected voidhandleVIDoubleClick(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack cursor) protected voidhandleVIDrop(boolean ctrl, org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked) protected voidhandleVIItemShift(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked) protected voidhandleVILeftClick(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked, org.bukkit.inventory.ItemStack cursor) protected voidhandleVINumberKey(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked) protected voidhandleVIOffHandKey(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked) protected voidhandleVIRightClick(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked, org.bukkit.inventory.ItemStack cursor) protected voidhandleVISlotElementClick(SlotElement.VISlotElement element, org.bukkit.event.inventory.InventoryClickEvent event) 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.protected intputIntoFirstVirtualInventory(UpdateReason updateReason, org.bukkit.inventory.ItemStack itemStack, VirtualInventory... ignored) voidremove(int index) Remove theItemwhich are placed on these slots.voidremove(int x, int y) Removes anItemby its coordinates.voidremoveParent(@NotNull GUIParent parent) voidsetBackground(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, SlotElement slotElement) Sets theSlotElementon these coordinates.voidsetSlotElement(int index, SlotElement slotElement) Sets theSlotElementon these coordinates.void
-
Constructor Details
-
BaseGUI
public BaseGUI(int width, int height)
-
-
Method Details
-
handleClick
public void handleClick(int slotNumber, org.bukkit.entity.Player player, org.bukkit.event.inventory.ClickType clickType, org.bukkit.event.inventory.InventoryClickEvent event) Description copied from interface:GUIA method called if a slot in theInventoryhas been clicked.- Specified by:
handleClickin interfaceGUI- Parameters:
slotNumber- The slot that has been clickedplayer- ThePlayerthat clickedclickType- TheClickTypeevent- TheInventoryClickEvent
-
handleVISlotElementClick
protected void handleVISlotElementClick(SlotElement.VISlotElement element, org.bukkit.event.inventory.InventoryClickEvent event) -
handleVILeftClick
protected void handleVILeftClick(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked, org.bukkit.inventory.ItemStack cursor) -
handleVIRightClick
protected void handleVIRightClick(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked, org.bukkit.inventory.ItemStack cursor) -
handleVIItemShift
protected void handleVIItemShift(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked) -
handleVINumberKey
protected void handleVINumberKey(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked) -
handleVIOffHandKey
protected void handleVIOffHandKey(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked) -
handleVIDrop
protected void handleVIDrop(boolean ctrl, org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked) -
handleVIDoubleClick
protected void handleVIDoubleClick(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack cursor) -
handleItemDrag
public boolean handleItemDrag(UpdateReason updateReason, int slot, org.bukkit.inventory.ItemStack oldStack, org.bukkit.inventory.ItemStack newStack) Description copied from interface:GUIA method called when anItemStackhas been dragged over theGUI.- Specified by:
handleItemDragin interfaceGUI- 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
-
handleItemShift
public void handleItemShift(org.bukkit.event.inventory.InventoryClickEvent event) Description copied from interface:GUIA method called when anItemStackhas been shift-clicked into thisGUI.- Specified by:
handleItemShiftin interfaceGUI- Parameters:
event- TheInventoryClickEventassociated with this action
-
putIntoFirstVirtualInventory
protected int putIntoFirstVirtualInventory(UpdateReason updateReason, org.bukkit.inventory.ItemStack itemStack, VirtualInventory... ignored) -
getAllVirtualInventories
-
handleSlotElementUpdate
Description copied from interface:GUIParentCalled by the childGUIto report an update of aSlotElement.- Specified by:
handleSlotElementUpdatein interfaceGUIParent- Parameters:
child- The childGUIwhoseSlotElementhas changedslotIndex- The slot index of the changedSlotElementin the childGUI
-
addParent
Description copied from interface:GUI -
removeParent
Description copied from interface:GUI- Specified by:
removeParentin interfaceGUI- Parameters:
parent- TheGUIParentto remove
-
getParents
Description copied from interface:GUIGets allGUIParents.- Specified by:
getParentsin interfaceGUI- Returns:
- The
GUIParents of thisGUI
-
findAllWindows
Description copied from interface:GUI- Specified by:
findAllWindowsin interfaceGUI- Returns:
- The list of
Windowthat show thisGUI
-
findAllCurrentViewers
Description copied from interface:GUIFinds allPlayers that are currently seeing thisWindow.- Specified by:
findAllCurrentViewersin interfaceGUI- Returns:
- The list of
Players that are currently seeing thisWindow
-
closeForAllViewers
public void closeForAllViewers()Description copied from interface:GUICloses 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.- Specified by:
closeForAllViewersin interfaceGUI
-
playAnimation
public void playAnimation(@NotNull @NotNull Animation animation, @Nullable @Nullable Predicate<SlotElement> filter) Description copied from interface:GUIPlays anAnimation.- Specified by:
playAnimationin interfaceGUI- Parameters:
animation- TheAnimationto play.filter- The filter that selects whichSlotElements should be animated.
-
cancelAnimation
public void cancelAnimation()Description copied from interface:GUICancels the runningAnimationif there is one.- Specified by:
cancelAnimationin interfaceGUI
-
updateControlItems
public void updateControlItems()- Specified by:
updateControlItemsin interfaceControllable
-
setSlotElement
Description copied from interface:GUISets theSlotElementon these coordinates. If you need to set anItem, please useGUI.setItem(int, Item)instead.- Specified by:
setSlotElementin interfaceGUI- Parameters:
index- The slot indexslotElement- TheSlotElementto be placed there.
-
getSlotElement
Description copied from interface:GUIGets theSlotElementplaced on that slot.- Specified by:
getSlotElementin interfaceGUI- Parameters:
index- The slot index- Returns:
- The
SlotElementplaced on that slot
-
hasSlotElement
public boolean hasSlotElement(int index) Description copied from interface:GUIGets if there is aSlotElementplaced on that slot.- Specified by:
hasSlotElementin interfaceGUI- Parameters:
index- The slot index- Returns:
- If there is a
SlotElementplaced there
-
getSlotElements
Description copied from interface:GUIGets allSlotElements of thisGUIin an Array.- Specified by:
getSlotElementsin interfaceGUI- Returns:
- All
SlotElements of thisGUI
-
setItem
Description copied from interface:GUISets theItemon that slot -
addItems
Description copied from interface:GUIAddsItems to the gui. -
getItem
Description copied from interface:GUIGets theItemplaced on that slot. -
getBackground
Description copied from interface:GUIGets theItemProviderthat will be used if nothing else is placed on a slot.- Specified by:
getBackgroundin interfaceGUI- Returns:
- The
ItemProvider
-
setBackground
Description copied from interface:GUISets theItemProviderthat will be used if nothing else is placed on a slot.- Specified by:
setBackgroundin interfaceGUI- Parameters:
itemProvider- TheItemProvider
-
remove
public void remove(int index) Description copied from interface:GUIRemove theItemwhich are placed on these slots. -
applyStructure
Description copied from interface:GUI- Specified by:
applyStructurein interfaceGUI- Parameters:
structure- The structure
-
getSize
public int getSize()Description copied from interface:GUIGets the size of theGUI. -
setSlotElement
Description copied from interface:GUISets theSlotElementon these coordinates. If you need to set anItem, please useGUI.setItem(int, int, Item)instead.- Specified by:
setSlotElementin interfaceGUI- Parameters:
x- The x coordinatey- The y coordinateslotElement- TheSlotElementto be placed there.
-
getSlotElement
Description copied from interface:GUIGets theSlotElementon these coordinates.- Specified by:
getSlotElementin interfaceGUI- Parameters:
x- The x coordinatey- The y coordinate- Returns:
- The
SlotElementplaced there
-
hasSlotElement
public boolean hasSlotElement(int x, int y) Description copied from interface:GUIGets if there is aSlotElementon these coordinates.- Specified by:
hasSlotElementin interfaceGUI- Parameters:
x- The x coordinatey- The y coordinate- Returns:
- If there is a
SlotElementplaced there
-
setItem
Description copied from interface:GUISets theItemon these coordinates. -
getItem
Description copied from interface:GUIGets theItemon these coordinates. -
remove
public void remove(int x, int y) Description copied from interface:GUIRemoves anItemby its coordinates. -
getWidth
public int getWidth()Description copied from interface:GUIGets the width of theGUI -
getHeight
public int getHeight()Description copied from interface:GUIGets the height of theGUI -
fill
-
fill
Description copied from interface:GUI -
fill
Description copied from interface:GUI -
fillRow
Description copied from interface:GUIFills one row with a specificItem -
fillColumn
Description copied from interface:GUIFills one column with a specificItem- Specified by:
fillColumnin interfaceGUI- Parameters:
column- The columnitem- TheItemthat should be used or null to remove an existing item.replaceExisting- If existingItems should be replaced.
-
fillBorders
Description copied from interface:GUI- Specified by:
fillBordersin interfaceGUI- Parameters:
item- TheItemthat should be used or null to remove an existing item.replaceExisting- If existingItems should be replaced.
-
fillRectangle
public void fillRectangle(int x, int y, int width, int height, @Nullable @Nullable Item item, boolean replaceExisting) Description copied from interface:GUI- Specified by:
fillRectanglein interfaceGUI- 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
Description copied from interface:GUI- Specified by:
fillRectanglein interfaceGUI- 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
public void fillRectangle(int x, int y, int width, @NotNull @NotNull VirtualInventory virtualInventory, boolean replaceExisting) Description copied from interface:GUIFills a rectangle of aVirtualInventoryin thisGUI.- Specified by:
fillRectanglein interfaceGUI- 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
public void fillRectangle(int x, int y, int width, @NotNull @NotNull VirtualInventory virtualInventory, @Nullable @Nullable ItemProvider background, boolean replaceExisting) Description copied from interface:GUIFills a rectangle of aVirtualInventoryin thisGUI.- Specified by:
fillRectanglein interfaceGUI- 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.
-