mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-15 08:28:10 +02:00
Fix instantbow resetting, e.g. with item changing, if in strict mode.
This commit is contained in:
parent
b822b5c08a
commit
4213002653
@ -42,19 +42,29 @@ public class InstantBow extends Check {
|
||||
final long expectedPullDuration = (long) (maxTime - maxTime * (1f - force) * (1f - force)) - cc.instantBowDelay;
|
||||
|
||||
// Time taken to pull the string.
|
||||
final long pullDuration = now - (cc.instantBowStrict ? data.instantBowInteract : data.instantBowShoot);
|
||||
final long pullDuration;
|
||||
final boolean valid;
|
||||
if (cc.instantBowStrict) {
|
||||
// The interact time is invalid, if set to 0.
|
||||
valid = data.instantBowInteract != 0;
|
||||
pullDuration = valid ? (now - data.instantBowInteract) : 0L;
|
||||
} else {
|
||||
valid = true;
|
||||
pullDuration = now - data.instantBowShoot;
|
||||
}
|
||||
|
||||
if ((!cc.instantBowStrict || data.instantBowInteract > 0) && pullDuration >= expectedPullDuration){
|
||||
if (valid && (!cc.instantBowStrict || data.instantBowInteract > 0L) && pullDuration >= expectedPullDuration) {
|
||||
// The player was slow enough, reward them by lowering their violation level.
|
||||
data.instantBowVL *= 0.9D;
|
||||
}
|
||||
else if (data.instantBowInteract > now){
|
||||
else if (valid && data.instantBowInteract > now) {
|
||||
// Security check if time ran backwards.
|
||||
// TODO: Maybe this can be removed, though TickTask does not reset at the exact moment.
|
||||
}
|
||||
else {
|
||||
// Account for server side lag.
|
||||
final long correctedPullduration = cc.lag ? (long) (TickTask.getLag(expectedPullDuration, true) * pullDuration) : pullDuration;
|
||||
// (Do not apply correction to invalid pulling.)
|
||||
final long correctedPullduration = valid ? (cc.lag ? (long) (TickTask.getLag(expectedPullDuration, true) * pullDuration) : pullDuration) : 0;
|
||||
if (correctedPullduration < expectedPullDuration) {
|
||||
// TODO: Consider: Allow one time but set yawrate penalty time ?
|
||||
final double difference = (expectedPullDuration - pullDuration) / 100D;
|
||||
|
@ -79,7 +79,8 @@ public class InventoryData extends ACheckData {
|
||||
public int fastClickLastCursorAmount = 0;
|
||||
|
||||
// Data of the instant bow check.
|
||||
public long instantBowInteract;
|
||||
/** Last time right click interact on bow. A value of 0 means 'invalid'.*/
|
||||
public long instantBowInteract = 0;
|
||||
public long instantBowShoot;
|
||||
|
||||
// Data of the instant eat check.
|
||||
|
@ -263,7 +263,7 @@ public class InventoryListener extends CheckListener implements JoinLeaveListen
|
||||
public void onItemHeldChange(final PlayerItemHeldEvent event){
|
||||
final Player player = event.getPlayer();
|
||||
final InventoryData data = InventoryData.getData(player);
|
||||
data.instantBowInteract = 0;
|
||||
data.instantBowInteract = Long.MAX_VALUE;
|
||||
data.instantEatInteract = 0;
|
||||
data.instantEatFood = null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user