Class InventoryView
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.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumRepresents various extra properties of certain inventory windows.
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfinal voidclose()Closes the inventory view.final intconvertSlot(int rawSlot) Converts a raw slot ID into its local slot ID into whichever of the two inventories the slot points to.final intCheck the total number of slots in this view, combining the upper and lower inventories.Get the lower inventory involved in this transaction.Get the item on the cursor of one of the viewing players.getInventory(int rawSlot) Gets the inventory corresponding to the given raw slot ID.getItem(int slot) Gets one item in this inventory view by its raw slot ID.Get the original title of this inventory window, before any changes were made usingsetTitle(String).abstract @NotNull HumanEntityGet the player viewing.final InventoryType.SlotTypegetSlotType(int slot) Determine the type of the slot by its raw slot ID.getTitle()Deprecated.Get the upper inventory involved in this transaction.abstract @NotNull InventoryTypegetType()Determine the type of inventory involved in the transaction.final voidSets the item on the cursor of one of the viewing players.voidSets one item in this inventory view by its raw slot ID.final booleansetProperty(@NotNull 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.abstract voidSets the title of this inventory window to the specified title if the inventory window supports it.title()Get the title of this inventory window.
- 
Field Details- 
OUTSIDEpublic static final int OUTSIDE- See Also:
 
 
- 
- 
Constructor Details- 
InventoryViewpublic InventoryView()
 
- 
- 
Method Details- 
getTopInventoryGet the upper inventory involved in this transaction.- Returns:
- the inventory
 
- 
getBottomInventoryGet the lower inventory involved in this transaction.- Returns:
- the inventory
 
- 
getPlayerGet the player viewing.- Returns:
- the player
 
- 
getTypeDetermine 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
 
- 
setItemSets 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:
- slot- The ID as returned by InventoryClickEvent.getRawSlot()
- item- The new item to put in the slot, or null to clear it.
 
- 
getItemGets one item in this inventory view by its raw slot ID.- Parameters:
- slot- The ID as returned by InventoryClickEvent.getRawSlot()
- Returns:
- The item currently in the slot.
 
- 
setCursorSets the item on the cursor of one of the viewing players.- Parameters:
- item- The item to put on the cursor, or null to remove the item on their cursor.
 
- 
getCursorGet 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.
 
- 
getInventoryGets the inventory corresponding to the given raw slot ID. If the slot ID isOUTSIDEnull will be returned, otherwise behaviour for illegal and negative slot IDs is undefined. May be used withconvertSlot(int)to directly index an underlying inventory.- Parameters:
- rawSlot- The raw slot ID.
- Returns:
- corresponding inventory, or null
 
- 
convertSlotpublic 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(). - Parameters:
- rawSlot- The raw slot ID.
- Returns:
- The converted slot ID.
 
- 
getSlotTypeDetermine the type of the slot by its raw slot ID.If the type of the slot is unknown, then InventoryType.SlotType.CONTAINERwill be returned.- Parameters:
- slot- The raw slot ID
- Returns:
- the slot type
 
- 
closepublic final void close()Closes the inventory view.
- 
countSlotspublic 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. - Returns:
- The total size
 
- 
setPropertySets an extra property of this inventory if supported by that inventory, for example the state of a progress bar.- Parameters:
- prop- the window property to update
- value- the new value for the window property
- Returns:
- true if the property was updated successfully, false if the property is not supported by that inventory
 
- 
titleGet the title of this inventory window.- Returns:
- The title.
 
- 
getTitleDeprecated.in favour oftitle()Get the title of this inventory window.- Returns:
- The title.
 
- 
getOriginalTitleGet the original title of this inventory window, before any changes were made usingsetTitle(String).- Returns:
- the original title
 
- 
setTitleSets the title of this inventory window to the specified title if the inventory window supports it.Note if the inventory does not support titles that can be changed (ie, it is not creatable or viewed by a player), then this method will throw an exception. - Parameters:
- title- The new title.
 
 
- 
title()