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
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfaceA functional interface for specifying how closing the inventory should be treated by implementing theInventoryGui.CloseAction.onClose(Close)method.static classFake InventoryHolder for the GUIsstatic class -
Constructor Summary
ConstructorsConstructorDescriptionInventoryGui(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 TypeMethodDescriptionvoidaddElement(char slotChar, org.bukkit.inventory.ItemStack item, GuiElement.Action action, String... text) Create and add aStaticGuiElementin one quick method.voidaddElement(char slotChar, org.bukkit.inventory.ItemStack item, String... text) Create and add aStaticGuiElementthat has no action.voidaddElement(char slotChar, org.bukkit.material.MaterialData materialData, GuiElement.Action action, String... text) Create and add aStaticGuiElementin one quick method.voidaddElement(char slotChar, org.bukkit.Material material, byte data, GuiElement.Action action, String... text) Create and add aStaticGuiElementvoidaddElement(char slotChar, org.bukkit.Material material, GuiElement.Action action, String... text) Create and add aStaticGuiElementvoidaddElement(GuiElement element) Add an element to the gui with its position directly based on the elements slot char and the gui setup stringvoidaddElements(GuiElement... elements) Add multiple elements to the gui with their position based on their slot charactervoidaddElements(Collection<GuiElement> elements) Add multiple elements to the gui with their position based on their slot characterstatic voidaddHistory(org.bukkit.entity.HumanEntity player, InventoryGui gui) Add a new history entry to the end of the historyvoidbuild()Build the guivoidbuild(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 playervoidclose()Closes the GUI for everyone viewing itvoidclose(boolean clearHistory) Close the GUI for everyone viewing itvoidclose(org.bukkit.entity.HumanEntity viewer) Closes the GUI for a specific viewer itvoidclose(org.bukkit.entity.HumanEntity viewer, boolean clearHistory) Closes the GUI for a specific viewer itvoiddestroy()Destroy this GUI.voiddraw()Draw the elements in the inventory.voiddraw(org.bukkit.entity.HumanEntity who) Draw the elements in the inventory.voiddraw(org.bukkit.entity.HumanEntity who, boolean updateDynamic) Draw the elements in the inventory.voiddraw(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 InventoryGuiget(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 StringGet 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 InventoryGuigetOpen(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.InventoryHoldergetOwner()Get the owner of this GUI.intgetPageAmount(@NotNull org.bukkit.entity.HumanEntity player) Get the amount of pages that this GUI has for a certain playerintgetPageNumber(@NotNull org.bukkit.entity.HumanEntity player) Get the number of the page that this gui is on.org.bukkit.plugin.PluginGet the plugin which owns this GUI.getTitle()Get the title of the guistatic booleangoBack(org.bukkit.entity.HumanEntity player) Go back one entry in the historybooleanCheck whether or not the Owner of this GUI is real or fakebooleanisSilent()Get whether or not this GUI should make a sound when interacting with elements that make soundvoidPlay 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.booleanremoveElement(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 voidSchedule a task on the global region/main thread to run on the next tickprotected voidSchedule a task on aHumanEntity/main thread to run on the next tickprotected voidrunTaskOrNow(org.bukkit.entity.HumanEntity entity, Runnable task) Schedule a task on aHumanEntityto run on the next tick Alternatively if the current thread is already the right thread, execute immediatelyvoidsetClickSound(String soundKey) Set the sound that plays when a button (that isn't preventing the item from being taken) is clicked in the GUI.voidsetCloseAction(InventoryGui.CloseAction closeAction) Set the action that is run when this GUI is closed; it should return true if the GUI should go backstatic voidsetDefaultClickSound(String defaultClickSound) Set the click sound to use for non-silent GUIs that don't have a specific one setvoidsetElement(int slot, GuiElement element) Directly set the element in a specific slotvoidsetFiller(org.bukkit.inventory.ItemStack item) Set the filler element for empty slotsvoidsetInventoryCreator(InventoryGui.InventoryCreator inventoryCreator) Set the helper class which will create the custom inventory for this gui.voidsetItemLoreSetter(BiConsumer<org.bukkit.inventory.meta.ItemMeta, List<String>> itemLoreSetter) Sets the setter for item lores.voidsetItemNameSetter(BiConsumer<org.bukkit.inventory.meta.ItemMeta, String> itemNameSetter) Sets the setter ofr item names.voidsetItemText(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.voidsetItemText(org.bukkit.inventory.ItemStack item, String... text) Deprecated.voidsetOutsideAction(GuiElement.Action outsideAction) Set the Action that is run when clicked outside of the inventoryvoidsetOwner(org.bukkit.inventory.InventoryHolder owner) Set the owner of this GUI.voidsetPageNumber(int pageNumber) Set the number of the page that this gui is on for all players.voidsetPageNumber(org.bukkit.entity.HumanEntity player, int pageNumber) Set the number of the page that this gui is on for a player.voidsetSilent(boolean silent) Set whether or not this GUI should make a sound when interacting with elements that make soundvoidSet the title of the guivoidshow(org.bukkit.entity.HumanEntity player) Show this GUI to a playervoidshow(org.bukkit.entity.HumanEntity player, boolean checkOpen) Show this GUI to a playerstatic voidupdateElements(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- TheGuiElements 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- TheGuiElements 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- TheGuiElements 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- TheGuiElements 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- TheGuiElements 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- TheGuiElementto 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- TheGuiElementto add
-
addElement
public void addElement(char slotChar, org.bukkit.inventory.ItemStack item, GuiElement.Action action, String... text) Create and add aStaticGuiElementin 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.Actionto 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 aStaticGuiElementthat 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 aStaticGuiElementin one quick method.- Parameters:
slotChar- The character to specify the elements position based on the gui setup stringmaterialData- TheMaterialDataof the item of tihs elementaction- TheGuiElement.Actionto 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- TheMaterialthat the item should havedata- Thebyterepresentation of the material data of this elementaction- TheGuiElement.Actionto 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- TheMaterialthat the item should haveaction- TheGuiElement.Actionto 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- TheGuiElements to add
-
addElements
Add multiple elements to the gui with their position based on their slot character- Parameters:
elements- TheGuiElements 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
nullif 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
nullif 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- TheInventoryHolderthat 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 aHumanEntityto 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:
trueif there was a gui to show;falseif 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
nullif 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
nullif 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:
trueif the owner is a real world InventoryHolder;falseif 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
nullif 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- TheStringthat 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- TheItemStackto 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- TheItemStackto 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...)