fix multiplayer: remove KNOCKED, swoon softlock, combat checks, dodge TP gate, inv cache, killfeed, threads/leaks

This commit is contained in:
SashegDev
2026-09-14 05:07:09 +00:00
parent e227ad63bd
commit 39ffe477a5
17 changed files with 419 additions and 230 deletions
@@ -5,7 +5,19 @@ import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataType;
public class DamageUtil {
public static boolean canHurt(Player attacker, LivingEntity victim) {
if (victim == null || !victim.isValid() || victim.isDead()) return false;
if (attacker != null && attacker.getGameMode() == org.bukkit.GameMode.SPECTATOR) return false;
if (victim instanceof Player pl) {
if (pl.getGameMode() == org.bukkit.GameMode.CREATIVE || pl.getGameMode() == org.bukkit.GameMode.SPECTATOR) return false;
if (pl.isInvulnerable()) return false;
if (pl.getPersistentDataContainer().has(SwoonHandler.SWOONED, PersistentDataType.BYTE)) return false;
}
return true;
}
public static void apply(Player attacker, LivingEntity victim, double amount) {
if (!canHurt(attacker, victim)) return;
victim.getPersistentDataContainer().set(SwoonHandler.MAGIC_DAMAGE, PersistentDataType.BYTE, (byte) 1);
victim.damage(amount, attacker);
victim.getPersistentDataContainer().remove(SwoonHandler.MAGIC_DAMAGE);