Class BaseInventory

java.lang.Object
org.cloudburstmc.server.inventory.BaseInventory
All Implemented Interfaces:
org.cloudburstmc.api.inventory.Inventory
Direct Known Subclasses:
CloudAnvilInventory, CloudBeaconInventory, CloudContainer, CloudCraftingGrid, CloudCreatureInventory, CloudEnchantInventory, PlayerCursorInventory

public abstract class BaseInventory extends Object implements org.cloudburstmc.api.inventory.Inventory
author: MagicDroidX Nukkit Project
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.cloudburstmc.api.inventory.InventoryHolder
     
    protected int
     
    protected String
     
    protected int
     
    it.unimi.dsi.fastutil.ints.Int2ObjectMap<org.cloudburstmc.api.item.ItemStack>
     
    protected String
     
    protected org.cloudburstmc.api.inventory.InventoryType
     
    protected Set<CloudPlayer>
     

    Fields inherited from interface org.cloudburstmc.api.inventory.Inventory

    MAX_STACK
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseInventory​(org.cloudburstmc.api.inventory.InventoryHolder holder, org.cloudburstmc.api.inventory.InventoryType type)
     
    BaseInventory​(org.cloudburstmc.api.inventory.InventoryHolder holder, org.cloudburstmc.api.inventory.InventoryType type, Map<Integer,​org.cloudburstmc.api.item.ItemStack> contents)
     
    BaseInventory​(org.cloudburstmc.api.inventory.InventoryHolder holder, org.cloudburstmc.api.inventory.InventoryType type, Map<Integer,​org.cloudburstmc.api.item.ItemStack> contents, Integer overrideSize)
     
    BaseInventory​(org.cloudburstmc.api.inventory.InventoryHolder holder, org.cloudburstmc.api.inventory.InventoryType type, Map<Integer,​org.cloudburstmc.api.item.ItemStack> contents, Integer overrideSize, String overrideTitle)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.cloudburstmc.api.item.ItemStack[]
    addItem​(org.cloudburstmc.api.item.ItemStack... slots)
     
    boolean
    addItemToFirstEmptySlot​(org.cloudburstmc.api.item.ItemStack item)
     
    Map<Integer,​org.cloudburstmc.api.item.ItemStack>
    all​(org.cloudburstmc.api.item.ItemStack item)
     
    boolean
    canAddItem​(org.cloudburstmc.api.item.ItemStack item)
     
    boolean
    clear​(int index, boolean send)
     
    void
     
    void
    close​(org.cloudburstmc.api.player.Player who)
     
    boolean
    contains​(org.cloudburstmc.api.item.ItemStack item)
     
    void
    decrementCount​(int slot)
     
    int
    first​(org.cloudburstmc.api.item.ItemStack item, boolean exact)
     
    int
     
    int
    firstFit​(org.cloudburstmc.api.item.ItemStack item, boolean single)
     
    int
     
    Map<Integer,​org.cloudburstmc.api.item.ItemStack>
     
    protected int
     
    int
    getFreeSpace​(org.cloudburstmc.api.item.ItemStack item)
     
    org.cloudburstmc.api.inventory.InventoryHolder
     
    getItem​(int index)
     
    int
     
     
    int
     
     
    org.cloudburstmc.api.inventory.InventoryType
     
     
    void
    incrementCount​(int slot)
     
    boolean
     
    boolean
     
    void
    onClose​(org.cloudburstmc.api.player.Player who)
     
    void
    onOpen​(org.cloudburstmc.api.player.Player who)
     
    void
    onSlotChange​(int index, org.cloudburstmc.api.item.ItemStack before, boolean send)
     
    boolean
    open​(org.cloudburstmc.api.player.Player who)
     
    void
    remove​(org.cloudburstmc.api.item.ItemStack item)
     
    org.cloudburstmc.api.item.ItemStack[]
    removeItem​(org.cloudburstmc.api.item.ItemStack... slots)
     
    void
    saveInventory​(com.nukkitx.nbt.NbtMapBuilder tag)
     
    void
    sendContents​(org.cloudburstmc.api.player.Player... players)
     
    void
    sendSlot​(int index, org.cloudburstmc.api.player.Player... players)
     
    void
    setContents​(Map<Integer,​org.cloudburstmc.api.item.ItemStack> items)
     
    boolean
    setItem​(int index, org.cloudburstmc.api.item.ItemStack item, boolean send)
     
    void
    setMaxStackSize​(int maxStackSize)
     
    void
    setSize​(int size)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.cloudburstmc.api.inventory.Inventory

    clear, first, firstFit, sendContents, sendContents, sendSlot, sendSlot, setItem
  • Field Details

    • type

      protected final org.cloudburstmc.api.inventory.InventoryType type
    • maxStackSize

      protected int maxStackSize
    • size

      protected int size
    • name

      protected final String name
    • title

      protected final String title
    • slots

      public final it.unimi.dsi.fastutil.ints.Int2ObjectMap<org.cloudburstmc.api.item.ItemStack> slots
    • viewers

      protected final Set<CloudPlayer> viewers
    • holder

      protected org.cloudburstmc.api.inventory.InventoryHolder holder
  • Constructor Details

    • BaseInventory

      public BaseInventory(org.cloudburstmc.api.inventory.InventoryHolder holder, org.cloudburstmc.api.inventory.InventoryType type)
    • BaseInventory

      public BaseInventory(org.cloudburstmc.api.inventory.InventoryHolder holder, org.cloudburstmc.api.inventory.InventoryType type, Map<Integer,​org.cloudburstmc.api.item.ItemStack> contents)
    • BaseInventory

      public BaseInventory(org.cloudburstmc.api.inventory.InventoryHolder holder, org.cloudburstmc.api.inventory.InventoryType type, Map<Integer,​org.cloudburstmc.api.item.ItemStack> contents, Integer overrideSize)
    • BaseInventory

      public BaseInventory(org.cloudburstmc.api.inventory.InventoryHolder holder, org.cloudburstmc.api.inventory.InventoryType type, Map<Integer,​org.cloudburstmc.api.item.ItemStack> contents, Integer overrideSize, String overrideTitle)
  • Method Details

    • getSize

      public int getSize()
      Specified by:
      getSize in interface org.cloudburstmc.api.inventory.Inventory
    • setSize

      public void setSize(int size)
    • getMaxStackSize

      public int getMaxStackSize()
      Specified by:
      getMaxStackSize in interface org.cloudburstmc.api.inventory.Inventory
    • getName

      public String getName()
      Specified by:
      getName in interface org.cloudburstmc.api.inventory.Inventory
    • getTitle

      public String getTitle()
      Specified by:
      getTitle in interface org.cloudburstmc.api.inventory.Inventory
    • getItem

      public @NonNull CloudItemStack getItem(int index)
      Specified by:
      getItem in interface org.cloudburstmc.api.inventory.Inventory
    • getContents

      public Map<Integer,​org.cloudburstmc.api.item.ItemStack> getContents()
      Specified by:
      getContents in interface org.cloudburstmc.api.inventory.Inventory
    • setContents

      public void setContents(Map<Integer,​org.cloudburstmc.api.item.ItemStack> items)
      Specified by:
      setContents in interface org.cloudburstmc.api.inventory.Inventory
    • setItem

      public boolean setItem(int index, org.cloudburstmc.api.item.ItemStack item, boolean send)
      Specified by:
      setItem in interface org.cloudburstmc.api.inventory.Inventory
    • contains

      public boolean contains(org.cloudburstmc.api.item.ItemStack item)
      Specified by:
      contains in interface org.cloudburstmc.api.inventory.Inventory
    • all

      public Map<Integer,​org.cloudburstmc.api.item.ItemStack> all(org.cloudburstmc.api.item.ItemStack item)
      Specified by:
      all in interface org.cloudburstmc.api.inventory.Inventory
    • remove

      public void remove(org.cloudburstmc.api.item.ItemStack item)
      Specified by:
      remove in interface org.cloudburstmc.api.inventory.Inventory
    • first

      public int first(org.cloudburstmc.api.item.ItemStack item, boolean exact)
      Specified by:
      first in interface org.cloudburstmc.api.inventory.Inventory
    • firstEmpty

      public int firstEmpty()
      Specified by:
      firstEmpty in interface org.cloudburstmc.api.inventory.Inventory
    • firstNonEmpty

      public int firstNonEmpty()
      Specified by:
      firstNonEmpty in interface org.cloudburstmc.api.inventory.Inventory
    • firstFit

      public int firstFit(org.cloudburstmc.api.item.ItemStack item, boolean single)
      Specified by:
      firstFit in interface org.cloudburstmc.api.inventory.Inventory
    • decrementCount

      public void decrementCount(int slot)
      Specified by:
      decrementCount in interface org.cloudburstmc.api.inventory.Inventory
    • incrementCount

      public void incrementCount(int slot)
      Specified by:
      incrementCount in interface org.cloudburstmc.api.inventory.Inventory
    • canAddItem

      public boolean canAddItem(org.cloudburstmc.api.item.ItemStack item)
      Specified by:
      canAddItem in interface org.cloudburstmc.api.inventory.Inventory
    • addItem

      public org.cloudburstmc.api.item.ItemStack[] addItem(org.cloudburstmc.api.item.ItemStack... slots)
      Specified by:
      addItem in interface org.cloudburstmc.api.inventory.Inventory
    • getEmptySlotsCount

      protected int getEmptySlotsCount()
    • addItemToFirstEmptySlot

      public boolean addItemToFirstEmptySlot(org.cloudburstmc.api.item.ItemStack item)
    • removeItem

      public org.cloudburstmc.api.item.ItemStack[] removeItem(org.cloudburstmc.api.item.ItemStack... slots)
      Specified by:
      removeItem in interface org.cloudburstmc.api.inventory.Inventory
    • clear

      public boolean clear(int index, boolean send)
      Specified by:
      clear in interface org.cloudburstmc.api.inventory.Inventory
    • clearAll

      public void clearAll()
      Specified by:
      clearAll in interface org.cloudburstmc.api.inventory.Inventory
    • getViewers

      public Set<CloudPlayer> getViewers()
      Specified by:
      getViewers in interface org.cloudburstmc.api.inventory.Inventory
    • getHolder

      public org.cloudburstmc.api.inventory.InventoryHolder getHolder()
      Specified by:
      getHolder in interface org.cloudburstmc.api.inventory.Inventory
    • setMaxStackSize

      public void setMaxStackSize(int maxStackSize)
      Specified by:
      setMaxStackSize in interface org.cloudburstmc.api.inventory.Inventory
    • open

      public boolean open(org.cloudburstmc.api.player.Player who)
      Specified by:
      open in interface org.cloudburstmc.api.inventory.Inventory
    • close

      public void close(org.cloudburstmc.api.player.Player who)
      Specified by:
      close in interface org.cloudburstmc.api.inventory.Inventory
    • onOpen

      public void onOpen(org.cloudburstmc.api.player.Player who)
      Specified by:
      onOpen in interface org.cloudburstmc.api.inventory.Inventory
    • onClose

      public void onClose(org.cloudburstmc.api.player.Player who)
      Specified by:
      onClose in interface org.cloudburstmc.api.inventory.Inventory
    • onSlotChange

      public void onSlotChange(int index, org.cloudburstmc.api.item.ItemStack before, boolean send)
      Specified by:
      onSlotChange in interface org.cloudburstmc.api.inventory.Inventory
    • sendContents

      public void sendContents(org.cloudburstmc.api.player.Player... players)
      Specified by:
      sendContents in interface org.cloudburstmc.api.inventory.Inventory
    • isFull

      public boolean isFull()
      Specified by:
      isFull in interface org.cloudburstmc.api.inventory.Inventory
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface org.cloudburstmc.api.inventory.Inventory
    • getFreeSpace

      public int getFreeSpace(org.cloudburstmc.api.item.ItemStack item)
      Specified by:
      getFreeSpace in interface org.cloudburstmc.api.inventory.Inventory
    • sendSlot

      public void sendSlot(int index, org.cloudburstmc.api.player.Player... players)
      Specified by:
      sendSlot in interface org.cloudburstmc.api.inventory.Inventory
    • saveInventory

      public void saveInventory(com.nukkitx.nbt.NbtMapBuilder tag)
    • getType

      public org.cloudburstmc.api.inventory.InventoryType getType()
      Specified by:
      getType in interface org.cloudburstmc.api.inventory.Inventory