本文整理了Java中org.bukkit.inventory.Inventory.getStorageContents()
方法的一些代码示例,展示了Inventory.getStorageContents()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Inventory.getStorageContents()
方法的具体详情如下:
包路径:org.bukkit.inventory.Inventory
类名称:Inventory
方法名:getStorageContents
暂无
代码示例来源:origin: ChestShop-authors/ChestShop-3
private static ItemStack[] getStorageContents(Inventory inventory) {
if (legacyContents == null) {
try {
inventory.getStorageContents();
legacyContents = false;
} catch (NoSuchMethodError e) {
legacyContents = true;
}
}
return legacyContents ? inventory.getContents() : inventory.getStorageContents();
}
代码示例来源:origin: CitizensDev/CitizensAPI
@EventHandler(ignoreCancelled = true)
public void inventoryCloseEvent(InventoryCloseEvent event) {
if (!views.contains(event.getView()))
return;
ItemStack[] contents = event.getInventory().getContents();
for (int i = 0; i < contents.length; i++) {
this.contents[i] = contents[i];
if (i == 0) {
npc.getTrait(Equipment.class).setItemInHand(contents[i]);
}
}
if (npc.getEntity() instanceof InventoryHolder) {
try {
int maxSize = ((InventoryHolder) npc.getEntity()).getInventory().getStorageContents().length;
((InventoryHolder) npc.getEntity()).getInventory().setStorageContents(Arrays.copyOf(contents, maxSize));
} catch (NoSuchMethodError e) {
int maxSize = ((InventoryHolder) npc.getEntity()).getInventory().getContents().length;
((InventoryHolder) npc.getEntity()).getInventory().setContents(Arrays.copyOf(contents, maxSize));
}
}
views.remove(event.getView());
}
内容来源于网络,如有侵权,请联系作者删除!