[Bleeding] Account for server side lag in inventory.instantbow.

This commit is contained in:
asofold 2013-01-04 15:55:21 +01:00
parent 1b350af75f
commit 8bb35fec94

View File

@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.TickTask;
/*
* M""M dP dP M#"""""""'M
@ -61,6 +62,9 @@ public class InstantBow extends Check {
// 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;
if (correctedPullduration < expectedPullDuration){
// TODO: Consider: Allow one time but set yawrate penalty time ?
final double difference = (expectedPullDuration - pullDuration) / 100D;
@ -71,6 +75,7 @@ public class InstantBow extends Check {
// violation level and find out if we should cancel the event
cancel = executeActions(player, data.instantBowVL, difference, cc.instantBowActions);
}
}
if (cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
player.sendMessage(ChatColor.YELLOW + "NCP: " + ChatColor.GRAY + "Bow shot - force: " + force +", " + (cc.instantBowStrict || pullDuration < 2 * expectedPullDuration ? ("pull time: " + pullDuration) : "") + "(" + expectedPullDuration +")");