mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-03 19:00:30 +02:00
Adjust critical, remove remainders of old god-mode check.
Critical: * Add tags. * Add extra flag (redundant to MediumLiftOff, just indicating what the real lift off was, might need redesign, since m-lo is modified sometimes.)
This commit is contained in:
parent
6b4421dc81
commit
f4b88b3309
|
@ -1,11 +1,16 @@
|
||||||
package fr.neatmonster.nocheatplus.checks.fight;
|
package fr.neatmonster.nocheatplus.checks.fight;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
import fr.neatmonster.nocheatplus.checks.Check;
|
import fr.neatmonster.nocheatplus.checks.Check;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||||
|
import fr.neatmonster.nocheatplus.checks.ViolationData;
|
||||||
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
|
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
|
||||||
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
|
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
|
||||||
import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
|
import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
|
||||||
|
@ -73,23 +78,33 @@ public class Critical extends Check {
|
||||||
if (dataM.sfLowJump || player.getFallDistance() < cc.criticalFallDistance && !BlockProperties.isOnGroundOrResetCond(player, loc, mCc.yOnGround)){
|
if (dataM.sfLowJump || player.getFallDistance() < cc.criticalFallDistance && !BlockProperties.isOnGroundOrResetCond(player, loc, mCc.yOnGround)){
|
||||||
final MovingConfig ccM = MovingConfig.getConfig(player);
|
final MovingConfig ccM = MovingConfig.getConfig(player);
|
||||||
if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)){
|
if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)){
|
||||||
final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance())
|
final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance()) / cc.criticalFallDistance;
|
||||||
/ cc.criticalFallDistance;
|
final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY())) / cc.criticalVelocity;
|
||||||
final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY()))
|
double delta = deltaFallDistance > 0D ? deltaFallDistance : 0D + deltaVelocity > 0D ? deltaVelocity : 0D;
|
||||||
/ cc.criticalVelocity;
|
|
||||||
final double delta = deltaFallDistance > 0D ? deltaFallDistance
|
final List<String> tags = new ArrayList<String>();
|
||||||
: 0D + deltaVelocity > 0D ? deltaVelocity : 0D;
|
|
||||||
|
|
||||||
// Player failed the check, but this is influenced by lag so don't do it if there was lag.
|
// Player failed the check, but this is influenced by lag so don't do it if there was lag.
|
||||||
if (TickTask.getLag(1000) < 1.5){
|
if (TickTask.getLag(1000) < 1.5){
|
||||||
// TODO: 1.5 is a fantasy value.
|
// TODO: 1.5 is a fantasy value.
|
||||||
// Increment the violation level.
|
// Increment the violation level.
|
||||||
data.criticalVL += delta;
|
data.criticalVL += delta;
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
tags.add("lag");
|
||||||
|
delta = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Execute whatever actions are associated with this check and the violation level and find out if we
|
// Execute whatever actions are associated with this check and the violation level and find out if we
|
||||||
// should cancel the event.
|
// should cancel the event.
|
||||||
cancel = executeActions(player, data.criticalVL, delta, cc.criticalActions);
|
final ViolationData vd = new ViolationData(this, player, data.criticalVL, delta, cc.criticalActions);
|
||||||
|
if (vd.needsParameters()){
|
||||||
|
if (dataM.sfLowJump){
|
||||||
|
tags.add("sf_lowjump");
|
||||||
|
}
|
||||||
|
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
|
||||||
|
}
|
||||||
|
cancel = executeActions(vd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,7 +276,6 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
||||||
final FightData damagedData = damagedPlayer == null ? null : FightData.getData(damagedPlayer);
|
final FightData damagedData = damagedPlayer == null ? null : FightData.getData(damagedPlayer);
|
||||||
final boolean damagedIsDead = damaged.isDead();
|
final boolean damagedIsDead = damaged.isDead();
|
||||||
if (damagedPlayer != null && !damagedIsDead) {
|
if (damagedPlayer != null && !damagedIsDead) {
|
||||||
// if (godMode.isEnabled(player) && godMode.check(player)){
|
|
||||||
if (!damagedPlayer.isDead() && godMode.isEnabled(damagedPlayer) && godMode.check(damagedPlayer, event.getDamage(), damagedData)){
|
if (!damagedPlayer.isDead() && godMode.isEnabled(damagedPlayer) && godMode.check(damagedPlayer, event.getDamage(), damagedData)){
|
||||||
// It requested to "cancel" the players invulnerability, so set his noDamageTicks to 0.
|
// It requested to "cancel" the players invulnerability, so set his noDamageTicks to 0.
|
||||||
damagedPlayer.setNoDamageTicks(0);
|
damagedPlayer.setNoDamageTicks(0);
|
||||||
|
|
|
@ -29,63 +29,6 @@ public class GodMode extends Check {
|
||||||
public GodMode() {
|
public GodMode() {
|
||||||
super(CheckType.FIGHT_GODMODE);
|
super(CheckType.FIGHT_GODMODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks a player.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* the player
|
|
||||||
* @return true, if successful
|
|
||||||
*/
|
|
||||||
public boolean check(final Player player) {
|
|
||||||
final FightData data = FightData.getData(player);
|
|
||||||
|
|
||||||
boolean cancel = false;
|
|
||||||
|
|
||||||
// Check at most once a second.
|
|
||||||
if (data.godModeLastTime < System.currentTimeMillis() - 1000L) {
|
|
||||||
data.godModeLastTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
final int age = player.getTicksLived();
|
|
||||||
|
|
||||||
// How much older did he get?
|
|
||||||
final int ageDelta = Math.max(0, age - data.godModeLastAge);
|
|
||||||
|
|
||||||
if (player.getNoDamageTicks() > 0 && ageDelta < 15) {
|
|
||||||
// He is invulnerable and didn't age fast enough, that costs some points.
|
|
||||||
data.godModeBuffer -= 15 - ageDelta;
|
|
||||||
|
|
||||||
// Still points left?
|
|
||||||
if (data.godModeBuffer <= 0) {
|
|
||||||
// No, that means we can increase his violation level.
|
|
||||||
data.godModeVL -= data.godModeBuffer;
|
|
||||||
|
|
||||||
// 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.godModeVL, -data.godModeBuffer,
|
|
||||||
FightConfig.getConfig(player).godModeActions);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Give some new points, once a second.
|
|
||||||
data.godModeBuffer += 15;
|
|
||||||
|
|
||||||
// Decrease the violation level.
|
|
||||||
data.godModeVL *= 0.95;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.godModeBuffer < 0)
|
|
||||||
// Can't have less than 0!
|
|
||||||
data.godModeBuffer = 0;
|
|
||||||
else if (data.godModeBuffer > 30)
|
|
||||||
// And 30 is enough for simple lag situations.
|
|
||||||
data.godModeBuffer = 30;
|
|
||||||
|
|
||||||
// Start age counting from a new time.
|
|
||||||
data.godModeLastAge = age;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New style god mode check. Much more sensitive.
|
* New style god mode check. Much more sensitive.
|
||||||
|
|
|
@ -160,6 +160,7 @@ public class MovingData extends ACheckData {
|
||||||
|
|
||||||
/** Indicate low jumping descending phase (likely cheating). */
|
/** Indicate low jumping descending phase (likely cheating). */
|
||||||
public boolean sfLowJump = false;
|
public boolean sfLowJump = false;
|
||||||
|
public boolean sfNoLowJump = false; // Hacks.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Last valid y distance covered by a move. Integer.MAX_VALUE indicates "not set".
|
* Last valid y distance covered by a move. Integer.MAX_VALUE indicates "not set".
|
||||||
|
|
|
@ -1008,7 +1008,9 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||||
|
|
||||||
final Vector velocity = event.getVelocity();
|
final Vector velocity = event.getVelocity();
|
||||||
|
|
||||||
if (cc.debug) System.out.println(event.getPlayer().getName() + " new velocity: " + velocity);
|
if (cc.debug){
|
||||||
|
System.out.println(event.getPlayer().getName() + " new velocity: " + velocity);
|
||||||
|
}
|
||||||
|
|
||||||
double newVal = velocity.getY();
|
double newVal = velocity.getY();
|
||||||
boolean used = false;
|
boolean used = false;
|
||||||
|
@ -1036,6 +1038,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||||
// Set dirty flag here.
|
// Set dirty flag here.
|
||||||
if (used){
|
if (used){
|
||||||
data.sfDirty = true;
|
data.sfDirty = true;
|
||||||
|
data.sfNoLowJump = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: clear accounting here ?
|
// TODO: clear accounting here ?
|
||||||
|
@ -1070,6 +1073,8 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||||
|
|
||||||
Location newTo = null;
|
Location newTo = null;
|
||||||
final MovingData data = MovingData.getData(player);
|
final MovingData data = MovingData.getData(player);
|
||||||
|
data.sfNoLowJump = true;
|
||||||
|
|
||||||
if (morePacketsVehicle.isEnabled(player)){
|
if (morePacketsVehicle.isEnabled(player)){
|
||||||
// If the player is handled by the more packets vehicle check, execute it.
|
// If the player is handled by the more packets vehicle check, execute it.
|
||||||
newTo = morePacketsVehicle.check(player, from, to);
|
newTo = morePacketsVehicle.check(player, from, to);
|
||||||
|
|
|
@ -282,6 +282,7 @@ public class SurvivalFly extends Check {
|
||||||
// Calculate the vertical speed limit based on the current jump phase.
|
// Calculate the vertical speed limit based on the current jump phase.
|
||||||
double vAllowedDistance = 0, vDistanceAboveLimit = 0;
|
double vAllowedDistance = 0, vDistanceAboveLimit = 0;
|
||||||
if (from.isInWeb()){
|
if (from.isInWeb()){
|
||||||
|
data.sfNoLowJump = true;
|
||||||
// Very simple: force players to descend or stay.
|
// Very simple: force players to descend or stay.
|
||||||
vAllowedDistance = from.isOnGround() ? 0.1D : 0;
|
vAllowedDistance = from.isOnGround() ? 0.1D : 0;
|
||||||
data.jumpAmplifier = 0; // TODO: later maybe fetch.
|
data.jumpAmplifier = 0; // TODO: later maybe fetch.
|
||||||
|
@ -301,6 +302,7 @@ public class SurvivalFly extends Check {
|
||||||
}
|
}
|
||||||
else if (data.verticalFreedom <= 0.001 && from.isOnClimbable()){
|
else if (data.verticalFreedom <= 0.001 && from.isOnClimbable()){
|
||||||
// Ladder types.
|
// Ladder types.
|
||||||
|
data.sfNoLowJump = true;
|
||||||
// TODO: bring in in-medium accounting.
|
// TODO: bring in in-medium accounting.
|
||||||
// // TODO: make these extra checks to the jumpphase thing ?
|
// // TODO: make these extra checks to the jumpphase thing ?
|
||||||
// if (fromOnGround) vAllowedDistance = climbSpeed + 0.3;
|
// if (fromOnGround) vAllowedDistance = climbSpeed + 0.3;
|
||||||
|
@ -328,6 +330,7 @@ public class SurvivalFly extends Check {
|
||||||
}
|
}
|
||||||
else if (data.verticalFreedom <= 0.001 && from.isInLiquid() && (Math.abs(yDistance) > 0.2 || to.isInLiquid())){
|
else if (data.verticalFreedom <= 0.001 && from.isInLiquid() && (Math.abs(yDistance) > 0.2 || to.isInLiquid())){
|
||||||
// Swimming...
|
// Swimming...
|
||||||
|
data.sfNoLowJump = true;
|
||||||
if (yDistance >= 0){
|
if (yDistance >= 0){
|
||||||
// This is more simple to test.
|
// This is more simple to test.
|
||||||
// TODO: Friction in water...
|
// TODO: Friction in water...
|
||||||
|
@ -378,6 +381,7 @@ public class SurvivalFly extends Check {
|
||||||
if (data.mediumLiftOff == MediumLiftOff.LIMIT_JUMP){
|
if (data.mediumLiftOff == MediumLiftOff.LIMIT_JUMP){
|
||||||
// TODO: In normal water this is 0. Could set higher for special cases only (needs efficient data + flags collection?).
|
// TODO: In normal water this is 0. Could set higher for special cases only (needs efficient data + flags collection?).
|
||||||
maxJumpPhase = 3;
|
maxJumpPhase = 3;
|
||||||
|
data.sfNoLowJump = true;
|
||||||
if (data.sfJumpPhase > 0) tags.add("limitjump");
|
if (data.sfJumpPhase > 0) tags.add("limitjump");
|
||||||
}
|
}
|
||||||
else if (data.jumpAmplifier > 0){
|
else if (data.jumpAmplifier > 0){
|
||||||
|
@ -526,6 +530,7 @@ public class SurvivalFly extends Check {
|
||||||
data.sfJumpPhase = 0;
|
data.sfJumpPhase = 0;
|
||||||
data.clearAccounting();
|
data.clearAccounting();
|
||||||
data.sfLowJump = false;
|
data.sfLowJump = false;
|
||||||
|
data.sfNoLowJump = false;
|
||||||
// TODO: Experimental: reset velocity.
|
// TODO: Experimental: reset velocity.
|
||||||
if (data.verticalVelocityUsed > cc.velocityGraceTicks && toOnGround && yDistance < 0){
|
if (data.verticalVelocityUsed > cc.velocityGraceTicks && toOnGround && yDistance < 0){
|
||||||
data.verticalVelocityCounter = 0;
|
data.verticalVelocityCounter = 0;
|
||||||
|
@ -540,6 +545,7 @@ public class SurvivalFly extends Check {
|
||||||
data.sfJumpPhase = 1; // TODO: ?
|
data.sfJumpPhase = 1; // TODO: ?
|
||||||
data.clearAccounting();
|
data.clearAccounting();
|
||||||
data.sfLowJump = false;
|
data.sfLowJump = false;
|
||||||
|
// not resetting nolow...
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check removal of active horizontal velocity.
|
// Check removal of active horizontal velocity.
|
||||||
|
@ -979,7 +985,7 @@ public class SurvivalFly extends Check {
|
||||||
// Decrease
|
// Decrease
|
||||||
tags.add("ychdec");
|
tags.add("ychdec");
|
||||||
// Detect low jumping.
|
// Detect low jumping.
|
||||||
if (!data.sfDirty && data.mediumLiftOff == MediumLiftOff.GROUND){
|
if (!data.sfNoLowJump && !data.sfDirty && data.mediumLiftOff == MediumLiftOff.GROUND){
|
||||||
final double setBackYDistance = to.getY() - data.getSetBackY();
|
final double setBackYDistance = to.getY() - data.getSetBackY();
|
||||||
if (setBackYDistance > 0.0){
|
if (setBackYDistance > 0.0){
|
||||||
// Only count it if the player has actually been jumping (higher than setback).
|
// Only count it if the player has actually been jumping (higher than setback).
|
||||||
|
|
|
@ -470,7 +470,7 @@ public class DefaultConfig extends ConfigFile {
|
||||||
set(ConfPaths.STRINGS + ".color", start + "sent colored chat message" + end);
|
set(ConfPaths.STRINGS + ".color", start + "sent colored chat message" + end);
|
||||||
set(ConfPaths.STRINGS + ".commands", start + "issued too many commands" + end);
|
set(ConfPaths.STRINGS + ".commands", start + "issued too many commands" + end);
|
||||||
set(ConfPaths.STRINGS + ".combspeed", start + "performs different actions at very high speed" + end);
|
set(ConfPaths.STRINGS + ".combspeed", start + "performs different actions at very high speed" + end);
|
||||||
set(ConfPaths.STRINGS + ".critical", start + "tried to do a critical hit but wasn't technically jumping" + end);
|
set(ConfPaths.STRINGS + ".critical", start + "tried to do a critical hit but wasn't technically jumping [tags]" + end);
|
||||||
set(ConfPaths.STRINGS + ".drop", start + "tried to drop more items than allowed" + end);
|
set(ConfPaths.STRINGS + ".drop", start + "tried to drop more items than allowed" + end);
|
||||||
set(ConfPaths.STRINGS + ".dropkick", "ncp delay ncp kick [player] Dropping items too fast.");
|
set(ConfPaths.STRINGS + ".dropkick", "ncp delay ncp kick [player] Dropping items too fast.");
|
||||||
set(ConfPaths.STRINGS + ".fastbreak", start + "tried to break blocks ([blockid]) faster than possible" + end);
|
set(ConfPaths.STRINGS + ".fastbreak", start + "tried to break blocks ([blockid]) faster than possible" + end);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user