Store passed checks with the last block.
This commit is contained in:
parent
9f3c10951d
commit
e6cc1bad05
|
@ -15,7 +15,9 @@
|
|||
package fr.neatmonster.nocheatplus.checks.blockinteract;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
@ -23,6 +25,7 @@ import org.bukkit.block.Block;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.access.ACheckData;
|
||||
import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory;
|
||||
import fr.neatmonster.nocheatplus.checks.access.ICheckData;
|
||||
|
@ -114,6 +117,8 @@ public class BlockInteractData extends ACheckData {
|
|||
*/
|
||||
public int rateLimitSkip = 0;
|
||||
|
||||
private final Set<CheckType> passedChecks = new HashSet<CheckType>();
|
||||
|
||||
public BlockInteractData(final BlockInteractConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
@ -205,18 +210,36 @@ public class BlockInteractData extends ACheckData {
|
|||
block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the last block (and passed checks).
|
||||
*/
|
||||
public void resetLastBlock() {
|
||||
lastTick = 0;
|
||||
lastAction = null;
|
||||
lastX = Integer.MAX_VALUE;
|
||||
lastType = null;
|
||||
resetPassedChecks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset passed checks (concern the last block interacted with).
|
||||
*/
|
||||
public void resetPassedChecks() {
|
||||
// TODO
|
||||
passedChecks.clear();
|
||||
}
|
||||
|
||||
public void addPassedCheck(final CheckType checkType) {
|
||||
passedChecks.add(checkType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this check type was set as passed for the last block.
|
||||
*
|
||||
* @param checkType
|
||||
* @return
|
||||
*/
|
||||
public boolean isPassedCheck(final CheckType checkType) {
|
||||
return passedChecks.contains(checkType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -224,7 +247,6 @@ public class BlockInteractData extends ACheckData {
|
|||
*/
|
||||
public void onCancelledBlockInteractEvent() {
|
||||
resetLastBlock();
|
||||
resetPassedChecks();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -126,6 +126,7 @@ public class Direction extends Check {
|
|||
} else {
|
||||
// Player did likely nothing wrong, reduce violation counter to reward them.
|
||||
data.directionVL *= 0.9D;
|
||||
data.addPassedCheck(this.type);
|
||||
}
|
||||
return cancel;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ public class Reach extends Check {
|
|||
} else
|
||||
// Player passed the check, reward them.
|
||||
data.reachVL *= 0.9D;
|
||||
data.addPassedCheck(this.type);
|
||||
|
||||
return cancel;
|
||||
}
|
||||
|
|
|
@ -49,10 +49,14 @@ public class Speed extends Check {
|
|||
cancel = true;
|
||||
}
|
||||
}
|
||||
// else: keep vl.
|
||||
else {
|
||||
// keep vl. // Not sure either.
|
||||
data.addPassedCheck(this.type); // Not sure.
|
||||
}
|
||||
}
|
||||
else{
|
||||
data.speedVL *= 0.99;
|
||||
data.addPassedCheck(this.type);
|
||||
}
|
||||
|
||||
return cancel;
|
||||
|
|
|
@ -172,6 +172,7 @@ public class Visible extends Check {
|
|||
}
|
||||
else {
|
||||
data.visibleVL *= 0.99;
|
||||
data.addPassedCheck(this.type);
|
||||
if (data.debug) {
|
||||
debug(player, "pitch=" + loc.getPitch() + ",yaw=" + loc.getYaw() + " tags=" + StringUtil.join(tags, "+"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue