类 InventoryView

java.lang.Object
org.bukkit.inventory.InventoryView

public abstract class InventoryView extends Object
Represents a view linking two inventories and a single player (whose inventory may or may not be one of the two).

Note: If you implement this interface but fail to satisfy the expected contracts of certain methods, there's no guarantee that the game will work as it should.

  • 嵌套类概要

    嵌套类
    修饰符和类型
    说明
    static enum 
    Represents various extra properties of certain inventory windows.
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final int
     
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    final void
    Closes the inventory view.
    final int
    convertSlot(int rawSlot)
    Converts a raw slot ID into its local slot ID into whichever of the two inventories the slot points to.
    final int
    Check the total number of slots in this view, combining the upper and lower inventories.
    abstract Inventory
    Get the lower inventory involved in this transaction.
    final ItemStack
    Get the item on the cursor of one of the viewing players.
    getItem(int slot)
    Gets one item in this inventory view by its raw slot ID.
    abstract HumanEntity
    Get the player viewing.
    final String
    Get the title of this inventory window.
    abstract Inventory
    Get the upper inventory involved in this transaction.
    abstract InventoryType
    Determine the type of inventory involved in the transaction.
    final void
    Sets the item on the cursor of one of the viewing players.
    void
    setItem(int slot, ItemStack item)
    Sets one item in this inventory view by its raw slot ID.
    final boolean
    Sets an extra property of this inventory if supported by that inventory, for example the state of a progress bar.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

  • 构造器详细资料

    • InventoryView

      public InventoryView()
  • 方法详细资料

    • getTopInventory

      public abstract Inventory getTopInventory()
      Get the upper inventory involved in this transaction.
      返回:
      the inventory
    • getBottomInventory

      public abstract Inventory getBottomInventory()
      Get the lower inventory involved in this transaction.
      返回:
      the inventory
    • getPlayer

      public abstract HumanEntity getPlayer()
      Get the player viewing.
      返回:
      the player
    • getType

      public abstract InventoryType getType()
      Determine the type of inventory involved in the transaction. This indicates the window style being shown. It will never return PLAYER, since that is common to all windows.
      返回:
      the inventory type
    • setItem

      public void setItem(int slot, ItemStack item)
      Sets one item in this inventory view by its raw slot ID.

      Note: If slot ID -999 is chosen, it may be expected that the item is dropped on the ground. This is not required behaviour, however.

      参数:
      slot - The ID as returned by InventoryClickEvent.getRawSlot()
      item - The new item to put in the slot, or null to clear it.
    • getItem

      public ItemStack getItem(int slot)
      Gets one item in this inventory view by its raw slot ID.
      参数:
      slot - The ID as returned by InventoryClickEvent.getRawSlot()
      返回:
      The item currently in the slot.
    • setCursor

      public final void setCursor(ItemStack item)
      Sets the item on the cursor of one of the viewing players.
      参数:
      item - The item to put on the cursor, or null to remove the item on their cursor.
    • getCursor

      public final ItemStack getCursor()
      Get the item on the cursor of one of the viewing players.
      返回:
      The item on the player's cursor, or null if they aren't holding one.
    • convertSlot

      public final int convertSlot(int rawSlot)
      Converts a raw slot ID into its local slot ID into whichever of the two inventories the slot points to.

      If the raw slot refers to the upper inventory, it will be returned unchanged and thus be suitable for getTopInventory().getItem(); if it refers to the lower inventory, the output will differ from the input and be suitable for getBottomInventory().getItem().

      参数:
      rawSlot - The raw slot ID.
      返回:
      The converted slot ID.
    • close

      public final void close()
      Closes the inventory view.
    • countSlots

      public final int countSlots()
      Check the total number of slots in this view, combining the upper and lower inventories.

      Note though that it's possible for this to be greater than the sum of the two inventories if for example some slots are not being used.

      返回:
      The total size
    • setProperty

      public final boolean setProperty(InventoryView.Property prop, int value)
      Sets an extra property of this inventory if supported by that inventory, for example the state of a progress bar.
      参数:
      prop - the window property to update
      value - the new value for the window property
      返回:
      true if the property was updated successfully, false if the property is not supported by that inventory
    • getTitle

      public final String getTitle()
      Get the title of this inventory window.
      返回:
      The title.