mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-03-10 05:29:12 +01:00
Ensure wrongBlock does not add Integer.MAX_VALUE as violation level.
Also cap violation at 4.
This commit is contained in:
parent
894aa466d6
commit
ce5a90201c
@ -26,45 +26,49 @@ public class WrongBlock extends Check {
|
||||
* @param isInstaBreak
|
||||
* @return
|
||||
*/
|
||||
public boolean check(final Player player, final Block block, final BlockBreakConfig cc, final BlockBreakData data, final boolean isInstaBreak){
|
||||
public boolean check(final Player player, final Block block, final BlockBreakConfig cc, final BlockBreakData data, final boolean isInstaBreak) {
|
||||
|
||||
boolean cancel = false;
|
||||
|
||||
final boolean wrongTime = data.fastBreakfirstDamage < data.fastBreakBreakTime;
|
||||
final int dist = TrigUtil.manhattan(data.clickedX, data.clickedY, data.clickedZ, block);
|
||||
final int dist = Math.min(4, data.clickedX == Integer.MAX_VALUE ? 100 : TrigUtil.manhattan(data.clickedX, data.clickedY, data.clickedZ, block));
|
||||
final boolean wrongBlock;
|
||||
final long now = System.currentTimeMillis();
|
||||
if (dist == 0){
|
||||
if (wrongTime){
|
||||
if (dist == 0) {
|
||||
if (wrongTime) {
|
||||
data.fastBreakBreakTime = now;
|
||||
data.fastBreakfirstDamage = now;
|
||||
// Could set to wrong block, but prefer to transform it into a quasi insta break.
|
||||
}
|
||||
wrongBlock = false;
|
||||
}
|
||||
else if (dist == 1){
|
||||
else if (dist == 1) {
|
||||
// One might to a concession in case of instant breaking.
|
||||
if (now - data.wasInstaBreak < 60)
|
||||
if (now - data.wasInstaBreak < 60) {
|
||||
wrongBlock = false;
|
||||
else
|
||||
}
|
||||
else {
|
||||
wrongBlock = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
// Note that the maximally counted distance is set above.
|
||||
wrongBlock = true;
|
||||
}
|
||||
|
||||
if (wrongBlock){
|
||||
// Manhattan distance.
|
||||
|
||||
if ((cc.fastBreakDebug || cc.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
|
||||
if (wrongBlock) {
|
||||
if ((cc.fastBreakDebug || cc.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) {
|
||||
player.sendMessage("WrongBlock failure with dist: " + dist);
|
||||
}
|
||||
data.wrongBlockVL.add(now, (float) (dist + 1) / 2f);
|
||||
final float score = data.wrongBlockVL.score(0.9f);
|
||||
if (score > cc.wrongBLockLevel){
|
||||
if (executeActions(player, score, 1D, cc.wrongBlockActions))
|
||||
if (score > cc.wrongBLockLevel) {
|
||||
if (executeActions(player, score, 1D, cc.wrongBlockActions)) {
|
||||
cancel = true;
|
||||
if (Improbable.check(player, 2.0f, now, "blockbreak.wrongblock"))
|
||||
}
|
||||
if (Improbable.check(player, 2.0f, now, "blockbreak.wrongblock")) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user