Search in sources :

Example 1 with MCProjectile

use of com.laytonsmith.abstraction.MCProjectile in project CommandHelper by EngineHub.

the class BukkitMCBlockProjectileSource method launchProjectile.

@Override
public MCProjectile launchProjectile(MCProjectileType projectile, Vector3D init) {
    EntityType et = EntityType.valueOf(projectile.name());
    Class<? extends Entity> c = et.getEntityClass();
    Vector vector = new Vector(init.X(), init.Y(), init.Z());
    Projectile proj = bps.launchProjectile(c.asSubclass(Projectile.class), vector);
    MCEntity e = BukkitConvertor.BukkitGetCorrectEntity(proj);
    if (e instanceof MCProjectile) {
        return (MCProjectile) e;
    } else {
        return null;
    }
}
Also used : EntityType(org.bukkit.entity.EntityType) MCEntity(com.laytonsmith.abstraction.MCEntity) Vector(org.bukkit.util.Vector) Projectile(org.bukkit.entity.Projectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile)

Example 2 with MCProjectile

use of com.laytonsmith.abstraction.MCProjectile in project CommandHelper by EngineHub.

the class BukkitMCEntityProjectileSource method launchProjectile.

@Override
public MCProjectile launchProjectile(MCProjectileType projectile, Vector3D init) {
    EntityType et = EntityType.valueOf(projectile.name());
    Class<? extends Entity> c = et.getEntityClass();
    Vector vector = new Vector(init.X(), init.Y(), init.Z());
    Projectile proj = eps.launchProjectile(c.asSubclass(Projectile.class), vector);
    MCEntity mcproj = BukkitConvertor.BukkitGetCorrectEntity(proj);
    if (mcproj instanceof MCProjectile) {
        return (MCProjectile) mcproj;
    } else {
        return null;
    }
}
Also used : EntityType(org.bukkit.entity.EntityType) MCEntity(com.laytonsmith.abstraction.MCEntity) Vector(org.bukkit.util.Vector) Projectile(org.bukkit.entity.Projectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile)

Example 3 with MCProjectile

use of com.laytonsmith.abstraction.MCProjectile in project CommandHelper by EngineHub.

the class BukkitMCEntityProjectileSource method launchProjectile.

@Override
public MCProjectile launchProjectile(MCProjectileType projectile) {
    EntityType et = EntityType.valueOf(projectile.name());
    Class<? extends Entity> c = et.getEntityClass();
    Projectile proj = eps.launchProjectile(c.asSubclass(Projectile.class));
    MCEntity mcproj = BukkitConvertor.BukkitGetCorrectEntity(proj);
    if (mcproj instanceof MCProjectile) {
        return (MCProjectile) mcproj;
    } else {
        return null;
    }
}
Also used : EntityType(org.bukkit.entity.EntityType) MCEntity(com.laytonsmith.abstraction.MCEntity) Projectile(org.bukkit.entity.Projectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile)

Example 4 with MCProjectile

use of com.laytonsmith.abstraction.MCProjectile in project CommandHelper by EngineHub.

the class BukkitMCBlockProjectileSource method launchProjectile.

@Override
public MCProjectile launchProjectile(MCProjectileType projectile) {
    EntityType et = EntityType.valueOf(projectile.name());
    Class<? extends Entity> c = et.getEntityClass();
    Projectile proj = bps.launchProjectile(c.asSubclass(Projectile.class));
    MCEntity e = BukkitConvertor.BukkitGetCorrectEntity(proj);
    if (e instanceof MCProjectile) {
        return (MCProjectile) e;
    } else {
        return null;
    }
}
Also used : EntityType(org.bukkit.entity.EntityType) MCEntity(com.laytonsmith.abstraction.MCEntity) Projectile(org.bukkit.entity.Projectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile) MCProjectile(com.laytonsmith.abstraction.MCProjectile)

Example 5 with MCProjectile

use of com.laytonsmith.abstraction.MCProjectile in project CommandHelper by EngineHub.

the class EntityEvents method parseEntityDamageEvent.

public static Map<String, Construct> parseEntityDamageEvent(MCEntityDamageEvent event, Map<String, Construct> map) {
    if (event != null) {
        MCEntity victim = event.getEntity();
        map.put("type", new CString(victim.getType().name(), Target.UNKNOWN));
        map.put("id", new CString(victim.getUniqueId().toString(), Target.UNKNOWN));
        map.put("cause", new CString(event.getCause().name(), Target.UNKNOWN));
        map.put("amount", new CDouble(event.getDamage(), Target.UNKNOWN));
        map.put("finalamount", new CDouble(event.getFinalDamage(), Target.UNKNOWN));
        map.put("world", new CString(event.getEntity().getWorld().getName(), Target.UNKNOWN));
        map.put("location", ObjectGenerator.GetGenerator().location(event.getEntity().getLocation()));
        if (event instanceof MCEntityDamageByEntityEvent) {
            MCEntity damager = ((MCEntityDamageByEntityEvent) event).getDamager();
            if (damager instanceof MCPlayer) {
                map.put("damager", new CString(((MCPlayer) damager).getName(), Target.UNKNOWN));
            } else {
                map.put("damager", new CString(damager.getUniqueId().toString(), Target.UNKNOWN));
            }
            if (damager instanceof MCProjectile) {
                MCProjectileSource shooter = ((MCProjectile) damager).getShooter();
                if (shooter instanceof MCPlayer) {
                    map.put("shooter", new CString(((MCPlayer) shooter).getName(), Target.UNKNOWN));
                } else if (shooter instanceof MCEntity) {
                    map.put("shooter", new CString(((MCEntity) shooter).getUniqueId().toString(), Target.UNKNOWN));
                } else if (shooter instanceof MCBlockProjectileSource) {
                    map.put("shooter", ObjectGenerator.GetGenerator().location(((MCBlockProjectileSource) shooter).getBlock().getLocation()));
                }
            }
        }
    }
    return map;
}
Also used : MCBlockProjectileSource(com.laytonsmith.abstraction.blocks.MCBlockProjectileSource) MCEntityDamageByEntityEvent(com.laytonsmith.abstraction.events.MCEntityDamageByEntityEvent) MCEntity(com.laytonsmith.abstraction.MCEntity) MCPlayer(com.laytonsmith.abstraction.MCPlayer) CDouble(com.laytonsmith.core.constructs.CDouble) CString(com.laytonsmith.core.constructs.CString) MCProjectile(com.laytonsmith.abstraction.MCProjectile) MCProjectileSource(com.laytonsmith.abstraction.MCProjectileSource)

Aggregations

MCEntity (com.laytonsmith.abstraction.MCEntity)5 MCProjectile (com.laytonsmith.abstraction.MCProjectile)5 EntityType (org.bukkit.entity.EntityType)4 Projectile (org.bukkit.entity.Projectile)4 Vector (org.bukkit.util.Vector)2 MCPlayer (com.laytonsmith.abstraction.MCPlayer)1 MCProjectileSource (com.laytonsmith.abstraction.MCProjectileSource)1 MCBlockProjectileSource (com.laytonsmith.abstraction.blocks.MCBlockProjectileSource)1 MCEntityDamageByEntityEvent (com.laytonsmith.abstraction.events.MCEntityDamageByEntityEvent)1 CDouble (com.laytonsmith.core.constructs.CDouble)1 CString (com.laytonsmith.core.constructs.CString)1