Search in sources :

Example 91 with ItemStack

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);
    }
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) BigDecimal(java.math.BigDecimal)

Example 92 with ItemStack

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();
    }
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 93 with ItemStack

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;
}
Also used : ItemStack(org.bukkit.inventory.ItemStack)

Example 94 with ItemStack

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);
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_8_R2.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack)

Example 95 with ItemStack

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;
    }
}
Also used : EntityType(org.bukkit.entity.EntityType) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

ItemStack (org.bukkit.inventory.ItemStack)1420 Player (org.bukkit.entity.Player)270 EventHandler (org.bukkit.event.EventHandler)197 ItemMeta (org.bukkit.inventory.meta.ItemMeta)192 ArrayList (java.util.ArrayList)151 Inventory (org.bukkit.inventory.Inventory)127 Material (org.bukkit.Material)103 Location (org.bukkit.Location)96 PlayerInventory (org.bukkit.inventory.PlayerInventory)84 Entity (org.bukkit.entity.Entity)67 Block (org.bukkit.block.Block)54 LivingEntity (org.bukkit.entity.LivingEntity)51 TagCompound (de.keyle.knbt.TagCompound)47 HashMap (java.util.HashMap)47 Map (java.util.Map)46 Vector (org.bukkit.util.Vector)44 Enchantment (org.bukkit.enchantments.Enchantment)41 SkullMeta (org.bukkit.inventory.meta.SkullMeta)41 Mage (com.elmakers.mine.bukkit.api.magic.Mage)39 Test (org.junit.Test)38