public interface InventoryAPI
| 限定符和类型 | 方法和说明 |
|---|---|
java.util.Map<java.lang.Integer,org.bukkit.inventory.ItemStack> |
addItem(org.bukkit.inventory.ItemStack item)
Add item.
|
java.util.Map<java.lang.Integer,org.bukkit.inventory.ItemStack> |
addItem(ItemStackProxy itemStackProxy)
Add item.
|
void |
clearBackGround()
Clear back ground.
|
void |
clearView()
Clear view.
|
void |
create()
Create the inventory.
|
void |
forceSetItem(int position,
org.bukkit.inventory.ItemStack item)
Force set item.
|
java.lang.String |
getGroupTitle()
Gets group title.
|
org.bukkit.inventory.Inventory |
getInventory()
Gets inventory.
|
int |
getPageNumber()
Gets page number.
|
int |
getSize()
Gets size of the Inventory.
|
java.lang.String |
getTitle()
Gets title.
|
java.lang.String |
getUuid() |
boolean |
isBackGround(org.bukkit.inventory.ItemStack item)
Is back ground boolean.
|
boolean |
isLastLineDisabled()
Is last line disabled boolean.
|
boolean |
isPageButtonEnabled()
Is page button enabled boolean.
|
void |
presetPage(ViewType type)
Pre-set page.
|
void |
setBackgroundColor(Colors backgroundColor)
Sets background color.
|
void |
setItem(int position,
org.bukkit.inventory.ItemStack item)
Sets item.
|
void |
setLastLineDisabled(boolean disabled)
Sets last line of the inventory disabled
设置GUI最后一排为不可用
|
void |
setMiddleButton(Buttons middleButton)
Sets middle button.
|
void |
setPageButtonEnabled(boolean isPageButtonEnabled)
Sets page button enabled.
|
void create()
You should only invoke this method after done the inventory settings. (Such as Setting title, setting size) You should invoke this method before you do any Bukkit inventory operation. (Such as Adding items, clearing content) 你必须在完成所有对GUI的设置的后才可以调用这个方法。(比如设置名字,设置容量) 你必须在对GUI进行操作之前调用这个方法。(比如添加物品,清空物品)
void presetPage(ViewType type)
You can use pre-set page to create a view. 你可以使用预设界面来创建一个GUI。
type - the pre-set enum type 预设界面Enumvoid setItem(int position,
org.bukkit.inventory.ItemStack item)
You can set an item with a position in the inventory. When the position has already had an item, it will set to next slot. If it is the last slot in the inventory and it has already had an item, and the autoAddPage is true, it will generate the next page. 你可以在GUI中的一个位置设置一个物品。当此位置存在物品时,要设置的物品会自动移到下个格子。如果要设置的格子是GUI 的最后一个格子且已经有了物品并且autoAddPage设置为true,则会自动生成下一页。
position - the position 需要生成的位置item - the item 需要生成的物品void forceSetItem(int position,
org.bukkit.inventory.ItemStack item)
throws java.lang.IndexOutOfBoundsException
You can force set an item in the inventory. Unlike setItem method, it will not care about whether it has item at that position or not. This method will not generate next page when the position is bigger than inventory size, so it will give an IndexOutOfBoundsException when trying to set the item larger than inventory size. 你可以强制在GUI的某个位置设置物品。但是和addItem不同的是,这个方法不会考虑位置是否有物品。并且当位置大于GUI容量时, 这个方法不会生成下一页,所以当你尝试将一个物品设置到大于GUI容量的位置时会报出IndexOutOfBoundsException的错误。
position - the positionitem - the itemjava.lang.IndexOutOfBoundsException - the index out of bounds exceptionjava.util.Map<java.lang.Integer,org.bukkit.inventory.ItemStack> addItem(org.bukkit.inventory.ItemStack item)
You can add item into a view by using this method. Item can stack automatically if they have a same property. 你可以使用这个方法向一个界面中添加物品。物品会自动堆叠如果物品属性相同。
item - the itemjava.util.Map<java.lang.Integer,org.bukkit.inventory.ItemStack> addItem(ItemStackProxy itemStackProxy)
See addItem(ItemStack item) 详见 addItem(ItemStack item)
itemStackProxy - the item stack managerorg.bukkit.inventory.Inventory getInventory()
You can get the inventory of this InventoryProxy. You must only call this method AFTER call create(), otherwise you will get null. 你可以通过这个方法获取InventoryFactory的Inventory对象。你必须先调用create()方法,否则会返回null!
java.lang.String getTitle()
Get the tile of this inventory 获取这个inventory的标题
java.lang.String getGroupTitle()
Get the group name of this InventoryProxy object if it has a group name. Group name often appears when there are pages hook to the view. 获取这个InventoryFactory对象的组名。 组名一般出现在此界面拥有多个页面时。
int getSize()
You can only invoke this method after call create() 你必须先调用create()方法。
int getPageNumber()
boolean isPageButtonEnabled()
void setPageButtonEnabled(boolean isPageButtonEnabled)
isPageButtonEnabled - the is page button enabledboolean isLastLineDisabled()
void setLastLineDisabled(boolean disabled)
disabled - if disable last linevoid clearView()
Clear all the item in the view. However if last line disabled, the last line will not be cleared. 清除页面上的所有物品。但是如果最后一行被关闭了,则不会清除最后一行的物品。
void setBackgroundColor(Colors backgroundColor)
Set the background color of the Inventory. It will not rewrite the item that is already exists. 设置背景颜色,不会覆盖物品。
backgroundColor - the background colorvoid clearBackGround()
boolean isBackGround(org.bukkit.inventory.ItemStack item)
item - the itemvoid setMiddleButton(Buttons middleButton)
middleButton - the middle buttonjava.lang.String getUuid()