Search in sources :

Example 46 with ItemTag

use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.

the class PlayerPreparesAnvilCraftScriptEvent method onCraftItem.

@EventHandler
public void onCraftItem(PrepareAnvilEvent event) {
    if (event.getInventory().getViewers().isEmpty()) {
        return;
    }
    HumanEntity humanEntity = event.getInventory().getViewers().get(0);
    if (EntityTag.isNPC(humanEntity)) {
        return;
    }
    this.event = event;
    result = new ItemTag(event.getResult());
    this.player = EntityTag.getPlayerFrom(humanEntity);
    this.cancelled = false;
    fire(event);
}
Also used : HumanEntity(org.bukkit.entity.HumanEntity) ItemTag(com.denizenscript.denizen.objects.ItemTag) EventHandler(org.bukkit.event.EventHandler)

Example 47 with ItemTag

use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.

the class EntityFirework method getObjectAttribute.

@Override
public ObjectTag getObjectAttribute(Attribute attribute) {
    if (attribute == null) {
        return null;
    }
    // -->
    if (attribute.startsWith("firework_item")) {
        ItemStack item = new ItemStack(Material.FIREWORK_ROCKET);
        item.setItemMeta(((Firework) firework.getBukkitEntity()).getFireworkMeta());
        return new ItemTag(item).getObjectAttribute(attribute.fulfill(1));
    }
    return null;
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) ItemTag(com.denizenscript.denizen.objects.ItemTag)

Example 48 with ItemTag

use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.

the class ItemChangeMessage method sendMessage.

public static void sendMessage(Player player, String message) {
    ItemStack item = player.getEquipment().getItemInMainHand();
    // which is probably the least intrusive
    if (item == null || item.getType() == Material.AIR) {
        item = new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE);
    } else {
        item = item.clone();
    }
    ItemTag itemTag = new ItemTag(item);
    NMSHandler.getItemHelper().setDisplayName(itemTag, message);
    int slot = player.getInventory().getHeldItemSlot() + 36;
    NMSHandler.getPacketHelper().setSlot(player, slot, item, true);
    slotChanged.put(player.getUniqueId(), slot);
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) ItemTag(com.denizenscript.denizen.objects.ItemTag)

Example 49 with ItemTag

use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.

the class EntityShootsBowEvent method onEntityShootsBow.

@EventHandler
public void onEntityShootsBow(EntityShootBowEvent event) {
    entity = new EntityTag(event.getEntity());
    bow = new ItemTag(event.getBow());
    Entity projectileEntity = event.getProjectile();
    EntityTag.rememberEntity(projectileEntity);
    projectile = new EntityTag(projectileEntity);
    this.event = event;
    fire(event);
    EntityTag.forgetEntity(projectileEntity);
}
Also used : Entity(org.bukkit.entity.Entity) EntityTag(com.denizenscript.denizen.objects.EntityTag) ItemTag(com.denizenscript.denizen.objects.ItemTag) EventHandler(org.bukkit.event.EventHandler)

Example 50 with ItemTag

use of com.denizenscript.denizen.objects.ItemTag in project Denizen-For-Bukkit by DenizenScript.

the class FireworkBurstsScriptEvent method getContext.

@Override
public ObjectTag getContext(String name) {
    switch(name) {
        case "entity":
            return entity;
        case "location":
            return location;
        case "item":
            ItemStack itemStack = new ItemStack(Material.FIREWORK_ROCKET);
            itemStack.setItemMeta(event.getEntity().getFireworkMeta());
            return new ItemTag(itemStack);
    }
    return super.getContext(name);
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) ItemTag(com.denizenscript.denizen.objects.ItemTag)

Aggregations

ItemTag (com.denizenscript.denizen.objects.ItemTag)77 EventHandler (org.bukkit.event.EventHandler)35 ItemStack (org.bukkit.inventory.ItemStack)20 LocationTag (com.denizenscript.denizen.objects.LocationTag)19 EntityTag (com.denizenscript.denizen.objects.EntityTag)14 ListTag (com.denizenscript.denizencore.objects.core.ListTag)14 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)13 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)9 Item (org.bukkit.entity.Item)7 Argument (com.denizenscript.denizencore.objects.Argument)6 List (java.util.List)6 InvalidArgumentsException (com.denizenscript.denizencore.exceptions.InvalidArgumentsException)5 ScriptTag (com.denizenscript.denizencore.objects.core.ScriptTag)5 HumanEntity (org.bukkit.entity.HumanEntity)5 Player (org.bukkit.entity.Player)5 InventoryTag (com.denizenscript.denizen.objects.InventoryTag)4 BukkitTagContext (com.denizenscript.denizen.tags.BukkitTagContext)4 DurationTag (com.denizenscript.denizencore.objects.core.DurationTag)4 ArrayList (java.util.ArrayList)4 MaterialTag (com.denizenscript.denizen.objects.MaterialTag)3