use of com.ebicep.warlords.events.WarlordsDeathEvent in project Warlords by ebicep.
the class WarlordsPlayer method die.
public void die(@Nullable WarlordsPlayer attacker) {
dead = true;
removeHorse();
getLocation(this.deathLocation);
showDeathAnimation();
cooldownManager.clearCooldowns();
if (attacker != null) {
if (attacker != this) {
hitBy.putAll(attacker.getHealedBy());
}
hitBy.remove(attacker);
}
this.addDeath();
FlagHolder.dropFlagForPlayer(this);
if (entity instanceof Player) {
Player player = (Player) entity;
player.setGameMode(GameMode.SPECTATOR);
// removing yellow hearts
((EntityLiving) ((CraftPlayer) entity).getHandle()).setAbsorptionHearts(0);
ItemStack item = ((CraftPlayer) entity).getInventory().getItem(0);
// removing sg shiny weapon
if (item != null) {
item.removeEnchantment(Enchantment.OXYGEN);
}
// removing boner
player.getInventory().remove(UndyingArmy.BONE);
}
Bukkit.getPluginManager().callEvent(new WarlordsDeathEvent(this, attacker));
// giving out assists
hitBy.forEach((assisted, value) -> {
if (attacker == assisted || attacker == this) {
assisted.sendMessage(ChatColor.GRAY + "You assisted in killing " + getColoredName());
} else {
if (attacker != null) {
assisted.sendMessage(ChatColor.GRAY + "You assisted " + attacker.getColoredName() + ChatColor.GRAY + " in killing " + getColoredName());
}
}
assisted.addAssist();
});
hitBy.clear();
regenTimer = 0;
heal();
}
Aggregations