How would I inflict direct damage to a player ignoring their armor and enchantments on it. I've tried the player.damage(damageD) feature but seem to have issues. I've also tried event.setDamage(0D) then tried to set the damage getting their health and subtracting damage only to find errors. Any help will be much appreciated
What is wrong with something like this: Code: event.getPlayer.setHealth(event.getPlayer.getHealth() - 8); Works for me
@Coopah What seanliam2000 said, just take in account that setting health lower than 0 throws and exception, so you need to check that, also use Player#playerEffect to play the hurt effect
@Konato_K @seanliam2000 I'm using this code but it doesn't work. It just keeps setting their health to the same amount. It puts them on 2 hearts instead of subtracting 2 hearts from their health and then every shot following that will keep them on 2 hearts. Isn't #getHealth just getting their total health and not current? Code: Code: @EventHandler public void onArrowLand(EntityDamageByEntityEvent e) { Entity damagerE = e.getDamager(); Entity damagedE = e.getEntity(); if (damagerE instanceof Arrow && damagedE instanceof Player) { Player damaged = (Player) damagedE; final Arrow arw = (Arrow) damagerE; if (arw.getShooter() instanceof Player) { final Player damager = (Player) arw.getShooter(); e.setDamage(0D); if (ArrowToggles.CripplingArrows.contains(damager.getName())) { damaged.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 1)); e.setDamage(6D); } else if (ArrowToggles.PiercingArrows.contains(damager.getName())) { damaged.damage(damaged.getHealth() - 8); } else { e.setDamage(6D); } } } }