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
@@ -39,11 +39,13 @@ public class LungeAttack {
d.setBrightness(new Display.Brightness(15, 15));
d.setViewRange(64);
});
EntityTracker.mark(catalyst);
p.getWorld().playSound(start, Sound.BLOCK_SCULK_CATALYST_BLOOM, 1f, 0.7f);
double catSpeed = 3.0;
new BukkitRunnable() {
@Override public void run() {
EntityTracker.untrack(catalyst);
if (!target.isValid() || target.isDead()) { if (catalyst.isValid()) catalyst.remove(); cancel(); return; }
if (!catalyst.isValid()) { cancel(); return; }
Location cur = catalyst.getLocation();
@@ -55,6 +57,7 @@ public class LungeAttack {
nl.getWorld().spawnParticle(Particle.DUST, nl, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(20, 60, 80), 1f));
if (nl.distanceSquared(tpos) < 4) {
catalyst.teleport(tpos);
EntityTracker.untrack(catalyst);
catalyst.remove();
cancel();
tpos.getWorld().spawnParticle(Particle.EXPLOSION, tpos, 1);
@@ -62,6 +65,7 @@ public class LungeAttack {
tpos.getWorld().playSound(tpos, Sound.ENTITY_WARDEN_SONIC_BOOM, 1f, 0.6f);
startPhase1(p, tpos, target, plugin);
}
EntityTracker.untrack(catalyst);
if (catalyst.getTicksLived() > 80) { catalyst.remove(); cancel(); }
}
}.runTaskTimer(plugin, 1L, 1L);
@@ -149,6 +153,7 @@ public class LungeAttack {
new org.joml.Vector3f(1.5f, 1.5f, 1.5f),
new org.joml.AxisAngle4f()));
});
EntityTracker.mark(sword);
new BukkitRunnable() {
long hold = 5;
boolean launched = false;
@@ -172,6 +177,7 @@ public class LungeAttack {
int steps = Math.max(1, (int) Math.ceil(aim.length() / 0.5));
for (int s = 0; s <= steps; s++) {
Location check = cur.clone().add(aim.clone().multiply((double) s / steps));
EntityTracker.untrack(sword);
if (check.getBlock().isSolid()) { sword.remove(); cancel(); return; }
}
sword.teleport(nl);
@@ -179,13 +185,15 @@ public class LungeAttack {
if (le == p) continue;
applyLungeDamage(le, p, damage);
le.getWorld().spawnParticle(Particle.CRIT, le.getLocation().add(0, 1, 0), 10, 0.4, 0.4, 0.4, 0.1);
EntityTracker.untrack(sword);
sword.remove(); cancel(); return;
}
for (Player pl : nl.getWorld().getNearbyPlayers(nl, 0.9)) {
if (pl == p) continue;
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(nl);
if (d2 > 0.25 && d2 < 0.81) plugin.getTension().addTP(pl, 2.5f, "DODGE +1%");
if (d2 > 0.25 && d2 < 0.81) plugin.getTension().tryGiveDodge(pl);
}
EntityTracker.untrack(sword);
if (sword.getTicksLived() > 80) { sword.remove(); cancel(); }
}
}.runTaskTimer(plugin, 1L, 1L);
@@ -235,6 +243,7 @@ public class LungeAttack {
nl.getWorld().spawnParticle(Particle.SCULK_SOUL, nl, 1, 0.05, 0.05, 0.05, 0);
if (nl.getY() <= gazePoint.getY() + 0.5 || nl.getBlock().isSolid()) {
Location expl = gazePoint.clone();
EntityTracker.untrack(sword);
sword.remove(); cancel();
expl.getWorld().spawnParticle(Particle.EXPLOSION, expl, 1);
expl.getWorld().spawnParticle(Particle.SMOKE, expl, 10, 0.3, 0.1, 0.3, 0.02);
@@ -254,7 +263,7 @@ public class LungeAttack {
for (Player pl : expl.getWorld().getNearbyPlayers(expl, 2.5)) {
if (pl == p) continue;
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(expl);
if (d2 > 0.25 && d2 < 6.5) plugin.getTension().addTP(pl, 2.5f, "DODGE +1%");
if (d2 > 0.25 && d2 < 6.5) plugin.getTension().tryGiveDodge(pl);
}
expl.getWorld().playSound(expl, Sound.ENTITY_GENERIC_EXPLODE, 0.8f, 1.2f);
return;
@@ -262,8 +271,10 @@ public class LungeAttack {
for (LivingEntity le : nl.getWorld().getNearbyLivingEntities(nl, 1.0)) {
if (le == p) continue;
applyLungeDamage(le, p, 20);
EntityTracker.untrack(sword);
sword.remove(); cancel(); return;
}
EntityTracker.untrack(sword);
if (sword.getTicksLived() > 60) { sword.remove(); cancel(); }
}
}.runTaskTimer(plugin, 1L, 1L);
@@ -271,6 +282,7 @@ public class LungeAttack {
}
private static void applyLungeDamage(LivingEntity ent, Player attacker, double amount) {
if (!DamageUtil.canHurt(attacker, ent)) return;
if (ent instanceof Player pl && pl.isBlocking()) amount /= 2.5;
ent.getPersistentDataContainer().set(SwoonHandler.MAGIC_DAMAGE, PersistentDataType.BYTE, (byte) 1);
ent.damage(amount, attacker);
@@ -357,6 +369,7 @@ public class LungeAttack {
new org.joml.Vector3f(0.7f, 0.7f, 0.7f),
new org.joml.AxisAngle4f()));
});
EntityTracker.mark(sword);
Vector vel = new Vector(0, -fallSpeed, 0);
p.getWorld().playSound(spawn, Sound.ENTITY_PLAYER_ATTACK_SWEEP, 0.6f, 0.7f);
new BukkitRunnable() {
@@ -369,6 +382,7 @@ public class LungeAttack {
nl.getWorld().spawnParticle(Particle.SCULK_SOUL, nl, 1, 0.05, 0.05, 0.05, 0);
if (nl.getY() <= target.getY() + 0.5 || nl.getBlock().isSolid()) {
Location expl = nl.clone();
EntityTracker.untrack(sword);
sword.remove();
cancel();
expl.getWorld().spawnParticle(Particle.SMOKE, expl, 6, 0.2, 0.1, 0.2, 0.02);
@@ -387,7 +401,7 @@ public class LungeAttack {
for (Player pl : expl.getWorld().getNearbyPlayers(expl, 0.9)) {
if (pl == p) continue;
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(expl);
if (d2 > 0.25 && d2 < 0.81) plugin.getTension().addTP(pl, 2.5f, "DODGE +1%");
if (d2 > 0.25 && d2 < 0.81) plugin.getTension().tryGiveDodge(pl);
}
return;
}
@@ -395,8 +409,10 @@ public class LungeAttack {
if (le == p) continue;
applyLungeDamage(le, p, damage);
le.getWorld().spawnParticle(Particle.CRIT, le.getLocation().add(0, 1, 0), 8, 0.3, 0.3, 0.3, 0.1);
EntityTracker.untrack(sword);
sword.remove(); cancel(); return;
}
EntityTracker.untrack(sword);
if (sword.getTicksLived() > 80) { sword.remove(); cancel(); }
}
}.runTaskTimer(plugin, 1L, 1L);
@@ -446,6 +462,7 @@ public class LungeAttack {
new org.joml.Vector3f(1.5f, 1.5f, 1.5f),
new org.joml.AxisAngle4f()));
});
EntityTracker.mark(sword);
spawn.getWorld().playSound(spawn, Sound.ENTITY_PLAYER_ATTACK_SWEEP, 0.8f, 0.5f);
new BukkitRunnable() {
@@ -472,6 +489,7 @@ public class LungeAttack {
int steps = Math.max(1, (int) Math.ceil(aim.length() / 0.5));
for (int s = 0; s <= steps; s++) {
Location check = cur.clone().add(aim.clone().multiply((double) s / steps));
EntityTracker.untrack(sword);
if (check.getBlock().isSolid()) { sword.remove(); cancel(); return; }
}
sword.teleport(nl);
@@ -479,13 +497,15 @@ public class LungeAttack {
if (le == p) continue;
applyLungeDamage(le, p, 20);
le.getWorld().spawnParticle(Particle.CRIT, le.getLocation().add(0, 1, 0), 10, 0.4, 0.4, 0.4, 0.1);
EntityTracker.untrack(sword);
sword.remove(); cancel(); return;
}
for (Player pl : nl.getWorld().getNearbyPlayers(nl, 0.9)) {
if (pl == p) continue;
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(nl);
if (d2 > 0.25 && d2 < 0.81) plugin.getTension().addTP(pl, 2.5f, "DODGE +1%");
if (d2 > 0.25 && d2 < 0.81) plugin.getTension().tryGiveDodge(pl);
}
EntityTracker.untrack(sword);
if (sword.getTicksLived() > 80) { sword.remove(); cancel(); }
}
}.runTaskTimer(plugin, 1L, 1L);