mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-27 14:13:11 +02:00
[BLIND] Add fight.wrongturn: Just kick for invalid pitch.
This commit is contained in:
parent
cec4a4d129
commit
d3a66b01ba
@ -98,6 +98,7 @@ public enum CheckType {
|
||||
FIGHT_SELFHIT(CheckTypeType.CHECK, FIGHT, Permissions.FIGHT_SELFHIT,
|
||||
FightConfig.factory, FightData.selfHitDataFactory),
|
||||
FIGHT_SPEED(FIGHT, Permissions.FIGHT_SPEED),
|
||||
FIGHT_WRONGTURN(FIGHT, null),
|
||||
|
||||
INVENTORY(CheckType.ALL, InventoryConfig.factory, InventoryData.factory, Permissions.INVENTORY),
|
||||
INVENTORY_DROP(INVENTORY, Permissions.INVENTORY_DROP),
|
||||
|
@ -126,6 +126,9 @@ public class FightConfig extends ACheckConfig {
|
||||
public final int speedShortTermTicks;
|
||||
public final ActionList speedActions;
|
||||
|
||||
public final boolean wrongTurnEnabled;
|
||||
public final ActionList wrongTurnActions;
|
||||
|
||||
// Special flags:
|
||||
public final boolean yawRateCheck;
|
||||
public final boolean cancelDead;
|
||||
@ -191,6 +194,10 @@ public class FightConfig extends ACheckConfig {
|
||||
speedShortTermTicks = data.getInt(ConfPaths.FIGHT_SPEED_SHORTTERM_TICKS);
|
||||
speedActions = data.getOptimizedActionList(ConfPaths.FIGHT_SPEED_ACTIONS, Permissions.FIGHT_SPEED);
|
||||
|
||||
wrongTurnEnabled = data.getBoolean(ConfPaths.FIGHT_WRONGTURN_CHECK);
|
||||
wrongTurnActions = data.getOptimizedActionList(ConfPaths.FIGHT_WRONGTURN_ACTIONS,
|
||||
CheckType.FIGHT_WRONGTURN.getPermission());
|
||||
|
||||
|
||||
yawRateCheck = data.getBoolean(ConfPaths.FIGHT_YAWRATE_CHECK, true);
|
||||
cancelDead = data.getBoolean(ConfPaths.FIGHT_CANCELDEAD);
|
||||
|
@ -152,6 +152,7 @@ public class FightData extends ACheckData implements IRemoveSubCheckData {
|
||||
public double noSwingVL;
|
||||
public double reachVL;
|
||||
public double speedVL;
|
||||
public double wrongTurnVL;
|
||||
|
||||
// Shared
|
||||
public String lastWorld = "";
|
||||
|
@ -102,6 +102,9 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
||||
/** The speed check. */
|
||||
private final Speed speed = addCheck(new Speed());
|
||||
|
||||
/** WrongTurn: clearly invalid data on Bukkit side. */
|
||||
private final WrongTurn wrongTurn = addCheck(new WrongTurn());
|
||||
|
||||
/** For temporary use: LocUtil.clone before passing deeply, call setWorld(null) after use. */
|
||||
private final Location useLoc1 = new Location(null, 0, 0, 0);
|
||||
|
||||
@ -268,6 +271,12 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
||||
data.thornsId = Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
// TODO: Add as real check.
|
||||
// TODO: Add something on packet level already.
|
||||
if (wrongTurn.isEnabled(player, cc, pData) && wrongTurn.check(damagedPlayer, loc, data, cc)) {
|
||||
cancelled = true;
|
||||
}
|
||||
|
||||
// Run through the main checks.
|
||||
if (!cancelled && speed.isEnabled(player)) {
|
||||
if (speed.check(player, now)) {
|
||||
|
@ -0,0 +1,47 @@
|
||||
package fr.neatmonster.nocheatplus.checks.fight;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.Check;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
|
||||
/**
|
||||
* First WrongTurn variant (pitch, possibly other).
|
||||
*
|
||||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public class WrongTurn extends Check {
|
||||
|
||||
public WrongTurn() {
|
||||
super(CheckType.FIGHT_WRONGTURN);
|
||||
}
|
||||
|
||||
public boolean check (final Player player, final Location loc, final FightData data, final FightConfig cc) {
|
||||
|
||||
final float pitch = loc.getPitch();
|
||||
|
||||
// Invalid Pitch
|
||||
// TODO: Does invalid pitch arrive here at all?
|
||||
// TODO: Prefer to detect on packet level already.
|
||||
if (Math.abs(pitch) > 90.0f) {
|
||||
data.wrongTurnVL += 1; // (Never cooldown.)
|
||||
if (executeActions(player, data.wrongTurnVL, 1.0, cc.wrongTurnActions).willCancel()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Better have the following in a check not resulting in banning 100% of the time.
|
||||
// TODO: Suspicious yaw + pitch combination (static).
|
||||
/*
|
||||
* TODO: Past moves: detect fast turning towards opponent for an easier
|
||||
* thing (re-use for difficulty). Better have an extra spot for relating
|
||||
* moves of the attacker vs. moves of the attacked.
|
||||
*/
|
||||
// TODO: Past moves: detect optimizing look/position in general.
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -516,6 +516,10 @@ public abstract class ConfPaths {
|
||||
public static final String FIGHT_SPEED_SHORTTERM_TICKS = FIGHT_SPEED_SHORTTERM + "ticks";
|
||||
public static final String FIGHT_SPEED_ACTIONS = FIGHT_SPEED + "actions";
|
||||
|
||||
private static final String FIGHT_WRONGTURN = FIGHT + "wrongturn.";
|
||||
public static final String FIGHT_WRONGTURN_CHECK = FIGHT_WRONGTURN + "active";
|
||||
public static final String FIGHT_WRONGTURN_ACTIONS = FIGHT_WRONGTURN + "actions";
|
||||
|
||||
private static final String FIGHT_YAWRATE = FIGHT + "yawrate.";
|
||||
public static final String FIGHT_YAWRATE_CHECK = FIGHT_YAWRATE + "active";
|
||||
|
||||
|
@ -349,6 +349,9 @@ public class DefaultConfig extends ConfigFile {
|
||||
set(ConfPaths.FIGHT_SPEED_SHORTTERM_TICKS, 7, 785);
|
||||
set(ConfPaths.FIGHT_SPEED_SHORTTERM_LIMIT, 6, 785);
|
||||
|
||||
set(ConfPaths.FIGHT_WRONGTURN_CHECK, true, 1143);
|
||||
set(ConfPaths.FIGHT_WRONGTURN_ACTIONS, "cancel cmd:kick_wrongturn log:log_wrongturn:0:15:fci", 1143);
|
||||
|
||||
set(ConfPaths.INVENTORY_DROP_CHECK, true, 785);
|
||||
set(ConfPaths.INVENTORY_DROP_LIMIT, 100, 785);
|
||||
set(ConfPaths.INVENTORY_DROP_TIMEFRAME, 20L, 785);
|
||||
@ -611,7 +614,9 @@ public class DefaultConfig extends ConfigFile {
|
||||
set(ConfPaths.STRINGS + ".kickpackets", "ncp delay ncp kick [player] Too many packets (extreme lag?)", 785);
|
||||
set(ConfPaths.STRINGS + ".kickselfhit", "ncp kick [player] You tried to hit yourself!", 785);
|
||||
set(ConfPaths.STRINGS + ".kickwb", "ncp kick [player] Block breaking out of sync!", 785);
|
||||
set(ConfPaths.STRINGS + ".kick_wrongturn", "ncp kick [player] Wrong turn!", 1143);
|
||||
set(ConfPaths.STRINGS + ".knockback", start + "tried to do a knockback but wasn't technically sprinting" + end, 785);
|
||||
set(ConfPaths.STRINGS + ".log_wrongturn", start + "looked wrongly" + end, 1143);
|
||||
set(ConfPaths.STRINGS + ".morepackets", start + "sent too many moves ([packets] [tags])" + end, 785);
|
||||
set(ConfPaths.STRINGS + ".msgtempdenylogin", "You are temporarily denied to join this server.", 785);
|
||||
set(ConfPaths.STRINGS + ".munchhausen", start + "almost made it off the pit" + end, 785);
|
||||
|
Loading…
Reference in New Issue
Block a user