fix multiplayer: remove KNOCKED, swoon softlock, combat checks, dodge TP gate, inv cache, killfeed, threads/leaks
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user