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
Modifier and TypeInterfaceDescriptionstatic interface
Gui.Builder<G extends Gui,
S extends Gui.Builder<G, S>> AGui
builder. -
Method Summary
Modifier and TypeMethodDescriptionvoid
AddsItems
to the gui.void
addSlotElements
(@NotNull SlotElement... slotElements) AddsSlotElements
to theGui
.void
applyStructure
(@NotNull Structure structure) void
Cancels the runningAnimation
if there is one.void
static @NotNull Gui
empty
(int width, int height) Creates a new emptyGui
.void
void
void
fillBorders
(@Nullable Item item, boolean replaceExisting) void
fillColumn
(int column, @Nullable Item item, boolean replaceExisting) Fills one column with a specificItem
void
fillRectangle
(int x, int y, int width, int height, @Nullable Item item, boolean replaceExisting) void
fillRectangle
(int x, int y, int width, @NotNull Inventory inventory, boolean replaceExisting) void
fillRectangle
(int x, int y, int width, @NotNull Inventory inventory, @Nullable ItemProvider background, boolean replaceExisting) void
fillRectangle
(int x, int y, @NotNull Gui gui, boolean replaceExisting) void
Fills one row with a specificItem
@NotNull Set
<@NotNull org.bukkit.entity.Player> Finds allPlayers
that are currently seeing thisWindow
.@Nullable ItemProvider
Gets theItemProvider
that will be used if nothing else is placed on a slot.int
Gets the height of theGui
@Nullable Item
getItem
(int index) Gets theItem
placed on that slot.@Nullable Item
getItem
(int x, int y) Gets theItem
on these coordinates.int
getSize()
Gets the size of theGui
.@Nullable SlotElement
getSlotElement
(int index) Gets theSlotElement
placed on that slot.@Nullable SlotElement
getSlotElement
(int x, int y) Gets theSlotElement
on these coordinates.@Nullable SlotElement @NotNull []
Gets allSlotElements
of thisGui
in an Array.int
getWidth()
Gets the width of theGui
boolean
hasSlotElement
(int index) Gets if there is aSlotElement
placed on that slot.boolean
hasSlotElement
(int x, int y) Gets if there is aSlotElement
on these coordinates.boolean
isFrozen()
Gets if theGui
is frozen.boolean
Gets whether it is possible to shift-click items into and cursor collect items from allInventory
slots of partially obscured embeddedInventories
.static Gui.Builder.Normal
normal()
Creates a newGui Builder
for a normalGui
.static @NotNull Gui
normal
(@NotNull Consumer<@NotNull Gui.Builder.Normal> consumer) static @NotNull Gui
Creates a new emptyGui
.void
playAnimation
(@NotNull Animation animation, @Nullable Predicate<@NotNull SlotElement> filter) Plays anAnimation
.void
remove
(int index) Remove theItem
which are placed on these slots.void
remove
(int x, int y) Removes anItem
by its coordinates.void
setBackground
(@Nullable ItemProvider itemProvider) Sets theItemProvider
that will be used if nothing else is placed on a slot.void
setFrozen
(boolean frozen) Freezes or unfreezes theGui
.void
setIgnoreObscuredInventorySlots
(boolean ignoreObscuredInventorySlots) Configures whether it is possible to shift-click items into and cursor collect items from allInventory
slots of partially obscured embeddedInventories
.void
Sets theItem
on these coordinates.void
Sets theItem
on that slotvoid
setSlotElement
(int x, int y, @Nullable SlotElement slotElement) Sets theSlotElement
on these coordinates.void
setSlotElement
(int index, @Nullable SlotElement slotElement) Sets theSlotElement
on these coordinates.
-
Method Details
-
normal
Creates a newGui Builder
for a normalGui
.- Returns:
- The new
Gui Builder
.
-
normal
@NotNull static @NotNull Gui normal(@NotNull @NotNull Consumer<@NotNull Gui.Builder.Normal> consumer) - Parameters:
consumer
- TheConsumer
to 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 theSlotElement
on these coordinates. If you need to set anItem
, please usesetItem(int, int, Item)
instead.- Parameters:
x
- The x coordinatey
- The y coordinateslotElement
- TheSlotElement
to be placed there.
-
setSlotElement
Sets theSlotElement
on these coordinates. If you need to set anItem
, please usesetItem(int, Item)
instead.- Parameters:
index
- The slot indexslotElement
- TheSlotElement
to be placed there.
-
addSlotElements
AddsSlotElements
to theGui
.- Parameters:
slotElements
- TheSlotElements
to add.
-
getSlotElement
Gets theSlotElement
on these coordinates.- Parameters:
x
- The x coordinatey
- The y coordinate- Returns:
- The
SlotElement
placed there
-
getSlotElement
Gets theSlotElement
placed on that slot.- Parameters:
index
- The slot index- Returns:
- The
SlotElement
placed on that slot
-
hasSlotElement
boolean hasSlotElement(int x, int y) Gets if there is aSlotElement
on these coordinates.- Parameters:
x
- The x coordinatey
- The y coordinate- Returns:
- If there is a
SlotElement
placed there
-
hasSlotElement
boolean hasSlotElement(int index) Gets if there is aSlotElement
placed on that slot.- Parameters:
index
- The slot index- Returns:
- If there is a
SlotElement
placed there
-
getSlotElements
Gets allSlotElements
of thisGui
in an Array.- Returns:
- All
SlotElements
of thisGui
-
setItem
Sets theItem
on these coordinates. -
setItem
Sets theItem
on that slot -
addItems
AddsItems
to the gui.- Parameters:
items
- TheItems
that should be added to the gui
-
getItem
Gets theItem
on these coordinates.- Parameters:
x
- The x coordinatey
- The y coordinate- Returns:
- The
Item
which is placed on that slot or null if there isn't one
-
getItem
Gets theItem
placed on that slot.- Parameters:
index
- The slot index- Returns:
- The
Item
which is placed on that slot or null if there isn't one
-
getBackground
Gets theItemProvider
that will be used if nothing else is placed on a slot.- Returns:
- The
ItemProvider
-
setBackground
Sets theItemProvider
that will be used if nothing else is placed on a slot.- Parameters:
itemProvider
- TheItemProvider
-
remove
void remove(int x, int y) Removes anItem
by its coordinates.- Parameters:
x
- The x coordinatey
- The y coordinate
-
remove
void remove(int index) Remove theItem
which are placed on these slots.- Parameters:
index
- The slot index of theItems
that should be removed
-
applyStructure
- Parameters:
structure
- The structure
-
findAllWindows
-
findAllCurrentViewers
Finds allPlayers
that are currently seeing thisWindow
.- Returns:
- The list of
Players
that are currently seeing thisWindow
-
closeForAllViewers
void closeForAllViewers()Closes the openInventory
for all viewers ofWindows
where thisGui
is displayed.If the
Windows
are not marked as "retain", they will be removed from theWindowManager
automatically. -
playAnimation
void playAnimation(@NotNull @NotNull Animation animation, @Nullable @Nullable Predicate<@NotNull SlotElement> filter) Plays anAnimation
.- Parameters:
animation
- TheAnimation
to play.filter
- The filter that selects whichSlotElements
should be animated.
-
cancelAnimation
void cancelAnimation()Cancels the runningAnimation
if there is one. -
setFrozen
void setFrozen(boolean frozen) - Parameters:
frozen
- If theGui
should be frozen or not.
-
isFrozen
boolean isFrozen()Gets if theGui
is frozen.- Returns:
- If the
Gui
is frozen.
-
setIgnoreObscuredInventorySlots
void setIgnoreObscuredInventorySlots(boolean ignoreObscuredInventorySlots) Configures whether it is possible to shift-click items into and cursor collect items from allInventory
slots of partially obscured embeddedInventories
.Defaults to true.
- Parameters:
ignoreObscuredInventorySlots
- Whether obscuredInventory
slots 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 allInventory
slots of partially obscured embeddedInventories
.- Returns:
- Whether obscured
Inventory
slots 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
- TheItem
that 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
- TheGui
to be put into thisGui
replaceExisting
- If existingSlotElements
should 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
- TheInventory
to be put into thisGui
.replaceExisting
- If existingSlotElements
should 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
- TheInventory
to be put into thisGui
.background
- TheItemProvider
for empty slots of theInventory
replaceExisting
- If existingSlotElements
should be replaced.
-