From cce67ac67c8ee3aeb1bf7f2843682f623a13bf37 Mon Sep 17 00:00:00 2001 From: asofold Date: Wed, 23 Jan 2013 03:06:52 +0100 Subject: [PATCH] Account for TickTask resetting. --- .../nocheatplus/checks/blockbreak/BlockBreakListener.java | 3 ++- .../nocheatplus/checks/blockbreak/FastBreak.java | 6 ++++-- .../nocheatplus/checks/blockbreak/Frequency.java | 7 ++++++- .../nocheatplus/checks/blockplace/FastPlace.java | 7 ++++++- .../fr/neatmonster/nocheatplus/checks/chat/Commands.java | 8 +++++++- .../fr/neatmonster/nocheatplus/checks/fight/Speed.java | 7 ++++++- 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java index 5a4fdd1e..0b2ebdc4 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java @@ -244,7 +244,8 @@ public class BlockBreakListener extends CheckListener { final int tick = TickTask.getTick(); // Skip if already set to the same block without breaking within one tick difference. - if (data.fastBreakBreakTime < data.fastBreakfirstDamage && data.clickedX == block.getX() && data.clickedZ == block.getZ() && data.clickedY == block.getY()){ + if (tick < data.clickedTick); + else if (data.fastBreakBreakTime < data.fastBreakfirstDamage && data.clickedX == block.getX() && data.clickedZ == block.getZ() && data.clickedY == block.getY()){ if (tick - data.clickedTick <= 1 ) return; } diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java index c72ba390..261f1f1a 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/FastBreak.java @@ -76,8 +76,10 @@ public class FastBreak extends Check { // // Ignore those for now. // } // else - - if (elapsedTime + cc.fastBreakDelay < breakingTime){ + if (elapsedTime < 0){ + // Ignore it. TODO: ? + } + else if (elapsedTime + cc.fastBreakDelay < breakingTime){ // lag or cheat or Minecraft. // Count in server side lag, if desired. diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/Frequency.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/Frequency.java index 4676b679..566b4f40 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/Frequency.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/Frequency.java @@ -29,7 +29,12 @@ public class Frequency extends Check { // Short term arrivals. final int tick = TickTask.getTick(); - if (tick - data.frequencyShortTermTick < cc.frequencyShortTermTicks){ + if (tick < data.frequencyShortTermTick){ + // Tick task got reset. + data.frequencyShortTermTick = tick; + data.frequencyShortTermCount = 1; + } + else if (tick - data.frequencyShortTermTick < cc.frequencyShortTermTicks){ // Account for server side lag. final float stLag = cc.lag ? TickTask.getLag(50L * (tick - data.frequencyShortTermTick), true) : 1f; if (stLag < 1.5){ diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockplace/FastPlace.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockplace/FastPlace.java index 5fe26864..9a841050 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockplace/FastPlace.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/blockplace/FastPlace.java @@ -48,7 +48,12 @@ public class FastPlace extends Check { // Short term arrivals. final int tick = TickTask.getTick(); - if (tick - data.fastPlaceShortTermTick < cc.fastPlaceShortTermTicks){ + if (tick < data.fastPlaceShortTermTick ){ + // TickTask got reset. + data.fastPlaceShortTermTick = tick; + data.fastPlaceShortTermCount = 1; + } + else if (tick - data.fastPlaceShortTermTick < cc.fastPlaceShortTermTicks){ // Account for server side lag. if (!cc.lag || TickTask.getLag(50L * (tick - data.fastPlaceShortTermTick), true) < 1.2){ // Within range, add. diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/chat/Commands.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/chat/Commands.java index 95aa585d..b0f18ad7 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/chat/Commands.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/chat/Commands.java @@ -41,7 +41,13 @@ public class Commands extends Check { final float weight = 1f; data.commandsWeights.add(now, weight); - if (tick - data.commandsShortTermTick < cc.commandsShortTermTicks){ + if (tick < data.commandsShortTermTick){ + // TickTask got reset. + data.commandsShortTermTick = tick; + data.commandsShortTermWeight = 1.0; + } + else if (tick - data.commandsShortTermTick < cc.commandsShortTermTicks){ + // TODO: account for lag. // Add up. data.commandsShortTermWeight += weight; } diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Speed.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Speed.java index 3c30967f..557995b7 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Speed.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Speed.java @@ -56,7 +56,12 @@ public class Speed extends Check { // Short term. final int tick = TickTask.getTick(); - if (tick - data.speedShortTermTick < cc.speedShortTermTicks){ + if (tick < data.speedShortTermTick){ + // Tick task got reset. + data.speedShortTermTick = tick; + data.speedShortTermCount = 1; + } + else if (tick - data.speedShortTermTick < cc.speedShortTermTicks){ // Account for server side lag. if (!cc.lag || TickTask.getLag(50L * (tick - data.speedShortTermTick), true) < 1.5f){ // Within range, add.