Search in sources :

Example 16 with EntityTag

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

the class EntityPotionEffectScriptEvent method onEntityPotionEffect.

@EventHandler
public void onEntityPotionEffect(EntityPotionEffectEvent event) {
    entity = new EntityTag(event.getEntity());
    this.event = event;
    fire(event);
}
Also used : EntityTag(com.denizenscript.denizen.objects.EntityTag) EventHandler(org.bukkit.event.EventHandler)

Example 17 with EntityTag

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

the class EntityShootsBowEvent method applyDetermination.

@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
    String determination = determinationObj.toString();
    if (determinationObj instanceof ElementTag) {
        String lower = CoreUtilities.toLowerCase(determination);
        if (lower.equals("keep_item")) {
            event.setConsumeItem(false);
            if (entity.isPlayer()) {
                final Player p = entity.getPlayer();
                Bukkit.getScheduler().scheduleSyncDelayedTask(Denizen.getInstance(), p::updateInventory, 1);
            }
            return true;
        }
    }
    if (Argument.valueOf(determination).matchesArgumentList(EntityTag.class)) {
        cancelled = true;
        cancellationChanged();
        // Get the list of entities
        List<EntityTag> newProjectiles = ListTag.getListFor(determinationObj, getTagContext(path)).filter(EntityTag.class, path.container, true);
        // Go through all the entities, spawning/teleporting them
        for (EntityTag newProjectile : newProjectiles) {
            newProjectile.spawnAt(entity.getEyeLocation().add(entity.getEyeLocation().getDirection()));
            // where applicable
            if (newProjectile.isProjectile()) {
                newProjectile.setShooter(entity);
            }
        }
        // Mount the projectiles on top of each other
        Position.mount(Conversion.convertEntities(newProjectiles));
        // Get the last entity on the list, i.e. the one at the bottom
        // if there are many mounted on top of each other
        Entity lastProjectile = newProjectiles.get(newProjectiles.size() - 1).getBukkitEntity();
        // Give it the same velocity as the arrow that would
        // have been shot by the bow
        // Note: No, I can't explain why this has to be multiplied by three, it just does.
        lastProjectile.setVelocity(event.getEntity().getLocation().getDirection().multiply(event.getForce() * 3));
        return true;
    }
    return super.applyDetermination(path, determinationObj);
}
Also used : Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) EntityTag(com.denizenscript.denizen.objects.EntityTag) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag)

Example 18 with EntityTag

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

the class EntitySwimScriptEvent method onEntityToggleSwim.

@EventHandler
public void onEntityToggleSwim(EntityToggleSwimEvent event) {
    entity = new EntityTag(event.getEntity());
    state = event.isSwimming();
    fire(event);
}
Also used : EntityTag(com.denizenscript.denizen.objects.EntityTag) EventHandler(org.bukkit.event.EventHandler)

Example 19 with EntityTag

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

the class CreeperPoweredScriptEvent method onCreeperPowered.

@EventHandler
public void onCreeperPowered(CreeperPowerEvent event) {
    lightning = new EntityTag(event.getLightning());
    entity = new EntityTag(event.getEntity());
    cause = new ElementTag(event.getCause().name());
    this.event = event;
    fire(event);
}
Also used : EntityTag(com.denizenscript.denizen.objects.EntityTag) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) EventHandler(org.bukkit.event.EventHandler)

Example 20 with EntityTag

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

the class DragonPhaseChangeScriptEvent method onEnderDragonChangePhase.

@EventHandler
public void onEnderDragonChangePhase(EnderDragonChangePhaseEvent event) {
    entity = new EntityTag(event.getEntity());
    this.event = event;
    fire(event);
}
Also used : EntityTag(com.denizenscript.denizen.objects.EntityTag) EventHandler(org.bukkit.event.EventHandler)

Aggregations

EntityTag (com.denizenscript.denizen.objects.EntityTag)142 EventHandler (org.bukkit.event.EventHandler)81 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)56 LocationTag (com.denizenscript.denizen.objects.LocationTag)45 List (java.util.List)27 Entity (org.bukkit.entity.Entity)25 ItemTag (com.denizenscript.denizen.objects.ItemTag)17 ListTag (com.denizenscript.denizencore.objects.core.ListTag)17 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)15 InvalidArgumentsException (com.denizenscript.denizencore.exceptions.InvalidArgumentsException)12 DurationTag (com.denizenscript.denizencore.objects.core.DurationTag)11 NPCTag (com.denizenscript.denizen.objects.NPCTag)10 ArrayList (java.util.ArrayList)10 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)10 ScriptEntry (com.denizenscript.denizencore.scripts.ScriptEntry)9 Player (org.bukkit.entity.Player)9 MaterialTag (com.denizenscript.denizen.objects.MaterialTag)8 Argument (com.denizenscript.denizencore.objects.Argument)8 LivingEntity (org.bukkit.entity.LivingEntity)8 Item (org.bukkit.entity.Item)7