/** * Convenience method. Returns the material of the item represented by * this event * * @return Material the material of the item used */ public Material getMaterial() { if (!hasItem()) { return Material.AIR; } return item.getType(); }
/** * Check whether this target includes the specified item. * * @param item The item to check * @return True if the target includes the item */ public boolean includes(ItemStack item) { return includes(item.getType()); } }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { if (tool != null && tool.getType() == Material.SHEARS) { return Arrays.asList(new ItemStack(Material.VINE)); } return BlockDropless.EMPTY_STACK; }
public static Potion fromItemStack(ItemStack item) { Validate.notNull(item, "item cannot be null"); if (item.getType() != Material.POTION) throw new IllegalArgumentException("item is not a potion"); return fromDamage(item.getDurability()); }
@Override @Utility public String toString() { StringBuilder toString = new StringBuilder("ItemStack{").append(getType().name()).append(" x ").append(getAmount()); if (hasItemMeta()) { toString.append(", ").append(getItemMeta()); } return toString.append('}').toString(); }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { if (tool != null && ToolType.SPADE.matches(tool.getType())) { return Arrays.asList(new ItemStack(Material.SNOW_BALL, 4)); } else { return BlockDropless.EMPTY_STACK; } }
/** * Convenience method to inform the user whether this was a block * placement event. * * @return boolean true if the item in hand was a block */ public boolean isBlockInHand() { if (!hasItem()) { return false; } return item.getType().isBlock(); }
/** * Get the maximum stacksize for the material hold in this ItemStack. * (Returns -1 if it has no idea) * * @return The maximum you can stack this material to. */ @Utility public int getMaxStackSize() { Material material = getType(); if (material != null) { return material.getMaxStackSize(); } return -1; }
/** * Applies the effects of this potion to the given {@link ItemStack}. The * ItemStack must be a potion. * * @param to The itemstack to apply to */ public void apply(ItemStack to) { Validate.notNull(to, "itemstack cannot be null"); Validate.isTrue(to.getType() == Material.POTION, "given itemstack is not a potion"); to.setDurability(toDamageValue()); }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { if (tool != null && ToolType.SPADE.matches(tool.getType())) { return Arrays.asList(new ItemStack(Material.SNOW_BALL, block.getData() + 1)); } else { return BlockDropless.EMPTY_STACK; } }
/** * Gets the MaterialData for this stack of items * * @return MaterialData for this item */ public MaterialData getData() { Material mat = getType(); if (data == null && mat != null && mat.getData() != null) { data = mat.getNewData((byte) this.getDurability()); } return data; }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { if (block.getType() == Material.WOOD_STEP || tool != null && ToolType.PICKAXE.matches(tool.getType())) { return getMinedDrops(block); } return BlockDropless.EMPTY_STACK; }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { MaterialMatcher neededTool = getNeededMiningTool(block); if (neededTool != null && (tool == null || !neededTool.matches(tool.getType()))) { return BlockDropless.EMPTY_STACK; } return getMinedDrops(block); }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { if (block.getType() == Material.WOOD_DOUBLE_STEP || tool != null && ToolType.PICKAXE.matches(tool.getType())) { return getMinedDrops(block); } return BlockDropless.EMPTY_STACK; }
/** * Create a WorldEdit BaseItemStack from a Bukkit ItemStack * * @param itemStack The Bukkit ItemStack * @return The WorldEdit BaseItemStack */ public static BaseItemStack adapt(ItemStack itemStack) { checkNotNull(itemStack); return new BaseItemStack(ItemTypes.get(itemStack.getType().getKey().toString()), itemStack.getAmount()); }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { if (isWoodenStair(block.getType()) || tool != null && ToolType.PICKAXE.matches(tool.getType())) { return getMinedDrops(block); } return BlockDropless.EMPTY_STACK; }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { Collection<ItemStack> drops = getContentDrops(block); MaterialMatcher neededTool = getNeededMiningTool(block); if (neededTool == null || !InventoryUtil.isEmpty(tool) && neededTool .matches(InventoryUtil.itemOrEmpty(tool).getType())) { drops.addAll(getBlockDrops(block)); } return drops; }
protected ItemStack dispenseStack(GlowBlock block, ItemStack stack) { BlockFace facing = BlockDispenser.getFacing(block); Vector dispensePosition = BlockDispenser.getDispensePosition(block); ItemStack items = new ItemStack(stack.getType(), 1); stack.setAmount(stack.getAmount() - 1); doDispense(block, items, 6, facing, dispensePosition); return stack.getAmount() > 0 ? stack : null; }
@Override public void rightClickAir(GlowPlayer player, ItemStack holding) { if (InventoryUtil.isEmpty(player.getEquipment().getChestplate()) || player.getEquipment().getChestplate().getType() != Material.ELYTRA || !player .isGliding()) { return; } spawnFirework(player, holding, player.getLocation(), player.getUniqueId(), player); }