use of org.bukkit.projectiles.ProjectileSource in project Glowstone by GlowstoneMC.
the class GlowArrow method collide.
@Override
public void collide(LivingEntity entity) {
double damage = getDamage();
ProjectileSource shooter = getShooter();
if (isCritical()) {
damage += 1.0;
}
entity.damage(damage, shooter instanceof Entity ? (Entity) shooter : null, EntityDamageEvent.DamageCause.PROJECTILE);
// Burning arrow ignites target, but doesn't stack if target is already on fire.
if (getFireTicks() > 0 && entity.getFireTicks() < TARGET_BURN_TICKS) {
entity.setFireTicks(TARGET_BURN_TICKS);
}
// TODO: knockback
entity.setArrowsStuck(entity.getArrowsStuck() + 1);
remove();
}
use of org.bukkit.projectiles.ProjectileSource in project Glowstone by GlowstoneMC.
the class GlowSnowball method collide.
/**
* Process collide with a living entity.
*
* @param entity the eneity that the snowball collides with
*/
@Override
public void collide(LivingEntity entity) {
ProjectileSource source = getShooter();
// the entity receives fake damage.
if (source instanceof Entity) {
if (entity instanceof GlowBlaze) {
entity.damage(3, (Entity) source, EntityDamageEvent.DamageCause.PROJECTILE);
} else {
entity.damage(0, (Entity) source, EntityDamageEvent.DamageCause.PROJECTILE);
}
} else {
entity.damage(0, EntityDamageEvent.DamageCause.PROJECTILE);
}
collide(location.getBlock());
}
use of org.bukkit.projectiles.ProjectileSource in project Glowstone by GlowstoneMC.
the class GlowEgg method collide.
/**
* Process random spawn chicks when collide with a living entity.
*
* @param entity the eneity that the egg collides with
*/
@Override
public void collide(LivingEntity entity) {
ProjectileSource source = getShooter();
// the entity receives fake damage.
if (entity instanceof Entity) {
entity.damage(0, (Entity) source, EntityDamageEvent.DamageCause.PROJECTILE);
} else {
entity.damage(0, EntityDamageEvent.DamageCause.PROJECTILE);
}
collide(entity.getLocation().getBlock());
}
use of org.bukkit.projectiles.ProjectileSource in project Prism-Bukkit by prism.
the class DeathUtils method getCauseNiceName.
/**
* Returns the name of what caused an entity to die.
*
* @return String
*/
public static String getCauseNiceName(Entity entity) {
EntityDamageEvent e = entity.getLastDamageCause();
if (e == null) {
return "unknown";
}
// Determine the root cause
DamageCause damageCause = e.getCause();
Entity killer = null;
// If was damaged by an entity
if (entity.getLastDamageCause() instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) entity.getLastDamageCause();
// Arrow?
if (entityDamageByEntityEvent.getDamager() instanceof Arrow) {
Projectile arrow = (Arrow) entityDamageByEntityEvent.getDamager();
ProjectileSource source = arrow.getShooter();
if (source instanceof Player) {
killer = ((Player) source);
}
} else {
killer = entityDamageByEntityEvent.getDamager();
}
}
if (entity instanceof Player) {
Player player = (Player) entity;
// yourself with instant damage it doesn't show as suicide.
if (killer instanceof Player) {
// Themself
if (killer.getName().equals(player.getName())) {
return "suicide";
}
// translate bukkit events to nicer names
if ((damageCause.equals(DamageCause.ENTITY_ATTACK) || damageCause.equals(DamageCause.PROJECTILE))) {
return "pvp";
}
}
}
// Causes of death for either entities or players
if (damageCause.equals(DamageCause.ENTITY_ATTACK)) {
return "mob";
} else if (damageCause.equals(DamageCause.PROJECTILE)) {
return "skeleton";
} else if (damageCause.equals(DamageCause.ENTITY_EXPLOSION)) {
return "creeper";
} else if (damageCause.equals(DamageCause.CONTACT)) {
return "cactus";
} else if (damageCause.equals(DamageCause.BLOCK_EXPLOSION)) {
return "tnt";
} else if (damageCause.equals(DamageCause.FIRE) || damageCause.equals(DamageCause.FIRE_TICK)) {
return "fire";
} else if (damageCause.equals(DamageCause.MAGIC)) {
return "potion";
}
return damageCause.name().toLowerCase();
}
use of org.bukkit.projectiles.ProjectileSource in project Prism-Bukkit by prism.
the class PrismEntityEvents method onPotionSplashEvent.
/**
* PotionSplashEvent.
* @param event PotionSplashEvent.
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPotionSplashEvent(final PotionSplashEvent event) {
final ProjectileSource source = event.getPotion().getShooter();
// Ignore from non-players for the time being
if (!(source instanceof Player)) {
return;
}
final Player player = (Player) source;
if (!Prism.getIgnore().event("potion-splash", player)) {
return;
}
// What type?
// Right now this won't support anything with multiple effects
final Collection<PotionEffect> potion = event.getPotion().getEffects();
String name = "";
for (final PotionEffect eff : potion) {
name = eff.getType().getName().toLowerCase();
}
RecordingQueue.addToQueue(ActionFactory.createPlayer("potion-splash", player, name));
}
Aggregations