mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-16 12:31:28 +01:00
InstantBow: Add "strict" flag for laggy servers.
If set to false only the time since last shot is taken into account. This allows an instant first shot always but still prevents "machine gun" hacks, which might be a good option for servers with much lag.
This commit is contained in:
parent
c7e7077ced
commit
25c5c48576
@ -50,9 +50,9 @@ 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 - data.instantBowInteract;
|
||||
final long pullDuration = now - (cc.instantBowStrict ? data.instantBowInteract : data.instantBowShoot);
|
||||
|
||||
if (data.instantBowInteract > 0 && pullDuration >= expectedPullDuration){
|
||||
if ((!cc.instantBowStrict || data.instantBowInteract > 0) && pullDuration >= expectedPullDuration){
|
||||
// The player was slow enough, reward him by lowering his violation level.
|
||||
data.instantBowVL *= 0.9D;
|
||||
}
|
||||
@ -69,17 +69,16 @@ public class InstantBow extends Check {
|
||||
|
||||
// Execute whatever actions are associated with this check and the
|
||||
// violation level and find out if we should cancel the event
|
||||
cancel = executeActions(player, data.instantBowVL, difference,
|
||||
cc.instantBowActions);
|
||||
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 +", pull time: " + pullDuration + "(" + expectedPullDuration +")");
|
||||
player.sendMessage(ChatColor.YELLOW + "NCP: " + ChatColor.GRAY + "Bow shot - force: " + force +", " + (cc.instantBowStrict || pullDuration < 2 * expectedPullDuration ? ("pull time: " + pullDuration) : "") + "(" + expectedPullDuration +")");
|
||||
}
|
||||
|
||||
// Reset data here.
|
||||
data.instantBowInteract = 0;
|
||||
|
||||
data.instantBowShoot = now;
|
||||
return cancel;
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ public class InventoryConfig extends ACheckConfig {
|
||||
public final ActionList fastClickActions;
|
||||
|
||||
public final boolean instantBowCheck;
|
||||
public final boolean instantBowStrict;
|
||||
public final long instantBowDelay;
|
||||
public final ActionList instantBowActions;
|
||||
|
||||
@ -112,6 +113,7 @@ public class InventoryConfig extends ACheckConfig {
|
||||
Permissions.INVENTORY_FASTCLICK);
|
||||
|
||||
instantBowCheck = data.getBoolean(ConfPaths.INVENTORY_INSTANTBOW_CHECK);
|
||||
instantBowStrict = data.getBoolean(ConfPaths.INVENTORY_INSTANTBOW_STRICT);
|
||||
instantBowDelay = data.getInt(ConfPaths.INVENTORY_INSTANTBOW_DELAY);
|
||||
instantBowActions = data.getActionList(
|
||||
ConfPaths.INVENTORY_INSTANTBOW_ACTIONS,
|
||||
|
@ -83,6 +83,7 @@ public class InventoryData extends ACheckData {
|
||||
|
||||
// Data of the instant bow check.
|
||||
public long instantBowInteract;
|
||||
public long instantBowShoot;
|
||||
|
||||
// Data of the instant eat check.
|
||||
public Material instantEatFood;
|
||||
|
@ -418,6 +418,7 @@ public abstract class ConfPaths {
|
||||
|
||||
private static final String INVENTORY_INSTANTBOW = INVENTORY + "instantbow.";
|
||||
public static final String INVENTORY_INSTANTBOW_CHECK = INVENTORY_INSTANTBOW + "active";
|
||||
public static final String INVENTORY_INSTANTBOW_STRICT = INVENTORY_INSTANTBOW + "strict";
|
||||
public static final String INVENTORY_INSTANTBOW_DELAY = INVENTORY_INSTANTBOW + "delay";
|
||||
public static final String INVENTORY_INSTANTBOW_ACTIONS = INVENTORY_INSTANTBOW + "actions";
|
||||
|
||||
|
@ -319,6 +319,7 @@ public class DefaultConfig extends ConfigFile {
|
||||
set(ConfPaths.INVENTORY_FASTCLICK_ACTIONS, "cancel vl>50 log:fastclick:3:5:cif cancel");
|
||||
|
||||
set(ConfPaths.INVENTORY_INSTANTBOW_CHECK, true);
|
||||
set(ConfPaths.INVENTORY_INSTANTBOW_STRICT, true);
|
||||
set(ConfPaths.INVENTORY_INSTANTBOW_DELAY, 130);
|
||||
set(ConfPaths.INVENTORY_INSTANTBOW_ACTIONS, "cancel vl>15 log:instantbow:2:5:if cancel");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user