Search in sources :

Example 51 with ItemTag

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

the class PlayerItemTakesDamageScriptEvent method onPlayerItemTakesDamage.

@EventHandler
public void onPlayerItemTakesDamage(PlayerItemDamageEvent event) {
    if (EntityTag.isNPC(event.getPlayer())) {
        return;
    }
    item = new ItemTag(event.getItem());
    location = new LocationTag(event.getPlayer().getLocation());
    this.event = event;
    fire(event);
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) ItemTag(com.denizenscript.denizen.objects.ItemTag) EventHandler(org.bukkit.event.EventHandler)

Example 52 with ItemTag

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

the class PlayerCraftsItemScriptEvent method onCraftItem.

@EventHandler
public void onCraftItem(CraftItemEvent event) {
    // This event fires even when nothing crafts due to a cursor item, so disregard those cases.
    if (event.getClick() != ClickType.SHIFT_LEFT && event.getCursor() != null && event.getCursor().getType() != Material.AIR) {
        if (!event.getCursor().isSimilar(event.getCurrentItem())) {
            return;
        }
        if (event.getCursor().getAmount() + event.getRecipe().getResult().getAmount() > event.getCursor().getType().getMaxStackSize()) {
            return;
        }
    }
    HumanEntity humanEntity = event.getWhoClicked();
    if (EntityTag.isNPC(humanEntity)) {
        return;
    }
    this.event = event;
    result = new ItemTag(event.getInventory().getResult());
    if (result.getBukkitMaterial() == Material.AIR) {
        result = new ItemTag(event.getRecipe().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 53 with ItemTag

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

the class PlayerDragsInInvScriptEvent method onPlayerDragsInInv.

@EventHandler
public void onPlayerDragsInInv(InventoryDragEvent event) {
    if (EntityTag.isCitizensNPC(event.getWhoClicked())) {
        return;
    }
    entity = EntityTag.getPlayerFrom(event.getWhoClicked());
    inventory = event.getInventory();
    dInv = InventoryTag.mirrorBukkitInventory(inventory);
    item = new ItemTag(event.getOldCursor());
    this.event = event;
    fire(event);
}
Also used : ItemTag(com.denizenscript.denizen.objects.ItemTag) EventHandler(org.bukkit.event.EventHandler)

Example 54 with ItemTag

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

the class ItemDespawnsScriptEvent method onItemDespawns.

@EventHandler
public void onItemDespawns(ItemDespawnEvent event) {
    location = new LocationTag(event.getLocation());
    item = new ItemTag(event.getEntity().getItemStack());
    entity = new EntityTag(event.getEntity());
    this.event = event;
    fire(event);
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) EntityTag(com.denizenscript.denizen.objects.EntityTag) ItemTag(com.denizenscript.denizen.objects.ItemTag) EventHandler(org.bukkit.event.EventHandler)

Example 55 with ItemTag

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

the class ItemSpawnsScriptEvent method onItemSpawns.

@EventHandler
public void onItemSpawns(ItemSpawnEvent event) {
    Item entity = event.getEntity();
    location = new LocationTag(event.getLocation());
    item = new ItemTag(entity.getItemStack());
    this.entity = new EntityTag(entity);
    this.event = event;
    EntityTag.rememberEntity(entity);
    fire(event);
    EntityTag.forgetEntity(entity);
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) Item(org.bukkit.entity.Item) EntityTag(com.denizenscript.denizen.objects.EntityTag) ItemTag(com.denizenscript.denizen.objects.ItemTag) EventHandler(org.bukkit.event.EventHandler)

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