Bukkit  1.4.7-R1.0
 All Classes Namespaces Files Functions Variables Enumerator Pages
org.bukkit.inventory.InventoryView Class Referenceabstract

Represents a view linking two inventories and a single player (whose inventory may or may not be one of the two) More...

Classes

enum  Property
 Represents various extra properties of certain inventory windows. More...
 

Public Member Functions

abstract Inventory getTopInventory ()
 Get the upper inventory involved in this transaction.
 
abstract Inventory getBottomInventory ()
 Get the lower inventory involved in this transaction.
 
abstract HumanEntity getPlayer ()
 Get the player viewing.
 
abstract InventoryType getType ()
 Determine the type of inventory involved in the transaction.
 
void setItem (int slot, ItemStack item)
 Sets one item in this inventory view by its raw slot ID.
 
ItemStack getItem (int slot)
 Gets one item in this inventory view by its raw slot ID.
 
final void setCursor (ItemStack item)
 Sets the item on the cursor of one of the viewing players.
 
final ItemStack getCursor ()
 Get the item on the cursor of one of the viewing players.
 
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 void close ()
 Closes the inventory view.
 
final int countSlots ()
 Check the total number of slots in this view, combining the upper and lower inventories.
 
final boolean setProperty (Property prop, int value)
 
final String getTitle ()
 Get the title of this inventory window.
 

Static Public Attributes

static final int OUTSIDE = -999
 

Detailed Description

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.

Definition at line 14 of file InventoryView.java.

Member Function Documentation

final void org.bukkit.inventory.InventoryView.close ( )

Closes the inventory view.

Definition at line 168 of file InventoryView.java.

References org.bukkit.entity.HumanEntity.closeInventory(), and org.bukkit.inventory.InventoryView.getPlayer().

final int org.bukkit.inventory.InventoryView.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().

Parameters
rawSlotThe raw slot ID.
Returns
The converted slot ID.

Definition at line 150 of file InventoryView.java.

References org.bukkit.event.inventory.InventoryType.CRAFTING, org.bukkit.inventory.Inventory.getSize(), org.bukkit.inventory.InventoryView.getTopInventory(), and org.bukkit.inventory.InventoryView.getType().

Referenced by org.bukkit.inventory.InventoryView.getItem(), org.bukkit.event.inventory.InventoryClickEvent.InventoryClickEvent(), and org.bukkit.inventory.InventoryView.setItem().

final int org.bukkit.inventory.InventoryView.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.

Returns
The total size

Definition at line 178 of file InventoryView.java.

References org.bukkit.inventory.InventoryView.getBottomInventory(), org.bukkit.inventory.Inventory.getSize(), and org.bukkit.inventory.InventoryView.getTopInventory().

abstract Inventory org.bukkit.inventory.InventoryView.getBottomInventory ( )
pure virtual

Get the lower inventory involved in this transaction.

Returns
the inventory

Referenced by org.bukkit.inventory.InventoryView.countSlots(), org.bukkit.inventory.InventoryView.getItem(), and org.bukkit.inventory.InventoryView.setItem().

final ItemStack org.bukkit.inventory.InventoryView.getCursor ( )

Get the item on the cursor of one of the viewing players.

Returns
The item on the player's cursor, or null if they aren't holding one.

Definition at line 137 of file InventoryView.java.

References org.bukkit.entity.HumanEntity.getItemOnCursor(), and org.bukkit.inventory.InventoryView.getPlayer().

Referenced by org.bukkit.event.inventory.InventoryClickEvent.getCursor().

ItemStack org.bukkit.inventory.InventoryView.getItem ( int  slot)

Gets one item in this inventory view by its raw slot ID.

Parameters
slotThe ID as returned by InventoryClickEvent.getRawSlot()
Returns
The item currently in the slot.

Definition at line 114 of file InventoryView.java.

References org.bukkit.inventory.InventoryView.convertSlot(), org.bukkit.inventory.InventoryView.getBottomInventory(), org.bukkit.inventory.Inventory.getItem(), org.bukkit.inventory.InventoryView.getTopInventory(), and org.bukkit.inventory.InventoryView.OUTSIDE.

Referenced by org.bukkit.event.inventory.InventoryClickEvent.getCurrentItem().

final String org.bukkit.inventory.InventoryView.getTitle ( )

Get the title of this inventory window.

Returns
The title.

Definition at line 190 of file InventoryView.java.

References org.bukkit.inventory.Inventory.getTitle(), and org.bukkit.inventory.InventoryView.getTopInventory().

abstract InventoryType org.bukkit.inventory.InventoryView.getType ( )
pure virtual

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.

Returns
the inventory type

Referenced by org.bukkit.inventory.InventoryView.convertSlot().

final void org.bukkit.inventory.InventoryView.setCursor ( ItemStack  item)

Sets the item on the cursor of one of the viewing players.

Parameters
itemThe item to put on the cursor, or null to remove the item on their cursor.

Definition at line 129 of file InventoryView.java.

References org.bukkit.inventory.InventoryView.getPlayer(), and org.bukkit.entity.HumanEntity.setItemOnCursor().

Referenced by org.bukkit.event.inventory.InventoryClickEvent.setCursor().

void org.bukkit.inventory.InventoryView.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.

Parameters
slotThe ID as returned by InventoryClickEvent.getRawSlot()
itemThe new item to put in the slot, or null to clear it.

Definition at line 97 of file InventoryView.java.

References org.bukkit.inventory.InventoryView.convertSlot(), org.bukkit.World.dropItemNaturally(), org.bukkit.inventory.InventoryView.getBottomInventory(), org.bukkit.inventory.InventoryView.getPlayer(), org.bukkit.inventory.InventoryView.getTopInventory(), org.bukkit.entity.Entity.getWorld(), org.bukkit.inventory.InventoryView.OUTSIDE, and org.bukkit.inventory.Inventory.setItem().

Referenced by org.bukkit.event.inventory.InventoryClickEvent.setCurrentItem().

final boolean org.bukkit.inventory.InventoryView.setProperty ( Property  prop,
int  value 
)

Member Data Documentation

final int org.bukkit.inventory.InventoryView.OUTSIDE = -999
static

The documentation for this class was generated from the following file: