mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-04 06:28:52 +00:00
Properly handle instances where time for break/place may be expected as 0
This commit is contained in:
1 parent
cfe291acf5
commit
d12fb048df
3 files changed
+10
-12
No files matched your search
@@ -656,7 +656,8 @@ public class Backend {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
|
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
|
||||||
if (math < timemax && (math != 0L)) {
|
if((math != 0L && timemax != 0L)) {
|
||||||
|
if (math < timemax) {
|
||||||
if (fastBreakViolation.containsKey(name) && fastBreakViolation.get(name) > 0) {
|
if (fastBreakViolation.containsKey(name) && fastBreakViolation.get(name) > 0) {
|
||||||
fastBreakViolation.put(name, fastBreakViolation.get(name) + 1);
|
fastBreakViolation.put(name, fastBreakViolation.get(name) + 1);
|
||||||
} else {
|
} else {
|
||||||
@@ -680,16 +681,14 @@ public class Backend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lastBlockBroken.put(name, System.currentTimeMillis()); // always keep a log going.
|
lastBlockBroken.put(name, System.currentTimeMillis()); // always keep a log going.
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkFastPlace(Player player) {
|
public CheckResult checkFastPlace(Player player) {
|
||||||
int violations = magic.FASTPLACE_MAXVIOLATIONS;
|
int violations = player.getGameMode() == GameMode.CREATIVE ? magic.FASTPLACE_MAXVIOLATIONS_CREATIVE : magic.FASTPLACE_MAXVIOLATIONS;
|
||||||
if (player.getGameMode() == GameMode.CREATIVE) {
|
|
||||||
violations = magic.FASTPLACE_MAXVIOLATIONS_CREATIVE;
|
|
||||||
}
|
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if (!lastBlockPlaceTime.containsKey(name) || !fastPlaceViolation.containsKey(name)) {
|
if (!lastBlockPlaceTime.containsKey(name) || !fastPlaceViolation.containsKey(name)) {
|
||||||
@@ -713,13 +712,12 @@ public class Backend {
|
|||||||
long lastTime = lastBlockPlaceTime.get(name);
|
long lastTime = lastBlockPlaceTime.get(name);
|
||||||
long thisTime = time - last;
|
long thisTime = time - last;
|
||||||
|
|
||||||
if (thisTime < magic.FASTPLACE_TIMEMAX || lastTime < magic.FASTPLACE_TIMEMAX) {
|
if (lastTime != 0 && thisTime < magic.FASTPLACE_TIMEMIN) {
|
||||||
lastBlockPlaceTime.put(name, (time - last));
|
lastBlockPlaceTime.put(name, (time - last));
|
||||||
lastBlockPlaced.put(name, time);
|
lastBlockPlaced.put(name, time);
|
||||||
fastPlaceViolation.put(name, fastPlaceViolation.get(name) + 1);
|
fastPlaceViolation.put(name, fastPlaceViolation.get(name) + 1);
|
||||||
return new CheckResult(Result.FAILED, player.getName()+" tried to place a block "+thisTime+" ms after the last one (min="+magic.FASTPLACE_TIMEMAX+" ms)");
|
return new CheckResult(Result.FAILED, player.getName()+" tried to place a block "+thisTime+" ms after the last one (min="+magic.FASTPLACE_TIMEMIN+" ms)");
|
||||||
}
|
}
|
||||||
|
|
||||||
lastBlockPlaceTime.put(name, (time - last));
|
lastBlockPlaceTime.put(name, (time - last));
|
||||||
}
|
}
|
||||||
lastBlockPlaced.put(name, time);
|
lastBlockPlaced.put(name, time);
|
||||||
|
|||||||
@@ -118,9 +118,9 @@ public class Magic {
|
|||||||
*/
|
*/
|
||||||
public final int FASTPLACE_ZEROLIMIT;
|
public final int FASTPLACE_ZEROLIMIT;
|
||||||
/**
|
/**
|
||||||
* Time to wait before checking block places; Type=system, +Leniency=Increase.
|
* Minimum time in between block places; Type=system, +Leniency=Decrease.
|
||||||
*/
|
*/
|
||||||
public final int FASTPLACE_TIMEMAX;
|
public final int FASTPLACE_TIMEMIN;
|
||||||
/**
|
/**
|
||||||
* Number of times fastplace can be observed before taking action; Type=integer, +Leniency=Increase.
|
* Number of times fastplace can be observed before taking action; Type=integer, +Leniency=Increase.
|
||||||
*/
|
*/
|
||||||
@@ -361,7 +361,7 @@ public class Magic {
|
|||||||
FASTBREAK_MAXVIOLATIONS_CREATIVE = getInt("FASTBREAK_MAXVIOLATIONS_CREATIVE");
|
FASTBREAK_MAXVIOLATIONS_CREATIVE = getInt("FASTBREAK_MAXVIOLATIONS_CREATIVE");
|
||||||
FASTBREAK_MAXVIOLATIONTIME = getInt("FASTBREAK_MAXVIOLATIONTIME");
|
FASTBREAK_MAXVIOLATIONTIME = getInt("FASTBREAK_MAXVIOLATIONTIME");
|
||||||
FASTPLACE_ZEROLIMIT = getInt("FASTPLACE_ZEROLIMIT");
|
FASTPLACE_ZEROLIMIT = getInt("FASTPLACE_ZEROLIMIT");
|
||||||
FASTPLACE_TIMEMAX = getInt("FASTPLACE_TIMEMAX");
|
FASTPLACE_TIMEMIN = getInt("FASTPLACE_TIMEMIN");
|
||||||
FASTPLACE_MAXVIOLATIONS = getInt("FASTPLACE_MAXVIOLATIONS");
|
FASTPLACE_MAXVIOLATIONS = getInt("FASTPLACE_MAXVIOLATIONS");
|
||||||
FASTPLACE_MAXVIOLATIONS_CREATIVE = getInt("FASTPLACE_MAXVIOLATIONS_CREATIVE");
|
FASTPLACE_MAXVIOLATIONS_CREATIVE = getInt("FASTPLACE_MAXVIOLATIONS_CREATIVE");
|
||||||
FASTPLACE_MAXVIOLATIONTIME = getInt("FASTPLACE_MAXVIOLATIONTIME");
|
FASTPLACE_MAXVIOLATIONTIME = getInt("FASTPLACE_MAXVIOLATIONTIME");
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ FASTBREAK_MAXVIOLATIONS: 2
|
|||||||
FASTBREAK_MAXVIOLATIONS_CREATIVE: 4
|
FASTBREAK_MAXVIOLATIONS_CREATIVE: 4
|
||||||
FASTBREAK_MAXVIOLATIONTIME: 10000
|
FASTBREAK_MAXVIOLATIONTIME: 10000
|
||||||
FASTPLACE_ZEROLIMIT: 3
|
FASTPLACE_ZEROLIMIT: 3
|
||||||
FASTPLACE_TIMEMAX: 50
|
FASTPLACE_TIMEMIN: 50
|
||||||
FASTPLACE_MAXVIOLATIONS: 2
|
FASTPLACE_MAXVIOLATIONS: 2
|
||||||
FASTPLACE_MAXVIOLATIONS_CREATIVE: 3
|
FASTPLACE_MAXVIOLATIONS_CREATIVE: 3
|
||||||
FASTPLACE_MAXVIOLATIONTIME: 10000
|
FASTPLACE_MAXVIOLATIONTIME: 10000
|
||||||
|
|||||||
Reference in new issue
Block a user