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
@@ -25,6 +25,7 @@ public class DiamondAttack {
d.setBrightness(new Display.Brightness(15, 15));
d.setViewRange(64);
});
EntityTracker.mark(crystal);
p.getWorld().playSound(spawn, Sound.BLOCK_AMETHYST_BLOCK_PLACE, 1f, 0.9f);
p.getWorld().playSound(spawn, Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1f, 1.5f);
Vector vel = dir.clone().multiply(1.5);
@@ -39,6 +40,7 @@ public class DiamondAttack {
if (hitBlock) {
Location expl = cur.clone().add(vel.clone().normalize().multiply(-0.1));
crystal.teleport(expl);
EntityTracker.untrack(crystal);
crystal.remove();
cancel();
expl.getWorld().spawnParticle(Particle.EXPLOSION, expl, 1);
@@ -50,6 +52,7 @@ public class DiamondAttack {
s.setBrightness(new Display.Brightness(15, 15));
s.setViewRange(64);
});
EntityTracker.mark(shard);
Vector sv = d.clone().multiply(0.4);
new BukkitRunnable() {
@Override public void run() {
@@ -59,6 +62,7 @@ public class DiamondAttack {
if (n2.getBlock().isSolid()) {
Location expl2 = cur2.clone().add(sv.clone().normalize().multiply(-0.1));
shard.teleport(expl2);
EntityTracker.untrack(shard);
shard.remove();
cancel();
return;
@@ -68,6 +72,7 @@ public class DiamondAttack {
for (var ent : n2.getWorld().getNearbyEntities(n2, 0.7, 0.7, 0.7, e -> e instanceof LivingEntity && e != p)) {
LivingEntity le = (LivingEntity) ent;
DamageUtil.apply(p, le, 2.0);
EntityTracker.untrack(shard);
shard.remove();
cancel();
break;
@@ -76,10 +81,11 @@ public class DiamondAttack {
if (pl == p) continue;
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(n2);
if (d2 > 0.25 && d2 < 0.81) {
BlackKnifePlugin.getPlugin(BlackKnifePlugin.class).getTension().addTP(pl, 2.5f, "DODGE +1%");
BlackKnifePlugin.getPlugin(BlackKnifePlugin.class).getTension().tryGiveDodge(pl);
pl.getWorld().spawnParticle(Particle.DUST, pl.getLocation().add(0, 0.25, 0), 25, 0.5, 0.05, 0.5, 0, new Particle.DustOptions(Color.fromRGB(255, 255, 255), 0.15f));
}
}
EntityTracker.untrack(shard);
if (shard.getTicksLived() > 40) { shard.remove(); cancel(); }
}
}.runTaskTimer(plugin, 1L, 1L);
@@ -100,12 +106,13 @@ public class DiamondAttack {
if (pl == p) continue;
double d = pl.getLocation().add(0, 1, 0).distanceSquared(nl);
if (d > 0.25 && d < 0.81) {
BlackKnifePlugin.getPlugin(BlackKnifePlugin.class).getTension().addTP(pl, 2.5f, "DODGE +1%");
BlackKnifePlugin.getPlugin(BlackKnifePlugin.class).getTension().tryGiveDodge(pl);
pl.getWorld().spawnParticle(Particle.DUST, pl.getLocation().add(0, 0.25, 0), 25, 0.5, 0.05, 0.5, 0, new Particle.DustOptions(Color.fromRGB(255, 255, 255), 0.15f));
}
}
if (hit) {
Location expl = nl.clone();
EntityTracker.untrack(crystal);
crystal.remove();
cancel();
expl.getWorld().spawnParticle(Particle.EXPLOSION, expl, 1);
@@ -117,6 +124,7 @@ public class DiamondAttack {
s.setBrightness(new Display.Brightness(15, 15));
s.setViewRange(64);
});
EntityTracker.mark(shard);
Vector sv = d.clone().multiply(0.4);
new BukkitRunnable() {
@Override public void run() {
@@ -126,6 +134,7 @@ public class DiamondAttack {
if (n2.getBlock().isSolid()) {
Location expl2 = cur2.clone().add(sv.clone().normalize().multiply(-0.1));
shard.teleport(expl2);
EntityTracker.untrack(shard);
shard.remove();
cancel();
return;
@@ -134,20 +143,23 @@ public class DiamondAttack {
shard.getWorld().spawnParticle(Particle.CRIT, n2, 1, 0.05, 0.05, 0.05, 0);
for (var ent : n2.getWorld().getNearbyEntities(n2, 0.7, 0.7, 0.7, e -> e instanceof LivingEntity && e != p)) {
LivingEntity le = (LivingEntity) ent;
EntityTracker.untrack(shard);
DamageUtil.apply(p, le, 2.0); shard.remove(); cancel(); break;
}
for (Player pl : n2.getWorld().getNearbyPlayers(n2, 0.9)) {
if (pl == p) continue;
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(n2);
if (d2 > 0.25 && d2 < 0.81) {
BlackKnifePlugin.getPlugin(BlackKnifePlugin.class).getTension().addTP(pl, 2.5f, "DODGE +1%");
BlackKnifePlugin.getPlugin(BlackKnifePlugin.class).getTension().tryGiveDodge(pl);
pl.getWorld().spawnParticle(Particle.DUST, pl.getLocation().add(0, 0.25, 0), 25, 0.5, 0.05, 0.5, 0, new Particle.DustOptions(Color.fromRGB(255, 255, 255), 0.15f));
}
}
EntityTracker.untrack(shard);
if (shard.getTicksLived() > 40) { shard.remove(); cancel(); }
}
}.runTaskTimer(plugin, 1L, 1L);
}
EntityTracker.untrack(crystal);
} else if (crystal.getTicksLived() > 60) { crystal.remove(); cancel(); }
}
}.runTaskTimer(plugin, 1L, 1L);