mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-15 03:51:20 +01:00
Remove fight.knockback.
Measuring the time from sprint to attack doesn't work well. The ctrl-sprint thing also adds to it. Better would be measuring the toggle-sprint frequency and possibly combine it with some other measure (packet level attack frequency?) then rather deal attack penalty time.
This commit is contained in:
parent
0fa307a8df
commit
a2e41452e7
@ -74,7 +74,6 @@ public enum CheckType {
|
||||
FIGHT_DIRECTION(FIGHT, Permissions.FIGHT_DIRECTION),
|
||||
FIGHT_FASTHEAL(FIGHT, Permissions.FIGHT_FASTHEAL),
|
||||
FIGHT_GODMODE(FIGHT, Permissions.FIGHT_GODMODE),
|
||||
FIGHT_KNOCKBACK(FIGHT, Permissions.FIGHT_KNOCKBACK),
|
||||
FIGHT_NOSWING(FIGHT, Permissions.FIGHT_NOSWING),
|
||||
FIGHT_REACH(FIGHT, Permissions.FIGHT_REACH),
|
||||
FIGHT_SELFHIT(FIGHT, Permissions.FIGHT_SELFHIT, FightConfig.factory, FightData.selfHitDataFactory),
|
||||
|
@ -80,10 +80,6 @@ public class FightConfig extends ACheckConfig {
|
||||
public final long godModeLagMaxAge;
|
||||
public final ActionList godModeActions;
|
||||
|
||||
public final boolean knockbackCheck;
|
||||
public final long knockbackInterval;
|
||||
public final ActionList knockbackActions;
|
||||
|
||||
public final boolean noSwingCheck;
|
||||
public final ActionList noSwingActions;
|
||||
|
||||
@ -148,10 +144,6 @@ public class FightConfig extends ACheckConfig {
|
||||
godModeLagMaxAge = data.getLong(ConfPaths.FIGHT_GODMODE_LAGMAXAGE);
|
||||
godModeActions = data.getOptimizedActionList(ConfPaths.FIGHT_GODMODE_ACTIONS, Permissions.FIGHT_GODMODE);
|
||||
|
||||
knockbackCheck = data.getBoolean(ConfPaths.FIGHT_KNOCKBACK_CHECK);
|
||||
knockbackInterval = data.getLong(ConfPaths.FIGHT_KNOCKBACK_INTERVAL);
|
||||
knockbackActions = data.getOptimizedActionList(ConfPaths.FIGHT_KNOCKBACK_ACTIONS, Permissions.FIGHT_KNOCKBACK);
|
||||
|
||||
noSwingCheck = data.getBoolean(ConfPaths.FIGHT_NOSWING_CHECK);
|
||||
noSwingActions = data.getOptimizedActionList(ConfPaths.FIGHT_NOSWING_ACTIONS, Permissions.FIGHT_NOSWING);
|
||||
|
||||
@ -197,8 +189,6 @@ public class FightConfig extends ACheckConfig {
|
||||
return directionCheck;
|
||||
case FIGHT_GODMODE:
|
||||
return godModeCheck;
|
||||
case FIGHT_KNOCKBACK:
|
||||
return knockbackCheck;
|
||||
case FIGHT_NOSWING:
|
||||
return noSwingCheck;
|
||||
case FIGHT_REACH:
|
||||
|
@ -123,7 +123,6 @@ public class FightData extends ACheckData {
|
||||
public double directionVL;
|
||||
public double fastHealVL;
|
||||
public double godModeVL;
|
||||
public double knockbackVL;
|
||||
public double noSwingVL;
|
||||
public double reachVL;
|
||||
public double speedVL;
|
||||
@ -167,9 +166,6 @@ public class FightData extends ACheckData {
|
||||
/** Accumulator. */
|
||||
public int godModeAcc = 0;
|
||||
|
||||
// Data of the knockback check.
|
||||
public long knockbackSprintTime;
|
||||
|
||||
// Data of the no swing check.
|
||||
public boolean noSwingArmSwung;
|
||||
|
||||
|
@ -18,7 +18,6 @@ import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
@ -67,9 +66,6 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
||||
/** The god mode check. */
|
||||
private final GodMode godMode = addCheck(new GodMode());
|
||||
|
||||
/** The knockback check. */
|
||||
private final Knockback knockback = addCheck(new Knockback());
|
||||
|
||||
/** The no swing check. */
|
||||
private final NoSwing noSwing = addCheck(new NoSwing());
|
||||
|
||||
@ -222,10 +218,6 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
||||
cancelled = true;
|
||||
}
|
||||
|
||||
if (!cancelled && knockback.isEnabled(player) && knockback.check(player, data, cc)) {
|
||||
cancelled = true;
|
||||
}
|
||||
|
||||
if (!cancelled && noSwing.isEnabled(player) && noSwing.check(player, data, cc)) {
|
||||
cancelled = true;
|
||||
}
|
||||
@ -594,19 +586,6 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
||||
FightData.getData(event.getPlayer()).noSwingArmSwung = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* We listen to the PlayerToggleSprint events for the Knockback check.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onPlayerToggleSprint(final PlayerToggleSprintEvent event) {
|
||||
if (event.isSprinting()) {
|
||||
FightData.getData(event.getPlayer()).knockbackSprintTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityRegainHealthLow(final EntityRegainHealthEvent event){
|
||||
final Entity entity = event.getEntity();
|
||||
|
@ -1,57 +0,0 @@
|
||||
package fr.neatmonster.nocheatplus.checks.fight;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.Check;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||
|
||||
/**
|
||||
* A check used to verify if players aren't "knockbacking" other players when it's not technically possible.
|
||||
*/
|
||||
public class Knockback extends Check {
|
||||
|
||||
/**
|
||||
* Instantiates a new knockback check.
|
||||
*/
|
||||
public Knockback() {
|
||||
super(CheckType.FIGHT_KNOCKBACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a player.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean check(final Player player, final FightData data, final FightConfig cc) {
|
||||
boolean cancel = false;
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
|
||||
// If the item has the knockback enchantment, do not check.
|
||||
if (player.getItemInHand().containsEnchantment(Enchantment.KNOCKBACK)
|
||||
|| player.getItemInHand().containsEnchantment(Enchantment.ARROW_KNOCKBACK))
|
||||
return false;
|
||||
|
||||
// How long ago has the player started sprinting?
|
||||
final long usedTime = (time - data.knockbackSprintTime);
|
||||
final long effectiveTime = (long) ((float) usedTime * (cc.lag ? TickTask.getLag(usedTime, true): 1f));
|
||||
// Pretty rough: Completely skip on lag.
|
||||
if (data.knockbackSprintTime > 0L && effectiveTime < cc.knockbackInterval) {
|
||||
final double difference = cc.knockbackInterval - time + data.knockbackSprintTime;
|
||||
|
||||
// Player failed the check, but this is influenced by lag, so don't do it if there was lag.
|
||||
// Increment the violation level
|
||||
data.knockbackVL += difference;
|
||||
|
||||
// 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.knockbackVL, difference, cc.knockbackActions);
|
||||
}
|
||||
|
||||
return cancel;
|
||||
}
|
||||
}
|
@ -408,11 +408,6 @@ public abstract class ConfPaths {
|
||||
public static final String FIGHT_GODMODE_LAGMAXAGE = FIGHT_GODMODE + "maxage";
|
||||
public static final String FIGHT_GODMODE_ACTIONS = FIGHT_GODMODE + "actions";
|
||||
|
||||
private static final String FIGHT_KNOCKBACK = FIGHT + "knockback.";
|
||||
public static final String FIGHT_KNOCKBACK_CHECK = FIGHT_KNOCKBACK + "active";
|
||||
public static final String FIGHT_KNOCKBACK_INTERVAL = FIGHT_KNOCKBACK + "interval";
|
||||
public static final String FIGHT_KNOCKBACK_ACTIONS = FIGHT_KNOCKBACK + "actions";
|
||||
|
||||
private static final String FIGHT_NOSWING = FIGHT + "noswing.";
|
||||
public static final String FIGHT_NOSWING_CHECK = FIGHT_NOSWING + "active";
|
||||
public static final String FIGHT_NOSWING_ACTIONS = FIGHT_NOSWING + "actions";
|
||||
@ -657,5 +652,11 @@ public abstract class ConfPaths {
|
||||
public static final String FIGHT_CRITICAL_VELOCITY = "checks.fight.critical.velocity";
|
||||
@Deprecated
|
||||
public static final String BLOCKBREAK_FASTBREAK_DEBUG = "checks.blockbreak.fastbreak.debug";
|
||||
@Deprecated
|
||||
public static final String FIGHT_KNOCKBACK_CHECK = "checks.fight.knockback.active";
|
||||
@Deprecated
|
||||
public static final String FIGHT_KNOCKBACK_INTERVAL = "checks.fight.knockback.interval";
|
||||
@Deprecated
|
||||
public static final String FIGHT_KNOCKBACK_ACTIONS = "checks.fight.knockback.actions";
|
||||
|
||||
}
|
||||
|
@ -291,10 +291,6 @@ public class DefaultConfig extends ConfigFile {
|
||||
set(ConfPaths.FIGHT_GODMODE_LAGMAXAGE, 5000);
|
||||
set(ConfPaths.FIGHT_GODMODE_ACTIONS, "log:godmode:2:5:if cancel vl>60 log:godmode:2:5:icf cancel"); // cmd:kickgod");
|
||||
|
||||
set(ConfPaths.FIGHT_KNOCKBACK_CHECK, true);
|
||||
set(ConfPaths.FIGHT_KNOCKBACK_INTERVAL, 50L);
|
||||
set(ConfPaths.FIGHT_KNOCKBACK_ACTIONS, "cancel vl>50 log:knockback:0:5:cif cancel");
|
||||
|
||||
set(ConfPaths.FIGHT_NOSWING_CHECK, true);
|
||||
set(ConfPaths.FIGHT_NOSWING_ACTIONS, "cancel vl>10 log:noswing:0:5:if cancel");
|
||||
|
||||
|
@ -99,7 +99,6 @@ public class Permissions {
|
||||
public static final String FIGHT_DIRECTION = FIGHT + ".direction";
|
||||
public static final String FIGHT_FASTHEAL = FIGHT + ".fastheal";
|
||||
public static final String FIGHT_GODMODE = FIGHT + ".godmode";
|
||||
public static final String FIGHT_KNOCKBACK = FIGHT + ".knockback";
|
||||
public static final String FIGHT_NOSWING = FIGHT + ".noswing";
|
||||
public static final String FIGHT_REACH = FIGHT + ".reach";
|
||||
public static final String FIGHT_SELFHIT = FIGHT + ".selfhit";
|
||||
|
@ -130,8 +130,6 @@ permissions:
|
||||
description: Allow the player to bypass the FastHeal check.
|
||||
nocheatplus.checks.fight.godmode:
|
||||
description: Allow the player to bypass the GodMode check.
|
||||
nocheatplus.checks.fight.knockback:
|
||||
description: Allow the player to bypass the Knockback check.
|
||||
nocheatplus.checks.fight.noswing:
|
||||
description: Allow the player to bypass the NoSwing check.
|
||||
nocheatplus.checks.fight.reach:
|
||||
|
Loading…
Reference in New Issue
Block a user