Class BInventory
java.lang.Object
com.bencodez.advancedcore.api.inventory.BInventory
- Direct Known Subclasses:
EditGUI
The Class BInventory.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddButton(int position, BInventoryButton button) Adds the button.voidaddButton(BInventoryButton button) Adds the button.Add data to this inventory.addPlaceholder(String toReplace, String replaceWith) Add a placeholder to this inventory.voidaddUpdatingButton(AdvancedCorePlugin plugin, long delay, long interval, Runnable runnable) Add an updating button with scheduled updates.voidCancel all scheduled timers for this inventory.voidcloseInv(org.bukkit.entity.Player p, BInventoryButton b) Close the inventory for a player after button click.Set this inventory to not close after interaction.voidforceClose(org.bukkit.entity.Player p) Force close the inventory for a player.Gets the buttons.getData()Get data by key.Get data by key with default value.intGet the first empty slot in the inventory.intGets the highest slot.Gets the inventory name.intGets the inventory size.intGet meta from player.org.bukkit.inventory.ItemStackintGets the next slot.org.bukkit.inventory.ItemStackbooleanisOpen(org.bukkit.entity.Player p) Check if the inventory is open for a player.booleanisPages()booleanisSlotTaken(int slot) Check if a slot is taken by a button.noSound()Disable sound for this inventory.voidonClick(org.bukkit.event.inventory.InventoryClickEvent event, BInventoryButton b) Handle button click.voidopenInventory(org.bukkit.entity.Player player) Open inventory.voidopenInventory(org.bukkit.entity.Player player, int page) Open inventory.static voidopenInventory(org.bukkit.entity.Player player, BInventory inventory) Open inventory.voidplaySound(org.bukkit.entity.Player player) Play sound for a player.voidrequirePermission(String permission) Require permission to open this inventory.voidsetButtons(Map<Integer, BInventoryButton> buttons) setCloseInv(boolean value) Set whether the inventory should close after interaction.voidsetInventoryName(String inventoryName) Sets the inventory name.voidsetMaxInvSize(int maxInvSize) voidSets the meta.voidsetNextItem(org.bukkit.inventory.ItemStack nextItem) voidsetPageButtons(ArrayList<BInventoryButton> pageButtons) voidsetPages(boolean pages) voidsetPrevItem(org.bukkit.inventory.ItemStack prevItem)
-
Constructor Details
-
BInventory
Instantiates a new b inventory.- Parameters:
name- the name
-
-
Method Details
-
openInventory
Open inventory.- Parameters:
player- the playerinventory- the inventory
-
addButton
Adds the button. Slot of -2 will add item to end of the GUI (last available slot)- Parameters:
button- the button
-
isSlotTaken
public boolean isSlotTaken(int slot) Check if a slot is taken by a button.- Parameters:
slot- the slot to check- Returns:
- true if the slot is taken
-
addButton
Adds the button.- Parameters:
position- the positionbutton- the button
-
addData
Add data to this inventory.- Parameters:
key- the keyobject- the value- Returns:
- this inventory
-
addPlaceholder
Add a placeholder to this inventory.- Parameters:
toReplace- the string to replacereplaceWith- the replacement string- Returns:
- this inventory
-
addUpdatingButton
public void addUpdatingButton(AdvancedCorePlugin plugin, long delay, long interval, Runnable runnable) Add an updating button with scheduled updates.- Parameters:
plugin- the plugin instancedelay- the initial delayinterval- the update intervalrunnable- the runnable to execute
-
cancelTimer
public void cancelTimer()Cancel all scheduled timers for this inventory. -
closeInv
Close the inventory for a player after button click.- Parameters:
p- the playerb- the button that was clicked
-
dontClose
Set this inventory to not close after interaction.- Returns:
- this inventory
-
forceClose
public void forceClose(org.bukkit.entity.Player p) Force close the inventory for a player.- Parameters:
p- the player
-
getButtons
Gets the buttons.- Returns:
- the buttons
-
getData
- Returns:
- the data
-
getData
Get data by key.- Parameters:
key- the key- Returns:
- the data value
-
getData
Get data by key with default value.- Parameters:
key- the keydefaultValue- the default value if key is not found- Returns:
- the data value or default value
-
getFirstEmptySlot
public int getFirstEmptySlot()Get the first empty slot in the inventory.- Returns:
- the first empty slot number
-
getHighestSlot
public int getHighestSlot()Gets the highest slot.- Returns:
- the highest slot
-
getInventoryName
Gets the inventory name.- Returns:
- the inventory name
-
getInventorySize
public int getInventorySize()Gets the inventory size.- Returns:
- the inventory size
-
getMaxInvSize
public int getMaxInvSize()- Returns:
- the maxInvSize
-
getMeta
Get meta from player.- Parameters:
player- the playerstr- the meta key- Returns:
- the meta value
-
getNextItem
public org.bukkit.inventory.ItemStack getNextItem()- Returns:
- the nextItem
-
getNextSlot
public int getNextSlot()Gets the next slot.- Returns:
- the next slot
-
getPageButtons
- Returns:
- the pageButtons
-
getPrevItem
public org.bukkit.inventory.ItemStack getPrevItem()- Returns:
- the prevItem
-
isOpen
public boolean isOpen(org.bukkit.entity.Player p) Check if the inventory is open for a player.- Parameters:
p- the player- Returns:
- true if the inventory is open
-
isPages
public boolean isPages()- Returns:
- the pages
-
noSound
Disable sound for this inventory.- Returns:
- this inventory
-
onClick
Handle button click.- Parameters:
event- the inventory click eventb- the button that was clicked
-
openInventory
public void openInventory(org.bukkit.entity.Player player) Open inventory.- Parameters:
player- the player
-
openInventory
public void openInventory(org.bukkit.entity.Player player, int page) Open inventory.- Parameters:
player- the playerpage- the page
-
playSound
public void playSound(org.bukkit.entity.Player player) Play sound for a player.- Parameters:
player- the player
-
requirePermission
Require permission to open this inventory.- Parameters:
permission- the permission required
-
setButtons
- Parameters:
buttons- the buttons to set
-
setCloseInv
Set whether the inventory should close after interaction.- Parameters:
value- whether to close- Returns:
- this inventory
-
setInventoryName
Sets the inventory name.- Parameters:
inventoryName- the new inventory name
-
setMaxInvSize
public void setMaxInvSize(int maxInvSize) - Parameters:
maxInvSize- the maxInvSize to set
-
setMeta
Sets the meta.- Parameters:
player- the playerstr- the strob- the ob
-
setNextItem
public void setNextItem(org.bukkit.inventory.ItemStack nextItem) - Parameters:
nextItem- the nextItem to set
-
setPageButtons
- Parameters:
pageButtons- the pageButtons to set
-
setPages
public void setPages(boolean pages) - Parameters:
pages- the pages to set
-
setPrevItem
public void setPrevItem(org.bukkit.inventory.ItemStack prevItem) - Parameters:
prevItem- the prevItem to set
-