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.
Dieser Commit ist enthalten in:
Jesse Boyd 2019-07-17 21:28:46 +10:00
Ursprung 48356275af
Commit 8f902c797d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
2 geänderte Dateien mit 9 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -50,6 +50,7 @@ import java.util.List;
public abstract class ChunkListener implements Listener { public abstract class ChunkListener implements Listener {
protected int rateLimit = 0; 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}; private int[] badLimit = new int[]{Settings.IMP.TICK_LIMITER.PHYSICS_MS, Settings.IMP.TICK_LIMITER.FALLING, Settings.IMP.TICK_LIMITER.ITEMS};
public ChunkListener() { public ChunkListener() {
@ -59,6 +60,10 @@ public abstract class ChunkListener implements Listener {
plm.registerEvents(this, plugin); plm.registerEvents(this, plugin);
try { plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {} try { plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {}
TaskManager.IMP.repeat(() -> { TaskManager.IMP.repeat(() -> {
Location tmpLoc = lastCancelPos;
if (tmpLoc != null) {
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + tmpLoc);
}
rateLimit--; rateLimit--;
physicsFreeze = false; physicsFreeze = false;
itemFreeze = false; itemFreeze = false;
@ -66,6 +71,7 @@ public abstract class ChunkListener implements Listener {
physSkip = 0; physSkip = 0;
physCancelPair = Long.MIN_VALUE; physCancelPair = Long.MIN_VALUE;
physCancel = false; physCancel = false;
lastCancelPos = null;
counter.clear(); counter.clear();
for (Long2ObjectMap.Entry<Boolean> entry : badChunks.long2ObjectEntrySet()) { for (Long2ObjectMap.Entry<Boolean> entry : badChunks.long2ObjectEntrySet()) {
@ -231,7 +237,7 @@ public abstract class ChunkListener implements Listener {
physCancelPair = MathMan.pairInt(cx, cz); physCancelPair = MathMan.pairInt(cx, cz);
if (rateLimit <= 0) { if (rateLimit <= 0) {
rateLimit = 20; rateLimit = 20;
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + block.getLocation()); lastCancelPos = block.getLocation();
} }
cancelNearby(cx, cz); cancelNearby(cx, cz);
event.setCancelled(true); event.setCancelled(true);
@ -305,7 +311,7 @@ public abstract class ChunkListener implements Listener {
cancelNearby(cx, cz); cancelNearby(cx, cz);
if (rateLimit <= 0) { if (rateLimit <= 0) {
rateLimit = 20; rateLimit = 20;
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled falling block lag source at " + block.getLocation()); lastCancelPos = block.getLocation();
} }
event.setCancelled(true); event.setCancelled(true);
return; return;

Datei anzeigen

@ -60,7 +60,7 @@ public class ChunkListener_9 extends ChunkListener {
physCancelPair = MathMan.pairInt(cx, cz); physCancelPair = MathMan.pairInt(cx, cz);
if (rateLimit <= 0) { if (rateLimit <= 0) {
rateLimit = 20; rateLimit = 20;
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + block.getLocation()); lastCancelPos = block.getLocation();
} }
cancelNearby(cx, cz); cancelNearby(cx, cz);
event.setCancelled(true); event.setCancelled(true);