Package xyz.xenondevs.invui.gui
Interface Gui
- All Known Implementing Classes:
AbstractGui,AbstractPagedGui,AbstractScrollGui,AbstractTabGui
public interface Gui
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 Inventory'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.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceGui.Builder<G extends Gui,S extends Gui.Builder<G, S>> AGuibuilder. -
Method Summary
Modifier and TypeMethodDescriptionvoidAddsItemsto the gui.voidaddSlotElements(@NotNull SlotElement... slotElements) AddsSlotElementsto theGui.voidapplyStructure(@NotNull Structure structure) voidCancels the runningAnimationif there is one.voidstatic @NotNull Guiempty(int width, int height) Creates a new emptyGui.voidvoidvoidfillBorders(@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 Inventory inventory, boolean replaceExisting) voidfillRectangle(int x, int y, int width, @NotNull Inventory inventory, @Nullable ItemProvider background, boolean replaceExisting) voidfillRectangle(int x, int y, @NotNull Gui gui, boolean replaceExisting) voidFills one row with a specificItem@NotNull Set<@NotNull org.bukkit.entity.Player> Finds allPlayersthat are currently seeing thisWindow.@Nullable ItemProviderGets theItemProviderthat will be used if nothing else is placed on a slot.intGets the height of theGui@Nullable ItemgetItem(int index) Gets theItemplaced on that slot.@Nullable ItemgetItem(int x, int y) Gets theItemon these coordinates.intgetSize()Gets the size of theGui.@Nullable SlotElementgetSlotElement(int index) Gets theSlotElementplaced on that slot.@Nullable SlotElementgetSlotElement(int x, int y) Gets theSlotElementon these coordinates.@Nullable SlotElement @NotNull []Gets allSlotElementsof thisGuiin an Array.intgetWidth()Gets the width of theGuibooleanhasSlotElement(int index) Gets if there is aSlotElementplaced on that slot.booleanhasSlotElement(int x, int y) Gets if there is aSlotElementon these coordinates.booleanisFrozen()Gets if theGuiis frozen.booleanGets whether it is possible to shift-click items into and cursor collect items from allInventoryslots of partially obscured embeddedInventories.static Gui.Builder.Normalnormal()Creates a newGui Builderfor a normalGui.static @NotNull Guinormal(@NotNull Consumer<@NotNull Gui.Builder.Normal> consumer) static @NotNull GuiCreates a new emptyGui.voidplayAnimation(@NotNull Animation animation, @Nullable Predicate<@NotNull SlotElement> filter) Plays anAnimation.voidremove(int index) Remove theItemwhich are placed on these slots.voidremove(int x, int y) Removes anItemby its coordinates.voidsetBackground(@Nullable ItemProvider itemProvider) Sets theItemProviderthat will be used if nothing else is placed on a slot.voidsetFrozen(boolean frozen) Freezes or unfreezes theGui.voidsetIgnoreObscuredInventorySlots(boolean ignoreObscuredInventorySlots) Configures whether it is possible to shift-click items into and cursor collect items from allInventoryslots of partially obscured embeddedInventories.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.
-
Method Details
-
normal
Creates a newGui Builderfor a normalGui.- Returns:
- The new
Gui Builder.
-
normal
@NotNull static @NotNull Gui normal(@NotNull @NotNull Consumer<@NotNull Gui.Builder.Normal> consumer) - Parameters:
consumer- TheConsumerto configure theGui Builder.- Returns:
- The created
Gui.
-
empty
Creates a new emptyGui. -
of
Creates a new emptyGui. -
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.
-
addSlotElements
AddsSlotElementsto theGui.- Parameters:
slotElements- TheSlotElementsto add.
-
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
Gets allSlotElementsof thisGuiin an Array.- Returns:
- All
SlotElementsof thisGui
-
setItem
Sets theItemon these coordinates. -
setItem
Sets theItemon that slot -
addItems
AddsItemsto the gui.- Parameters:
items- TheItemsthat should be added to the gui
-
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
-
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 theItemsthat should be removed
-
applyStructure
- Parameters:
structure- The structure
-
findAllWindows
-
findAllCurrentViewers
Finds allPlayersthat are currently seeing thisWindow.- Returns:
- The list of
Playersthat are currently seeing thisWindow
-
closeForAllViewers
void closeForAllViewers()Closes the openInventoryfor all viewers ofWindowswhere thisGuiis displayed.If the
Windowsare not marked as "retain", they will be removed from theWindowManagerautomatically. -
playAnimation
void playAnimation(@NotNull @NotNull Animation animation, @Nullable @Nullable Predicate<@NotNull SlotElement> filter) Plays anAnimation.- Parameters:
animation- TheAnimationto play.filter- The filter that selects whichSlotElementsshould be animated.
-
cancelAnimation
void cancelAnimation()Cancels the runningAnimationif there is one. -
setFrozen
void setFrozen(boolean frozen) - Parameters:
frozen- If theGuishould be frozen or not.
-
isFrozen
boolean isFrozen()Gets if theGuiis frozen.- Returns:
- If the
Guiis frozen.
-
setIgnoreObscuredInventorySlots
void setIgnoreObscuredInventorySlots(boolean ignoreObscuredInventorySlots) Configures whether it is possible to shift-click items into and cursor collect items from allInventoryslots of partially obscured embeddedInventories.Defaults to true.
- Parameters:
ignoreObscuredInventorySlots- Whether obscuredInventoryslots should be ignored when shift-clicking and collecting to the cursor.
-
isIgnoreObscuredInventorySlots
boolean isIgnoreObscuredInventorySlots()Gets whether it is possible to shift-click items into and cursor collect items from allInventoryslots of partially obscured embeddedInventories.- Returns:
- Whether obscured
Inventoryslots are ignored when shift-clicking and collecting to the cursor.
-
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 existingItemsshould 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 existingSlotElementsshould be replaced.
-
fillRectangle
void fillRectangle(int x, int y, int width, @NotNull @NotNull Inventory inventory, boolean replaceExisting) - Parameters:
x- The x coordinate where the rectangle should starty- The y coordinate where the rectangle should startwidth- The line length of the rectangle.inventory- TheInventoryto be put into thisGui.replaceExisting- If existingSlotElementsshould be replaced.
-
fillRectangle
void fillRectangle(int x, int y, int width, @NotNull @NotNull Inventory inventory, @Nullable @Nullable ItemProvider background, boolean replaceExisting) - Parameters:
x- The x coordinate where the rectangle should starty- The y coordinate where the rectangle should startwidth- The line length of the rectangle.inventory- TheInventoryto be put into thisGui.background- TheItemProviderfor empty slots of theInventoryreplaceExisting- If existingSlotElementsshould be replaced.
-