use of org.bukkit.event.entity.EntityDeathEvent in project MagicPlugin by elBukkit.
the class CompatibilityUtils method damage.
public static void damage(Damageable target, double amount, Entity source) {
if (target == null || target.isDead())
return;
while (target instanceof ComplexEntityPart) {
target = ((ComplexEntityPart) target).getParent();
}
if (USE_MAGIC_DAMAGE && target.getType() == EntityType.ENDER_DRAGON) {
magicDamage(target, amount, source);
return;
}
isDamaging = true;
try {
if (target instanceof ArmorStand) {
double newHealth = Math.max(0, target.getHealth() - amount);
if (newHealth <= 0) {
EntityDeathEvent deathEvent = new EntityDeathEvent((ArmorStand) target, new ArrayList<ItemStack>());
Bukkit.getPluginManager().callEvent(deathEvent);
target.remove();
} else {
target.setHealth(newHealth);
}
} else {
target.damage(amount, source);
}
} catch (Exception ex) {
ex.printStackTrace();
}
isDamaging = false;
}
use of org.bukkit.event.entity.EntityDeathEvent in project Village_Defense by Plajer.
the class GolemBuster method damageEntity.
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (damagesource != null && damagesource.getEntity() != null && damagesource.getEntity().getBukkitEntity().getType() == EntityType.IRON_GOLEM) {
this.die();
this.die();
org.bukkit.inventory.ItemStack[] itemStack = new org.bukkit.inventory.ItemStack[] { new org.bukkit.inventory.ItemStack(org.bukkit.Material.ROTTEN_FLESH) };
Bukkit.getServer().getPluginManager().callEvent(new EntityDeathEvent((LivingEntity) this.getBukkitEntity(), Arrays.asList(itemStack), expToDrop));
IronGolem golem = (IronGolem) damagesource.getEntity().getBukkitEntity();
// golem.getWorld().createExplosion(golem.getLocation(), 4);
org.bukkit.entity.Entity primed = golem.getWorld().spawnEntity(golem.getLocation(), EntityType.PRIMED_TNT);
return true;
} else {
super.damageEntity(damagesource, f);
return false;
}
}
use of org.bukkit.event.entity.EntityDeathEvent in project Village_Defense by Plajer.
the class PlayerBuster method damageEntity.
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (damagesource != null && damagesource.getEntity() != null && damagesource.getEntity().getBukkitEntity().getType() == EntityType.PLAYER) {
ItemStack[] itemStack = new ItemStack[] { new ItemStack(Material.ROTTEN_FLESH) };
Bukkit.getServer().getPluginManager().callEvent(new EntityDeathEvent((LivingEntity) this.getBukkitEntity(), Arrays.asList(itemStack), expToDrop));
Player player = (Player) damagesource.getEntity().getBukkitEntity();
getBukkitEntity().getWorld().spawnEntity(getBukkitEntity().getLocation(), EntityType.PRIMED_TNT);
this.die();
return true;
} else {
super.damageEntity(damagesource, f);
return false;
}
}
use of org.bukkit.event.entity.EntityDeathEvent in project Village_Defense by Plajer.
the class PlayerBuster method damageEntity.
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (damagesource != null && damagesource.getEntity() != null && damagesource.getEntity().getBukkitEntity().getType() == EntityType.PLAYER) {
ItemStack[] itemStack = new ItemStack[] { new ItemStack(Material.ROTTEN_FLESH) };
Bukkit.getServer().getPluginManager().callEvent(new EntityDeathEvent((LivingEntity) this.getBukkitEntity(), Arrays.asList(itemStack), expToDrop));
getBukkitEntity().getWorld().spawnEntity(getBukkitEntity().getLocation(), EntityType.PRIMED_TNT);
this.die();
return true;
} else {
super.damageEntity(damagesource, f);
return false;
}
}
use of org.bukkit.event.entity.EntityDeathEvent in project Village_Defense by Plajer.
the class GolemBuster method damageEntity.
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (damagesource != null && damagesource.getEntity() != null && damagesource.getEntity().getBukkitEntity().getType() == EntityType.IRON_GOLEM) {
this.die();
this.die();
org.bukkit.inventory.ItemStack[] itemStack = new org.bukkit.inventory.ItemStack[] { new org.bukkit.inventory.ItemStack(org.bukkit.Material.ROTTEN_FLESH) };
Bukkit.getServer().getPluginManager().callEvent(new EntityDeathEvent((LivingEntity) this.getBukkitEntity(), Arrays.asList(itemStack), expToDrop));
IronGolem golem = (IronGolem) damagesource.getEntity().getBukkitEntity();
// golem.getWorld().createExplosion(golem.getLocation(), 4);
org.bukkit.entity.Entity primed = golem.getWorld().spawnEntity(golem.getLocation(), EntityType.PRIMED_TNT);
return true;
} else {
super.damageEntity(damagesource, f);
return false;
}
}
Aggregations