Class BInventory

java.lang.Object
com.bencodez.advancedcore.api.inventory.BInventory
Direct Known Subclasses:
EditGUI

public class BInventory extends Object
The Class BInventory.
  • Constructor Details

    • BInventory

      public BInventory(String name)
      Instantiates a new b inventory.
      Parameters:
      name - the name
  • Method Details

    • openInventory

      public static void openInventory(org.bukkit.entity.Player player, BInventory inventory)
      Open inventory.
      Parameters:
      player - the player
      inventory - the inventory
    • addButton

      public void addButton(BInventoryButton button)
      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

      public void addButton(int position, BInventoryButton button)
      Adds the button.
      Parameters:
      position - the position
      button - the button
    • addData

      public BInventory addData(String key, Object object)
      Add data to this inventory.
      Parameters:
      key - the key
      object - the value
      Returns:
      this inventory
    • addPlaceholder

      public BInventory addPlaceholder(String toReplace, String replaceWith)
      Add a placeholder to this inventory.
      Parameters:
      toReplace - the string to replace
      replaceWith - 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 instance
      delay - the initial delay
      interval - the update interval
      runnable - the runnable to execute
    • cancelTimer

      public void cancelTimer()
      Cancel all scheduled timers for this inventory.
    • closeInv

      public void closeInv(org.bukkit.entity.Player p, BInventoryButton b)
      Close the inventory for a player after button click.
      Parameters:
      p - the player
      b - the button that was clicked
    • dontClose

      public BInventory 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

      public Map<Integer,BInventoryButton> getButtons()
      Gets the buttons.
      Returns:
      the buttons
    • getData

      public HashMap<String,Object> getData()
      Returns:
      the data
    • getData

      public Object getData(String key)
      Get data by key.
      Parameters:
      key - the key
      Returns:
      the data value
    • getData

      public Object getData(String key, Object defaultValue)
      Get data by key with default value.
      Parameters:
      key - the key
      defaultValue - 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

      public String 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

      public Object getMeta(org.bukkit.entity.Player player, String str)
      Get meta from player.
      Parameters:
      player - the player
      str - 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

      public ArrayList<BInventoryButton> 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

      public BInventory noSound()
      Disable sound for this inventory.
      Returns:
      this inventory
    • onClick

      public void onClick(org.bukkit.event.inventory.InventoryClickEvent event, BInventoryButton b)
      Handle button click.
      Parameters:
      event - the inventory click event
      b - 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 player
      page - the page
    • playSound

      public void playSound(org.bukkit.entity.Player player)
      Play sound for a player.
      Parameters:
      player - the player
    • requirePermission

      public void requirePermission(String permission)
      Require permission to open this inventory.
      Parameters:
      permission - the permission required
    • setButtons

      public void setButtons(Map<Integer,BInventoryButton> buttons)
      Parameters:
      buttons - the buttons to set
    • setCloseInv

      public BInventory setCloseInv(boolean value)
      Set whether the inventory should close after interaction.
      Parameters:
      value - whether to close
      Returns:
      this inventory
    • setInventoryName

      public void setInventoryName(String inventoryName)
      Sets the inventory name.
      Parameters:
      inventoryName - the new inventory name
    • setMaxInvSize

      public void setMaxInvSize(int maxInvSize)
      Parameters:
      maxInvSize - the maxInvSize to set
    • setMeta

      public void setMeta(org.bukkit.entity.Player player, String str, Object ob)
      Sets the meta.
      Parameters:
      player - the player
      str - the str
      ob - the ob
    • setNextItem

      public void setNextItem(org.bukkit.inventory.ItemStack nextItem)
      Parameters:
      nextItem - the nextItem to set
    • setPageButtons

      public void setPageButtons(ArrayList<BInventoryButton> pageButtons)
      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