From 8f902c797de33f5481159a5f7664e329dde57c66 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 17 Jul 2019 21:28:46 +1000 Subject: [PATCH] Don't print within high stack depth conditions FAWE is trying to detect prevent a stackoverflow from block/item lag. Calling print adds to the stack depth. --- .../java/com/boydti/fawe/bukkit/v0/ChunkListener.java | 10 ++++++++-- .../com/boydti/fawe/bukkit/v0/ChunkListener_9.java | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java index a2ca171cc..e7bef8045 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java @@ -50,6 +50,7 @@ import java.util.List; public abstract class ChunkListener implements Listener { protected int rateLimit = 0; + protected Location lastCancelPos; private int[] badLimit = new int[]{Settings.IMP.TICK_LIMITER.PHYSICS_MS, Settings.IMP.TICK_LIMITER.FALLING, Settings.IMP.TICK_LIMITER.ITEMS}; public ChunkListener() { @@ -59,6 +60,10 @@ public abstract class ChunkListener implements Listener { plm.registerEvents(this, plugin); try { plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {} TaskManager.IMP.repeat(() -> { + Location tmpLoc = lastCancelPos; + if (tmpLoc != null) { + Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + tmpLoc); + } rateLimit--; physicsFreeze = false; itemFreeze = false; @@ -66,6 +71,7 @@ public abstract class ChunkListener implements Listener { physSkip = 0; physCancelPair = Long.MIN_VALUE; physCancel = false; + lastCancelPos = null; counter.clear(); for (Long2ObjectMap.Entry entry : badChunks.long2ObjectEntrySet()) { @@ -231,7 +237,7 @@ public abstract class ChunkListener implements Listener { physCancelPair = MathMan.pairInt(cx, cz); if (rateLimit <= 0) { rateLimit = 20; - Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + block.getLocation()); + lastCancelPos = block.getLocation(); } cancelNearby(cx, cz); event.setCancelled(true); @@ -305,7 +311,7 @@ public abstract class ChunkListener implements Listener { cancelNearby(cx, cz); if (rateLimit <= 0) { rateLimit = 20; - Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled falling block lag source at " + block.getLocation()); + lastCancelPos = block.getLocation(); } event.setCancelled(true); return; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_9.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_9.java index 7c84f1924..53ccbe1ca 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_9.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_9.java @@ -60,7 +60,7 @@ public class ChunkListener_9 extends ChunkListener { physCancelPair = MathMan.pairInt(cx, cz); if (rateLimit <= 0) { rateLimit = 20; - Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + block.getLocation()); + lastCancelPos = block.getLocation(); } cancelNearby(cx, cz); event.setCancelled(true);