Add a semi-realistic damage & knockback to attacker when a player is afk

This commit is contained in:
2024-07-12 20:38:26 -07:00
parent 8f17de9c67
commit f66f610d05
5 changed files with 4 additions and 82 deletions

View File

@@ -25,6 +25,10 @@ public class EntityDamageListener implements Listener {
if (damageEvent.getDamager() instanceof Player attacker) {
attacker.sendMessage("%s%sLncvrtBox %s%s» %sYou can't attack AFK players!".formatted(GOLD, BOLD, GRAY, BOLD, RESET));
player.sendMessage("%s%sLncvrtBox %s%s» %s%s tried to attack you while you were AFK!".formatted(GOLD, BOLD, GRAY, BOLD, RESET, attacker.getName()));
if (attacker.getNoDamageTicks() == 0) {
attacker.damage(0.0001);
attacker.setVelocity(attacker.getLocation().toVector().subtract(player.getLocation().toVector()).normalize().setY(0.5).multiply(0.5));
}
}
}
}