Search in sources :

Example 71 with EntityTag

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

the class EntityAddToWorldScriptEvent method onPreCreatureSpawn.

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

Example 72 with EntityTag

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

the class EntityKnocksbackEntityScriptEvent method onEntityKnockbackEntity.

@EventHandler
public void onEntityKnockbackEntity(EntityKnockbackByEntityEvent event) {
    entity = new EntityTag(event.getEntity());
    hitBy = new EntityTag(event.getHitBy());
    held = hitBy.getItemInHand();
    this.event = event;
    fire(event);
}
Also used : EntityTag(com.denizenscript.denizen.objects.EntityTag) EventHandler(org.bukkit.event.EventHandler)

Example 73 with EntityTag

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

the class EntityPathfindScriptEvent method onEntityPathfind.

@EventHandler
public void onEntityPathfind(EntityPathfindEvent event) {
    this.event = event;
    this.entity = new EntityTag(event.getEntity());
    Entity target = event.getTargetEntity();
    this.target = target != null ? new EntityTag(target) : null;
    fire(event);
}
Also used : Entity(org.bukkit.entity.Entity) EntityTag(com.denizenscript.denizen.objects.EntityTag) EventHandler(org.bukkit.event.EventHandler)

Example 74 with EntityTag

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

the class AttachCommand method execute.

@Override
public void execute(final ScriptEntry scriptEntry) {
    LocationTag offset = scriptEntry.getObjectTag("offset");
    List<EntityTag> entities = (List<EntityTag>) scriptEntry.getObject("entities");
    EntityTag target = scriptEntry.getObjectTag("to");
    List<PlayerTag> forPlayers = (List<PlayerTag>) scriptEntry.getObject("for");
    ElementTag cancel = scriptEntry.getElement("cancel");
    ElementTag relative = scriptEntry.getElement("relative");
    ElementTag sync_server = scriptEntry.getElement("sync_server");
    ElementTag no_rotate = scriptEntry.getElement("no_rotate");
    ElementTag no_pitch = scriptEntry.getElement("no_pitch");
    ElementTag yaw_offset = scriptEntry.getElement("yaw_offset");
    ElementTag pitch_offset = scriptEntry.getElement("pitch_offset");
    boolean shouldCancel = cancel.asBoolean();
    if (scriptEntry.dbCallShouldDebug()) {
        Debug.report(scriptEntry, getName(), db("entities", entities), shouldCancel ? cancel : target, relative, offset, yaw_offset, pitch_offset, sync_server, no_rotate, no_pitch, db("for", forPlayers));
    }
    BiConsumer<EntityTag, UUID> procPlayer = (entity, player) -> {
        if (shouldCancel) {
            EntityAttachmentHelper.removeAttachment(entity.getUUID(), player);
        } else {
            EntityAttachmentHelper.AttachmentData attachment = new EntityAttachmentHelper.AttachmentData();
            attachment.attached = entity;
            attachment.to = target;
            attachment.positionalOffset = offset == null ? null : offset.clone();
            attachment.offsetRelative = relative.asBoolean();
            attachment.yawAngleOffset = yaw_offset.asFloat();
            attachment.pitchAngleOffset = pitch_offset.asFloat();
            attachment.syncServer = sync_server.asBoolean();
            attachment.forPlayer = player;
            attachment.noRotate = no_rotate.asBoolean();
            attachment.noPitch = no_pitch.asBoolean();
            EntityAttachmentHelper.registerAttachment(attachment);
        }
    };
    for (EntityTag entity : entities) {
        if (!entity.isSpawned() && !entity.isFake && !shouldCancel) {
            Debug.echoError("Cannot attach entity '" + entity + "': entity is not spawned.");
            continue;
        }
        if (forPlayers == null) {
            procPlayer.accept(entity, null);
        } else {
            for (PlayerTag player : forPlayers) {
                procPlayer.accept(entity, player.getUUID());
            }
        }
    }
}
Also used : ListTag(com.denizenscript.denizencore.objects.core.ListTag) LocationTag(com.denizenscript.denizen.objects.LocationTag) UUID(java.util.UUID) PlayerTag(com.denizenscript.denizen.objects.PlayerTag) InvalidArgumentsException(com.denizenscript.denizencore.exceptions.InvalidArgumentsException) Argument(com.denizenscript.denizencore.objects.Argument) List(java.util.List) BiConsumer(java.util.function.BiConsumer) EntityTag(com.denizenscript.denizen.objects.EntityTag) ScriptEntry(com.denizenscript.denizencore.scripts.ScriptEntry) Debug(com.denizenscript.denizen.utilities.debugging.Debug) AbstractCommand(com.denizenscript.denizencore.scripts.commands.AbstractCommand) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) EntityAttachmentHelper(com.denizenscript.denizen.utilities.entity.EntityAttachmentHelper) PlayerTag(com.denizenscript.denizen.objects.PlayerTag) LocationTag(com.denizenscript.denizen.objects.LocationTag) EntityTag(com.denizenscript.denizen.objects.EntityTag) List(java.util.List) EntityAttachmentHelper(com.denizenscript.denizen.utilities.entity.EntityAttachmentHelper) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) UUID(java.util.UUID)

Example 75 with EntityTag

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

the class BurnCommand method execute.

@Override
public void execute(final ScriptEntry scriptEntry) {
    List<EntityTag> entities = (List<EntityTag>) scriptEntry.getObject("entities");
    DurationTag duration = scriptEntry.getObjectTag("duration");
    if (scriptEntry.dbCallShouldDebug()) {
        Debug.report(scriptEntry, getName(), duration, db("entities", entities));
    }
    for (EntityTag entity : entities) {
        if (entity.isSpawned()) {
            entity.getBukkitEntity().setFireTicks(duration.getTicksAsInt());
        }
    }
}
Also used : EntityTag(com.denizenscript.denizen.objects.EntityTag) List(java.util.List) DurationTag(com.denizenscript.denizencore.objects.core.DurationTag)

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