Search in sources :

Example 1 with ItemTag

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

the class PaperPlayerProperties method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("affects_monster_spawning") && mechanism.requireBoolean()) {
        player.getPlayerEntity().setAffectsSpawning(mechanism.getValue().asBoolean());
    }
    // -->
    if (mechanism.matches("firework_boost") && mechanism.requireObject(ItemTag.class)) {
        if (!player.getPlayerEntity().isGliding()) {
            mechanism.echoError("Player must be gliding to use firework_boost.");
            return;
        }
        ItemTag item = mechanism.valueAsType(ItemTag.class);
        if (item.getBukkitMaterial() != Material.FIREWORK_ROCKET) {
            mechanism.echoError("Invalid input item: must be a firework rocket.");
            return;
        }
        player.getPlayerEntity().boostElytra(item.getItemStack());
    }
}
Also used : ItemTag(com.denizenscript.denizen.objects.ItemTag)

Example 2 with ItemTag

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

the class BlockCooksSmeltsItemScriptEvent method onBlockCooks.

@EventHandler
public void onBlockCooks(BlockCookEvent event) {
    block = event.getBlock();
    source_item = new ItemTag(event.getSource());
    result_item = new ItemTag(event.getResult());
    this.event = event;
    fire(event);
}
Also used : ItemTag(com.denizenscript.denizen.objects.ItemTag) EventHandler(org.bukkit.event.EventHandler)

Example 3 with ItemTag

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

the class BlockDispensesScriptEvent method applyDetermination.

@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
    if (determinationObj.canBeType(LocationTag.class)) {
        LocationTag vel = determinationObj.asType(LocationTag.class, getTagContext(path));
        if (vel != null) {
            event.setVelocity(vel.toVector());
            return true;
        }
    }
    if (determinationObj.canBeType(ItemTag.class)) {
        ItemTag it = determinationObj.asType(ItemTag.class, getTagContext(path));
        if (it != null) {
            item = it;
            event.setItem(item.getItemStack());
            return true;
        }
    }
    if (ArgumentHelper.matchesDouble(determinationObj.toString())) {
        Deprecations.blockDispensesItemDetermination.warn();
        event.setVelocity(event.getVelocity().multiply(Double.parseDouble(determinationObj.toString())));
        return true;
    }
    return super.applyDetermination(path, determinationObj);
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) ItemTag(com.denizenscript.denizen.objects.ItemTag)

Example 4 with ItemTag

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

the class BlockDispensesScriptEvent method onBlockDispenses.

@EventHandler
public void onBlockDispenses(BlockDispenseEvent event) {
    location = new LocationTag(event.getBlock().getLocation());
    material = new MaterialTag(event.getBlock());
    item = new ItemTag(event.getItem());
    this.event = event;
    fire(event);
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) MaterialTag(com.denizenscript.denizen.objects.MaterialTag) ItemTag(com.denizenscript.denizen.objects.ItemTag) EventHandler(org.bukkit.event.EventHandler)

Example 5 with ItemTag

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

the class PlayerEquipsArmorScriptEvent method armorChangeEvent.

@EventHandler
public void armorChangeEvent(PlayerArmorChangeEvent event) {
    if (EntityTag.isCitizensNPC(event.getPlayer())) {
        return;
    }
    if (simpleComparisonString(event.getOldItem()).equals(simpleComparisonString(event.getNewItem()))) {
        return;
    }
    newItem = new ItemTag(event.getNewItem());
    oldItem = new ItemTag(event.getOldItem());
    slot = event.getSlotType();
    player = new PlayerTag(event.getPlayer());
    fire(event);
}
Also used : PlayerTag(com.denizenscript.denizen.objects.PlayerTag) 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