use of org.bukkit.inventory.ItemStack in project Essentials by drtshock.
the class SignTrade method subtractAmount.
protected final void subtractAmount(final ISign sign, final int index, final Trade trade, final IEssentials ess) throws SignException {
final BigDecimal money = trade.getMoney();
if (money != null) {
changeAmount(sign, index, money.negate(), ess);
}
final ItemStack item = trade.getItemStack();
if (item != null) {
changeAmount(sign, index, BigDecimal.valueOf(-item.getAmount()), ess);
}
final Integer exp = trade.getExperience();
if (exp != null) {
changeAmount(sign, index, BigDecimal.valueOf(-exp.intValue()), ess);
}
}
use of org.bukkit.inventory.ItemStack in project Essentials by drtshock.
the class EssentialsPlayerListener method onPlayerEggThrow.
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerEggThrow(final PlayerEggThrowEvent event) {
final User user = ess.getUser(event.getPlayer());
final ItemStack stack = new ItemStack(Material.EGG, 1);
if (user.hasUnlimited(stack)) {
user.getBase().getInventory().addItem(stack);
user.getBase().updateInventory();
}
}
use of org.bukkit.inventory.ItemStack in project Essentials by drtshock.
the class ItemDb method get.
@Override
public ItemStack get(final String id, final int quantity) throws Exception {
final ItemStack retval = get(id.toLowerCase(Locale.ENGLISH));
retval.setAmount(quantity);
return retval;
}
use of org.bukkit.inventory.ItemStack in project Essentials by drtshock.
the class v1_8_R2SpawnerProvider method setEntityType.
@Override
public ItemStack setEntityType(ItemStack is, EntityType type) {
net.minecraft.server.v1_8_R2.ItemStack itemStack;
CraftItemStack craftStack = CraftItemStack.asCraftCopy(is);
itemStack = CraftItemStack.asNMSCopy(craftStack);
NBTTagCompound tag = itemStack.getTag();
if (tag == null) {
tag = new NBTTagCompound();
itemStack.setTag(tag);
}
if (!tag.hasKey("BlockEntityTag")) {
tag.set("BlockEntityTag", new NBTTagCompound());
}
tag = itemStack.getTag().getCompound("BlockEntityTag");
tag.setString("EntityId", type.getName());
ItemStack bukkitItemStack = CraftItemStack.asCraftMirror(itemStack).clone();
return setDisplayName(bukkitItemStack, type);
}
use of org.bukkit.inventory.ItemStack in project Essentials by drtshock.
the class SpawnEggProvider method tryProvider.
@Override
public boolean tryProvider() {
try {
EntityType type = EntityType.CREEPER;
ItemStack is = createEggItem(type);
EntityType readType = getSpawnedType(is);
return type == readType;
} catch (Throwable t) {
return false;
}
}
Aggregations