private static boolean addDamage(Player attacker, Player victim, Double damage) { // mysql shit if (attacker == null) { attacker = DataUtils.getPlayer(victim).getLastAttacker(); } if (damage > victim.getHealth()) { damage = victim.getHealth(); } SmashPlayer Victim = DataUtils.getPlayer(victim); Victim.setLastDamage(System.currentTimeMillis()); Victim.setLastAttacker(attacker); StatisticUtils.addDamageTaken(victim, damage); if (attacker != null) { StatisticUtils.addDamageDelt(attacker, damage); if (Victim.getDamagers().containsKey(attacker)) { Victim.getDamagers().put(attacker, Victim.getDamagers().get(attacker) + damage); } else { Victim.getDamagers().put(attacker, damage); } } return HealthUtils.addHealth(victim, damage * -1); }
public static boolean Damage(Player attacker, Player victim, Double damage) { if (victim.isDead()) { return false; } if (attacker != null && !attacker.isOnline()) { return false; } if (DataUtils.getPlayer(victim).isVanished()) { return false; } if (attacker != null && DataUtils.getPlayer(attacker).isVanished()) { return false; } // Multiply and reduce by team stats. SmashPredamageEvent event = new SmashPredamageEvent(attacker, victim, damage); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } damage = event.getDamage(); victim.playEffect(EntityEffect.HURT); Location loc = victim.getLocation().add(0, 1, 0); ParticleUtils.SendPacket( ParticleUtils.createBlockPacket( EnumParticle.BLOCK_CRACK, 152, 0, loc, new Vector(0.1, 0.1, 0.1), 0F, 50), loc); ParticleUtils.SendPacket( ParticleUtils.createNormalPacket( EnumParticle.VILLAGER_ANGRY, victim.getEyeLocation(), new Vector(0, 0, 0), 0F, 1), loc); Double totalDamage = damage; damage = BarrierUtils.takeDamage(victim, damage); HologramUtils.displayAlertHolo(victim, "&c-" + Integer.toString(totalDamage.intValue()) + " ❤"); boolean result = addDamage(attacker, victim, damage); Bukkit.getPluginManager().callEvent(new SmashDamageEvent(attacker, victim, totalDamage)); return result; }
public static void Death(Player victim) { DeathEffectUtils.playDeathEffect(victim); SoundUtils.playSound(Sound.HURT_FLESH, victim.getEyeLocation(), 2F, 0F); Player attacker = DataUtils.getPlayer(victim).getLastAttacker(); StatisticUtils.addDeath(victim); if (attacker == null) { TitleUtils.sendTitle(victim, "&c&lYou have died!", "&7&lMistakes were made", 10, 80, 10); ChatUtils.sendMessage(victim, "&7&m-----------------------------------------------------"); ChatUtils.sendMessage(victim, "&8[&c&lDeath&8] &7Mistakes were made."); ChatUtils.sendMessage(victim, "&7&m-----------------------------------------------------"); } else { String prefixAttacker = DataUtils.getPlayer(attacker).getPrefix(); String colorAttacker = prefixAttacker.substring(0, 2); ChatUtils.sendMessage(victim, "&7&m-----------------------------------------------------"); ChatUtils.sendMessage( victim, "&8[&c&lDeath&8] &7You have been slain by " + prefixAttacker + attacker.getDisplayName()); ChatUtils.sendMessage(victim, "&7&m-----------------------------------------------------"); TitleUtils.sendTitle( victim, "&c&lYou have been slain!", "&7&lKiller: " + colorAttacker + attacker.getDisplayName(), 10, 80, 10); MoneyUtils.deathCoinsPayout(victim); StatisticUtils.addDeath(attacker); } victim.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 60, 0, true, true)); // victim.teleport(Main.SpawnLoc); // Location teleport to team spawn. victim.setVelocity(new Vector(0, 0, 0)); }