本文整理汇总了Java中org.bukkit.inventory.meta.BlockStateMeta.hasBlockState方法的典型用法代码示例。如果您正苦于以下问题:Java BlockStateMeta.hasBlockState方法的具体用法?Java BlockStateMeta.hasBlockState怎么用?Java BlockStateMeta.hasBlockState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.meta.BlockStateMeta
的用法示例。
在下文中一共展示了BlockStateMeta.hasBlockState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: containsBook
import org.bukkit.inventory.meta.BlockStateMeta; //导入方法依赖的package包/类
public static boolean containsBook(ItemStack item) {
if (item.hasItemMeta() && item.getItemMeta() instanceof BlockStateMeta) {
BlockStateMeta blockStateMeta = (BlockStateMeta) item.getItemMeta();
if (blockStateMeta.hasBlockState() && blockStateMeta.getBlockState() instanceof InventoryHolder) {
InventoryHolder inventoryHolder = (InventoryHolder) blockStateMeta.getBlockState();
for (ItemStack itemStack : inventoryHolder.getInventory().getContents()) {
if (itemStack != null && itemStack.getType() != Material.AIR &&
itemStack.hasItemMeta() && itemStack.getItemMeta() instanceof BookMeta) {
return true;
}
}
}
}
return false;
}
示例2: fromItemStack
import org.bukkit.inventory.meta.BlockStateMeta; //导入方法依赖的package包/类
public static SignContent fromItemStack(ItemStack item) {
SignContent content = new SignContent();
if (item.hasItemMeta() && item.getItemMeta() instanceof BlockStateMeta) {
BlockStateMeta blockStateMeta = (BlockStateMeta) item.getItemMeta();
if (blockStateMeta.hasBlockState() && blockStateMeta.getBlockState() instanceof Sign) {
Sign sign = ((Sign) blockStateMeta.getBlockState());
for (int i = 0; i < 4; i++) {
content.setLine(i, sign.getLine(i));
}
}
}
return content;
}
示例3: getItemJsonStripped
import org.bukkit.inventory.meta.BlockStateMeta; //导入方法依赖的package包/类
private String getItemJsonStripped(ItemStack item) {
ItemStack cloned = item.clone();
if (cloned.hasItemMeta() && cloned.getItemMeta() instanceof BookMeta) {
return ItemStackUtils.itemToJson(removeBookContent(cloned));
}
if (cloned.hasItemMeta() && cloned.getItemMeta() instanceof BlockStateMeta) {
BlockStateMeta blockStateMeta = (BlockStateMeta) cloned.getItemMeta();
if (blockStateMeta.hasBlockState() && blockStateMeta.getBlockState() instanceof InventoryHolder) {
InventoryHolder inventoryHolder = (InventoryHolder) blockStateMeta.getBlockState();
ArrayList<ItemStack> items = new ArrayList<>();
for (int i = 0; i < inventoryHolder.getInventory().getSize(); i++) {
ItemStack itemStack = inventoryHolder.getInventory().getItem(i);
if (itemStack != null && itemStack.getType() != Material.AIR) {
if (items.size() < 5) {
if (itemStack.hasItemMeta()) {
if (itemStack.getItemMeta().hasLore()) {
ItemMeta meta = itemStack.getItemMeta();
meta.setLore(new ArrayList<String>());
itemStack.setItemMeta(meta);
}
if (itemStack.getItemMeta() instanceof BookMeta) {
itemStack = removeBookContent(itemStack);
}
}
items.add(itemStack);
} else {
items.add(new ItemStack(Material.STONE));
}
}
}
inventoryHolder.getInventory().clear();
for (int i = 0; i < items.size(); i++) {
inventoryHolder.getInventory().setItem(i, items.get(i));
}
blockStateMeta.setBlockState((BlockState) inventoryHolder);
cloned.setItemMeta(blockStateMeta);
return ItemStackUtils.itemToJson(cloned);
}
}
return ItemStackUtils.itemToJson(cloned);
}