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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
Aggregations