Package de.themoep.inventorygui
Class InventoryGui
java.lang.Object
de.themoep.inventorygui.InventoryGui
- All Implemented Interfaces:
org.bukkit.event.Listener
The main library class that lets you create and manage your GUIs
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static interface
A functional interface for specifying how closing the inventory should be treated by implementing theInventoryGui.CloseAction.onClose(Close)
method.static class
Fake InventoryHolder for the GUIsstatic class
-
Constructor Summary
ConstructorDescriptionInventoryGui
(org.bukkit.plugin.Plugin plugin, InventoryGui.InventoryCreator creator, BiConsumer<org.bukkit.inventory.meta.ItemMeta, String> itemNameSetter, BiConsumer<org.bukkit.inventory.meta.ItemMeta, List<String>> itemLoreSetter, org.bukkit.inventory.InventoryHolder owner, String title, String[] rows, GuiElement... elements) Create a new gui with a certain setup and some elementsInventoryGui
(org.bukkit.plugin.Plugin plugin, InventoryGui.InventoryCreator creator, org.bukkit.inventory.InventoryHolder owner, String title, String[] rows, GuiElement... elements) Create a new gui with a certain setup and some elementsInventoryGui
(org.bukkit.plugin.Plugin plugin, String title, String[] rows, GuiElement... elements) The simplest way to create a new gui.InventoryGui
(org.bukkit.plugin.Plugin plugin, org.bukkit.inventory.InventoryHolder owner, String title, String[] rows, GuiElement... elements) Create a new gui with a certain setup and some elementsInventoryGui
(org.bukkit.plugin.Plugin plugin, org.bukkit.inventory.InventoryHolder owner, String title, String[] rows, Collection<GuiElement> elements) Create a new gui that has no owner with a certain setup and some elements -
Method Summary
Modifier and TypeMethodDescriptionvoid
addElement
(char slotChar, org.bukkit.inventory.ItemStack item, GuiElement.Action action, String... text) Create and add aStaticGuiElement
in one quick method.void
addElement
(char slotChar, org.bukkit.inventory.ItemStack item, String... text) Create and add aStaticGuiElement
that has no action.void
addElement
(char slotChar, org.bukkit.material.MaterialData materialData, GuiElement.Action action, String... text) Create and add aStaticGuiElement
in one quick method.void
addElement
(char slotChar, org.bukkit.Material material, byte data, GuiElement.Action action, String... text) Create and add aStaticGuiElement
void
addElement
(char slotChar, org.bukkit.Material material, GuiElement.Action action, String... text) Create and add aStaticGuiElement
void
addElement
(GuiElement element) Add an element to the gui with its position directly based on the elements slot char and the gui setup stringvoid
addElements
(GuiElement... elements) Add multiple elements to the gui with their position based on their slot charactervoid
addElements
(Collection<GuiElement> elements) Add multiple elements to the gui with their position based on their slot characterstatic void
addHistory
(org.bukkit.entity.HumanEntity player, InventoryGui gui) Add a new history entry to the end of the historyvoid
build()
Build the guivoid
build
(org.bukkit.inventory.InventoryHolder owner) Set the gui's owner and build itstatic Deque
<InventoryGui> clearHistory
(org.bukkit.entity.HumanEntity player) Clear the history of a playervoid
close()
Closes the GUI for everyone viewing itvoid
close
(boolean clearHistory) Close the GUI for everyone viewing itvoid
close
(org.bukkit.entity.HumanEntity viewer) Closes the GUI for a specific viewer itvoid
close
(org.bukkit.entity.HumanEntity viewer, boolean clearHistory) Closes the GUI for a specific viewer itvoid
destroy()
Destroy this GUI.void
draw()
Draw the elements in the inventory.void
draw
(org.bukkit.entity.HumanEntity who) Draw the elements in the inventory.void
draw
(org.bukkit.entity.HumanEntity who, boolean updateDynamic) Draw the elements in the inventory.void
draw
(org.bukkit.entity.HumanEntity who, boolean updateDynamic, boolean recreateInventory) Draw the elements in the inventory.filler
(org.bukkit.inventory.ItemStack item) Set the filler element for empty slotsstatic InventoryGui
get
(org.bukkit.inventory.InventoryHolder holder) Get the GUI registered to an InventoryHolderSet the sound that plays when a button (that isn't preventing the item from being taken) is clicked in the GUI.Get the action that is run when this GUI is closedstatic String
Get the click sound to use for non-silent GUIs that don't have a specific one setgetElement
(char c) Get an element by its charactergetElement
(int slot) Get element in a certain slotGet all elements of this gui.Get the filler elementstatic Deque
<InventoryGui> getHistory
(org.bukkit.entity.HumanEntity player) Get the history of a playerGet the helper class which will create the custom inventory for this gui.BiConsumer
<org.bukkit.inventory.meta.ItemMeta, List<String>> Get the setter for item lores.BiConsumer
<org.bukkit.inventory.meta.ItemMeta, String> Get the setter for item names.static InventoryGui
getOpen
(org.bukkit.entity.HumanEntity player) Get the GUI that a player has currently openGet the Action that is run when clicked outside of the inventoryorg.bukkit.inventory.InventoryHolder
getOwner()
Get the owner of this GUI.int
getPageAmount
(@NotNull org.bukkit.entity.HumanEntity player) Get the amount of pages that this GUI has for a certain playerint
getPageNumber
(@NotNull org.bukkit.entity.HumanEntity player) Get the number of the page that this gui is on.org.bukkit.plugin.Plugin
Get the plugin which owns this GUI.getTitle()
Get the title of the guistatic boolean
goBack
(org.bukkit.entity.HumanEntity player) Go back one entry in the historyboolean
Check whether or not the Owner of this GUI is real or fakeboolean
isSilent()
Get whether or not this GUI should make a sound when interacting with elements that make soundvoid
Play a click sound e.g.removeElement
(char slotChar) Remove the element that is currently assigned to a specific slot char from all slots in the guiremoveElement
(int slot) Remove the element that is currently in a specific slot.boolean
removeElement
(GuiElement element) Remove a specific element from this gui.replaceVars
(@NotNull org.bukkit.entity.HumanEntity player, @NotNull String text, String... replacements) Replace some placeholders in the with values regarding the gui's state.protected void
Schedule a task on the global region/main thread to run on the next tickprotected void
Schedule a task on aHumanEntity
/main thread to run on the next tickprotected void
runTaskOrNow
(org.bukkit.entity.HumanEntity entity, Runnable task) Schedule a task on aHumanEntity
to run on the next tick Alternatively if the current thread is already the right thread, execute immediatelyvoid
setClickSound
(String soundKey) Set the sound that plays when a button (that isn't preventing the item from being taken) is clicked in the GUI.void
setCloseAction
(InventoryGui.CloseAction closeAction) Set the action that is run when this GUI is closed; it should return true if the GUI should go backstatic void
setDefaultClickSound
(String defaultClickSound) Set the click sound to use for non-silent GUIs that don't have a specific one setvoid
setElement
(int slot, GuiElement element) Directly set the element in a specific slotvoid
setFiller
(org.bukkit.inventory.ItemStack item) Set the filler element for empty slotsvoid
setInventoryCreator
(InventoryGui.InventoryCreator inventoryCreator) Set the helper class which will create the custom inventory for this gui.void
setItemLoreSetter
(BiConsumer<org.bukkit.inventory.meta.ItemMeta, List<String>> itemLoreSetter) Sets the setter for item lores.void
setItemNameSetter
(BiConsumer<org.bukkit.inventory.meta.ItemMeta, String> itemNameSetter) Sets the setter ofr item names.void
setItemText
(org.bukkit.entity.HumanEntity player, org.bukkit.inventory.ItemStack item, String... text) Set the text of an item using the display name and the lore.void
setItemText
(org.bukkit.inventory.ItemStack item, String... text) Deprecated.void
setOutsideAction
(GuiElement.Action outsideAction) Set the Action that is run when clicked outside of the inventoryvoid
setOwner
(org.bukkit.inventory.InventoryHolder owner) Set the owner of this GUI.void
setPageNumber
(int pageNumber) Set the number of the page that this gui is on for all players.void
setPageNumber
(org.bukkit.entity.HumanEntity player, int pageNumber) Set the number of the page that this gui is on for a player.void
setSilent
(boolean silent) Set whether or not this GUI should make a sound when interacting with elements that make soundvoid
Set the title of the guivoid
show
(org.bukkit.entity.HumanEntity player) Show this GUI to a playervoid
show
(org.bukkit.entity.HumanEntity player, boolean checkOpen) Show this GUI to a playerstatic void
updateElements
(org.bukkit.entity.HumanEntity who, Collection<GuiElement> elements) Update all dynamic elements in a collection of elements.
-
Constructor Details
-
InventoryGui
public InventoryGui(org.bukkit.plugin.Plugin plugin, InventoryGui.InventoryCreator creator, BiConsumer<org.bukkit.inventory.meta.ItemMeta, String> itemNameSetter, BiConsumer<org.bukkit.inventory.meta.ItemMeta, List<String>> itemLoreSetter, org.bukkit.inventory.InventoryHolder owner, String title, String[] rows, GuiElement... elements) Create a new gui with a certain setup and some elements- Parameters:
plugin
- Your plugincreator
- A creator for the backing inventoryitemNameSetter
- Setter for item display namesitemLoreSetter
- Setter for item loresowner
- The holder that owns this gui to retrieve it withget(InventoryHolder)
. Can benull
.title
- The name of the GUI. This will be the title of the inventory.rows
- How your rows are setup. Each element is getting assigned to a character. Empty/missing ones get filled with the Filler.elements
- TheGuiElement
s that the gui should have. You can also useaddElement(GuiElement)
later.- Throws:
IllegalArgumentException
- Thrown when the provided rows cannot be matched to an InventoryType
-
InventoryGui
public InventoryGui(org.bukkit.plugin.Plugin plugin, InventoryGui.InventoryCreator creator, org.bukkit.inventory.InventoryHolder owner, String title, String[] rows, GuiElement... elements) Create a new gui with a certain setup and some elements- Parameters:
plugin
- Your plugincreator
- A creator for the backing inventoryowner
- The holder that owns this gui to retrieve it withget(InventoryHolder)
. Can benull
.title
- The name of the GUI. This will be the title of the inventory.rows
- How your rows are setup. Each element is getting assigned to a character. Empty/missing ones get filled with the Filler.elements
- TheGuiElement
s that the gui should have. You can also useaddElement(GuiElement)
later.- Throws:
IllegalArgumentException
- Thrown when the provided rows cannot be matched to an InventoryType
-
InventoryGui
public InventoryGui(org.bukkit.plugin.Plugin plugin, org.bukkit.inventory.InventoryHolder owner, String title, String[] rows, GuiElement... elements) Create a new gui with a certain setup and some elements- Parameters:
plugin
- Your pluginowner
- The holder that owns this gui to retrieve it withget(InventoryHolder)
. Can benull
.title
- The name of the GUI. This will be the title of the inventory.rows
- How your rows are setup. Each element is getting assigned to a character. Empty/missing ones get filled with the Filler.elements
- TheGuiElement
s that the gui should have. You can also useaddElement(GuiElement)
later.- Throws:
IllegalArgumentException
- Thrown when the provided rows cannot be matched to an InventoryType
-
InventoryGui
public InventoryGui(org.bukkit.plugin.Plugin plugin, String title, String[] rows, GuiElement... elements) The simplest way to create a new gui. It has no owner and elements are optional.- Parameters:
plugin
- Your plugintitle
- The name of the GUI. This will be the title of the inventory.rows
- How your rows are setup. Each element is getting assigned to a character. Empty/missing ones get filled with the Filler.elements
- TheGuiElement
s that the gui should have. You can also useaddElement(GuiElement)
later.- Throws:
IllegalArgumentException
- Thrown when the provided rows cannot be matched to an InventoryType
-
InventoryGui
public InventoryGui(org.bukkit.plugin.Plugin plugin, org.bukkit.inventory.InventoryHolder owner, String title, String[] rows, Collection<GuiElement> elements) Create a new gui that has no owner with a certain setup and some elements- Parameters:
plugin
- Your pluginowner
- The holder that owns this gui to retrieve it withget(InventoryHolder)
. Can benull
.title
- The name of the GUI. This will be the title of the inventory.rows
- How your rows are setup. Each element is getting assigned to a character. Empty/missing ones get filled with the Filler.elements
- TheGuiElement
s that the gui should have. You can also useaddElement(GuiElement)
later.- Throws:
IllegalArgumentException
- Thrown when the provided rows cannot be matched to an InventoryType
-
-
Method Details
-
setElement
Directly set the element in a specific slot- Parameters:
element
- TheGuiElement
to add- Throws:
IllegalArgumentException
- Thrown if the provided slot is below 0 or equal/above the available slot countIllegalStateException
- Thrown if the element was already added to a gui
-
addElement
Add an element to the gui with its position directly based on the elements slot char and the gui setup string- Parameters:
element
- TheGuiElement
to add
-
addElement
public void addElement(char slotChar, org.bukkit.inventory.ItemStack item, GuiElement.Action action, String... text) Create and add aStaticGuiElement
in one quick method.- Parameters:
slotChar
- The character to specify the elements position based on the gui setup stringitem
- The item that should be displayedaction
- TheGuiElement.Action
to run when the player clicks on this elementtext
- The text to display on this element, placeholders are automatically replaced, seereplaceVars(org.bukkit.entity.HumanEntity, java.lang.String, java.lang.String...)
for a list of the placeholder variables. Empty text strings are also filter out, use a single space if you want to add an empty line!
If it's not set/empty the item's default name will be used
-
addElement
Create and add aStaticGuiElement
that has no action.- Parameters:
slotChar
- The character to specify the elements position based on the gui setup stringitem
- The item that should be displayedtext
- The text to display on this element, placeholders are automatically replaced, seereplaceVars(org.bukkit.entity.HumanEntity, java.lang.String, java.lang.String...)
for a list of the placeholder variables. Empty text strings are also filter out, use a single space if you want to add an empty line!
If it's not set/empty the item's default name will be used
-
addElement
public void addElement(char slotChar, org.bukkit.material.MaterialData materialData, GuiElement.Action action, String... text) Create and add aStaticGuiElement
in one quick method.- Parameters:
slotChar
- The character to specify the elements position based on the gui setup stringmaterialData
- TheMaterialData
of the item of tihs elementaction
- TheGuiElement.Action
to run when the player clicks on this elementtext
- The text to display on this element, placeholders are automatically replaced, seereplaceVars(org.bukkit.entity.HumanEntity, java.lang.String, java.lang.String...)
for a list of the placeholder variables. Empty text strings are also filter out, use a single space if you want to add an empty line!
If it's not set/empty the item's default name will be used
-
addElement
public void addElement(char slotChar, org.bukkit.Material material, byte data, GuiElement.Action action, String... text) Create and add aStaticGuiElement
- Parameters:
slotChar
- The character to specify the elements position based on the gui setup stringmaterial
- TheMaterial
that the item should havedata
- Thebyte
representation of the material data of this elementaction
- TheGuiElement.Action
to run when the player clicks on this elementtext
- The text to display on this element, placeholders are automatically replaced, seereplaceVars(org.bukkit.entity.HumanEntity, java.lang.String, java.lang.String...)
for a list of the placeholder variables. Empty text strings are also filter out, use a single space if you want to add an empty line!
If it's not set/empty the item's default name will be used
-
addElement
public void addElement(char slotChar, org.bukkit.Material material, GuiElement.Action action, String... text) Create and add aStaticGuiElement
- Parameters:
slotChar
- The character to specify the elements position based on the gui setup stringmaterial
- TheMaterial
that the item should haveaction
- TheGuiElement.Action
to run when the player clicks on this elementtext
- The text to display on this element, placeholders are automatically replaced, seereplaceVars(org.bukkit.entity.HumanEntity, java.lang.String, java.lang.String...)
for a list of the placeholder variables. Empty text strings are also filter out, use a single space if you want to add an empty line!
If it's not set/empty the item's default name will be used
-
addElements
Add multiple elements to the gui with their position based on their slot character- Parameters:
elements
- TheGuiElement
s to add
-
addElements
Add multiple elements to the gui with their position based on their slot character- Parameters:
elements
- TheGuiElement
s to add
-
removeElement
Remove a specific element from this gui.- Parameters:
element
- The element to remove- Returns:
- Whether or not the gui contained this element and if it was removed
-
removeElement
Remove the element that is currently assigned to a specific slot char from all slots in the gui- Parameters:
slotChar
- The char of the slot- Returns:
- The element which was in that slot or
null
if there was none
-
removeElement
Remove the element that is currently in a specific slot. Will not remove that element from other slots- Parameters:
slot
- The slot- Returns:
- The element which was in that slot or
null
if there was none
-
filler
Set the filler element for empty slots- Parameters:
item
- The item for the filler element- Returns:
- The GUI instance
-
setFiller
public void setFiller(org.bukkit.inventory.ItemStack item) Set the filler element for empty slots- Parameters:
item
- The item for the filler element
-
getFiller
Get the filler element- Returns:
- The filler element for empty slots
-
getPageNumber
public int getPageNumber(@NotNull @NotNull org.bukkit.entity.HumanEntity player) Get the number of the page that this gui is on. zero indexed. Only affects group elements.- Parameters:
player
- The Player to query the page number for- Returns:
- The page number
-
setPageNumber
public void setPageNumber(int pageNumber) Set the number of the page that this gui is on for all players. zero indexed. Only affects group elements.- Parameters:
pageNumber
- The page number to set
-
setPageNumber
public void setPageNumber(org.bukkit.entity.HumanEntity player, int pageNumber) Set the number of the page that this gui is on for a player. zero indexed. Only affects group elements.- Parameters:
player
- The player to set the page number forpageNumber
- The page number to set
-
getPageAmount
public int getPageAmount(@NotNull @NotNull org.bukkit.entity.HumanEntity player) Get the amount of pages that this GUI has for a certain player- Parameters:
player
- The Player to query the page amount for- Returns:
- The amount of pages
-
show
public void show(org.bukkit.entity.HumanEntity player) Show this GUI to a player- Parameters:
player
- The Player to show the GUI to
-
show
public void show(org.bukkit.entity.HumanEntity player, boolean checkOpen) Show this GUI to a player- Parameters:
player
- The Player to show the GUI tocheckOpen
- Whether or not it should check if this gui is already open
-
build
public void build()Build the gui -
build
public void build(org.bukkit.inventory.InventoryHolder owner) Set the gui's owner and build it- Parameters:
owner
- TheInventoryHolder
that owns the gui
-
draw
public void draw()Draw the elements in the inventory. This can be used to manually refresh the gui. Updates any dynamic elements. -
draw
public void draw(org.bukkit.entity.HumanEntity who) Draw the elements in the inventory. This can be used to manually refresh the gui. Updates any dynamic elements.- Parameters:
who
- For who to draw the GUI
-
draw
public void draw(org.bukkit.entity.HumanEntity who, boolean updateDynamic) Draw the elements in the inventory. This can be used to manually refresh the gui.- Parameters:
who
- For who to draw the GUIupdateDynamic
- Update dynamic elements
-
draw
public void draw(org.bukkit.entity.HumanEntity who, boolean updateDynamic, boolean recreateInventory) Draw the elements in the inventory. This can be used to manually refresh the gui.- Parameters:
who
- For who to draw the GUIupdateDynamic
- Update dynamic elementsrecreateInventory
- Recreate the inventory
-
runTask
Schedule a task on aHumanEntity
/main thread to run on the next tick- Parameters:
entity
- the human entity to schedule a task ontask
- the task to be run
-
runTask
Schedule a task on the global region/main thread to run on the next tick- Parameters:
task
- the task to be run
-
runTaskOrNow
Schedule a task on aHumanEntity
to run on the next tick Alternatively if the current thread is already the right thread, execute immediately- Parameters:
entity
- the human entity to schedule a task ontask
- the task to be run
-
updateElements
public static void updateElements(org.bukkit.entity.HumanEntity who, Collection<GuiElement> elements) Update all dynamic elements in a collection of elements.- Parameters:
who
- The player to update the elements forelements
- The elements to update
-
close
public void close()Closes the GUI for everyone viewing it -
close
public void close(boolean clearHistory) Close the GUI for everyone viewing it- Parameters:
clearHistory
- Whether to close the GUI completely (by clearing the history)
-
close
public void close(org.bukkit.entity.HumanEntity viewer) Closes the GUI for a specific viewer it- Parameters:
viewer
- The player viewing it
-
close
public void close(org.bukkit.entity.HumanEntity viewer, boolean clearHistory) Closes the GUI for a specific viewer it- Parameters:
viewer
- The player viewing itclearHistory
- Whether to close the GUI completely (by clearing the history)
-
destroy
public void destroy()Destroy this GUI. This unregisters all listeners and removes it from the GUI_MAP -
addHistory
Add a new history entry to the end of the history- Parameters:
player
- The player to add the history entry forgui
- The GUI to add to the history
-
getHistory
Get the history of a player- Parameters:
player
- The player to get the history for- Returns:
- The history as a deque of InventoryGuis;
returns an empty one and not
null
!
-
goBack
public static boolean goBack(org.bukkit.entity.HumanEntity player) Go back one entry in the history- Parameters:
player
- The player to show the previous gui to- Returns:
true
if there was a gui to show;false
if not
-
clearHistory
Clear the history of a player- Parameters:
player
- The player to clear the history for- Returns:
- The history
-
getPlugin
public org.bukkit.plugin.Plugin getPlugin()Get the plugin which owns this GUI. Should be the one who created it.- Returns:
- The plugin which owns this GUI
-
getInventoryCreator
Get the helper class which will create the custom inventory for this gui. Simply usesBukkit.createInventory(InventoryHolder, int, String)
by default.- Returns:
- The used inventory creator instance
-
setInventoryCreator
Set the helper class which will create the custom inventory for this gui. Can be used to create more special inventories. Simply usesBukkit.createInventory(InventoryHolder, int, String)
by default. Should return a container inventory that can hold the size. Special inventories will break stuff.- Parameters:
inventoryCreator
- The new inventory creator instance
-
getItemNameSetter
Get the setter for item names.- Returns:
- The setter instance
-
setItemNameSetter
Sets the setter ofr item names.- Parameters:
itemNameSetter
- The item name setter BiConsumer taking the ItemMeta to be modified and the string for the name
-
getItemLoreSetter
Get the setter for item lores.- Returns:
- The setter instance
-
setItemLoreSetter
public void setItemLoreSetter(BiConsumer<org.bukkit.inventory.meta.ItemMeta, List<String>> itemLoreSetter) Sets the setter for item lores.- Parameters:
itemLoreSetter
- The item lore setter BiConsumer taking the ItemMeta to be modified and the string list for the lore lines
-
getElement
Get element in a certain slot- Parameters:
slot
- The slot to get the element from- Returns:
- The GuiElement or
null
if the slot is empty/there wasn't one
-
getElement
Get an element by its character- Parameters:
c
- The character to get the element by- Returns:
- The GuiElement or
null
if there is no element for that character
-
getElements
Get all elements of this gui. This collection is immutable, use the addElement and removeElement methods to modify the elements in this gui.- Returns:
- An immutable collection of all elements in this group
-
setOwner
public void setOwner(org.bukkit.inventory.InventoryHolder owner) Set the owner of this GUI. Will remove the previous assignment.- Parameters:
owner
- The owner of the GUI
-
getOwner
public org.bukkit.inventory.InventoryHolder getOwner()Get the owner of this GUI. Will be null if th GUI doesn't have one- Returns:
- The InventoryHolder of this GUI
-
hasRealOwner
public boolean hasRealOwner()Check whether or not the Owner of this GUI is real or fake- Returns:
true
if the owner is a real world InventoryHolder;false
if it is null
-
getOutsideAction
Get the Action that is run when clicked outside of the inventory- Returns:
- The Action for when the player clicks outside the inventory; can be null
-
setOutsideAction
Set the Action that is run when clicked outside of the inventory- Parameters:
outsideAction
- The Action for when the player clicks outside the inventory; can be null
-
getCloseAction
Get the action that is run when this GUI is closed- Returns:
- The action for when the player closes this inventory; can be null
-
setCloseAction
Set the action that is run when this GUI is closed; it should return true if the GUI should go back- Parameters:
closeAction
- The action for when the player closes this inventory; can be null
-
getDefaultClickSound
Get the click sound to use for non-silent GUIs that don't have a specific one set- Returns:
- The default click sound, if set null no sound will play
-
setDefaultClickSound
Set the click sound to use for non-silent GUIs that don't have a specific one set- Parameters:
defaultClickSound
- The default click sound, if set to null no sound will play
-
getClickSound
Set the sound that plays when a button (that isn't preventing the item from being taken) is clicked in the GUI. Fillers will not play a click sound- Returns:
- The key of the sound to play
-
setClickSound
Set the sound that plays when a button (that isn't preventing the item from being taken) is clicked in the GUI. Fillers will not play a click sound- Parameters:
soundKey
- The key of the sound to play, if null then no sound will play (same effect assetSilent(boolean)
)
-
isSilent
public boolean isSilent()Get whether or not this GUI should make a sound when interacting with elements that make sound- Returns:
- Whether or not to make a sound when interacted with
-
setSilent
public void setSilent(boolean silent) Set whether or not this GUI should make a sound when interacting with elements that make sound- Parameters:
silent
- Whether or not to make a sound when interacted with
-
get
Get the GUI registered to an InventoryHolder- Parameters:
holder
- The InventoryHolder to get the GUI for- Returns:
- The InventoryGui registered to it or
null
if none was registered to it
-
getOpen
Get the GUI that a player has currently open- Parameters:
player
- The Player to get the GUI for- Returns:
- The InventoryGui that the player has open
-
getTitle
Get the title of the gui- Returns:
- The title of the gui
-
setTitle
Set the title of the gui- Parameters:
title
- TheString
that should be the title of the gui
-
playClickSound
public void playClickSound()Play a click sound e.g. when an element acts as a button -
setItemText
Deprecated.Set the text of an item using the display name and the lore. Also replaces any placeholders in the text and filters out empty lines. Use a single space to create an emtpy line.- Parameters:
item
- TheItemStack
to set the text fortext
- The text lines to set
-
setItemText
public void setItemText(org.bukkit.entity.HumanEntity player, org.bukkit.inventory.ItemStack item, String... text) Set the text of an item using the display name and the lore. Also replaces any placeholders in the text and filters out empty lines. Use a single space to create an emtpy line.- Parameters:
player
- The player viewing the GUIitem
- TheItemStack
to set the text fortext
- The text lines to set
-
replaceVars
public String replaceVars(@NotNull @NotNull org.bukkit.entity.HumanEntity player, @NotNull @NotNull String text, String... replacements) Replace some placeholders in the with values regarding the gui's state. Replaced color codes.
The placeholders are:
%plugin%
- The name of the plugin that this gui is from.
%owner%
- The name of the owner of this gui. Will be an empty string when the owner is null.
%title%
- The title of this GUI.
%page%
- The current page that this gui is on.
%nextpage%
- The next page. "none" if there is no next page.
%prevpage%
- The previous page. "none" if there is no previous page.
%pages%
- The amount of pages that this gui has.- Parameters:
player
- The player viewing the GUItext
- The text to replace the placeholders inreplacements
- Additional replacements. i = placeholder, i+1 = replacements- Returns:
- The text with all placeholders replaced
-
setItemText(HumanEntity, ItemStack, String...)