mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-29 03:48:50 +01:00
NoFallCheck implementation
This commit is contained in:
parent
41a09ea5ae
commit
1ac3c524e5
@ -30,6 +30,7 @@ permissions:
|
|||||||
nocheat.checks.moving.swimming: true
|
nocheat.checks.moving.swimming: true
|
||||||
nocheat.checks.moving.sneaking: true
|
nocheat.checks.moving.sneaking: true
|
||||||
nocheat.checks.moving.noclip: true
|
nocheat.checks.moving.noclip: true
|
||||||
|
nocheat.checks.moving.nofall: true
|
||||||
nocheat.checks.moving.morepackets: true
|
nocheat.checks.moving.morepackets: true
|
||||||
|
|
||||||
nocheat.checks.blockbreak.*:
|
nocheat.checks.blockbreak.*:
|
||||||
@ -69,6 +70,9 @@ permissions:
|
|||||||
nocheat.checks.moving.noclip:
|
nocheat.checks.moving.noclip:
|
||||||
description: Allow a player to walk through walls
|
description: Allow a player to walk through walls
|
||||||
default: op
|
default: op
|
||||||
|
nocheat.checks.moving.nofall:
|
||||||
|
description: Allow a player to cheat and not take fall damage at all
|
||||||
|
default: op
|
||||||
nocheat.checks.moving.morepackets:
|
nocheat.checks.moving.morepackets:
|
||||||
description: Allow a player to send more move-event-packets than normal, causing him to move faster than normal
|
description: Allow a player to send more move-event-packets than normal, causing him to move faster than normal
|
||||||
default: op
|
default: op
|
||||||
|
@ -77,22 +77,24 @@ public class DefaultConfiguration {
|
|||||||
runflyNode.add(new IntegerOption("swimmingspeedlimit", 18));
|
runflyNode.add(new IntegerOption("swimmingspeedlimit", 18));
|
||||||
|
|
||||||
ActionListOption walkactions = new ActionListOption("actions");
|
ActionListOption walkactions = new ActionListOption("actions");
|
||||||
|
|
||||||
runflyNode.add(walkactions);
|
runflyNode.add(walkactions);
|
||||||
|
|
||||||
walkactions.add(0, "moveLogLowShort moveCancel");
|
walkactions.add(0, "moveLogLowShort moveCancel");
|
||||||
walkactions.add(100, "moveLogMedShort moveCancel");
|
walkactions.add(100, "moveLogMedShort moveCancel");
|
||||||
walkactions.add(400, "moveLogHighShort moveCancel");
|
walkactions.add(400, "moveLogHighShort moveCancel");
|
||||||
|
|
||||||
|
runflyNode.add(new BooleanOption("checknofall", true, false));
|
||||||
|
runflyNode.add(new IntegerOption("nofallmultiplier", 100));
|
||||||
|
ActionListOption nofallactions = new ActionListOption("nofallactions");
|
||||||
|
runflyNode.add(nofallactions);
|
||||||
|
nofallactions.add(0, "nofallLog nofallCancel");
|
||||||
|
|
||||||
runflyNode.add(new BooleanOption("allowlimitedflying", false, false));
|
runflyNode.add(new BooleanOption("allowlimitedflying", false, false));
|
||||||
|
|
||||||
runflyNode.add(new IntegerOption("flyingspeedlimitvertical", 100));
|
runflyNode.add(new IntegerOption("flyingspeedlimitvertical", 100));
|
||||||
runflyNode.add(new IntegerOption("flyingspeedlimithorizontal", 60));
|
runflyNode.add(new IntegerOption("flyingspeedlimithorizontal", 60));
|
||||||
|
|
||||||
ActionListOption flyactions = new ActionListOption("flyingactions");
|
ActionListOption flyactions = new ActionListOption("flyingactions");
|
||||||
|
|
||||||
runflyNode.add(flyactions);
|
runflyNode.add(flyactions);
|
||||||
|
|
||||||
flyactions.add(0, "moveLogLowShort moveCancel");
|
flyactions.add(0, "moveLogLowShort moveCancel");
|
||||||
flyactions.add(100, "moveLogMedShort moveCancel");
|
flyactions.add(100, "moveLogMedShort moveCancel");
|
||||||
flyactions.add(400, "moveLogHighShort moveCancel");
|
flyactions.add(400, "moveLogHighShort moveCancel");
|
||||||
@ -330,6 +332,7 @@ public class DefaultConfiguration {
|
|||||||
w(w, "log durabilityLog 0 1 med NC: [player] failed [check]: tried to use infinity durability hack.");
|
w(w, "log durabilityLog 0 1 med NC: [player] failed [check]: tried to use infinity durability hack.");
|
||||||
w(w, "log onliquidLog 2 1 med NC: [player] failed [check]: tried to place a block on liquids.");
|
w(w, "log onliquidLog 2 1 med NC: [player] failed [check]: tried to place a block on liquids.");
|
||||||
w(w, "log spamLog 0 4 med NC: [player] failed [check]: Last sent message \"[text]\".");
|
w(w, "log spamLog 0 4 med NC: [player] failed [check]: Last sent message \"[text]\".");
|
||||||
|
w(w, "log nofallLog 0 1 med NC: [player] failed [check]: tried to avoid fall damage for ~[distance] blocks.");
|
||||||
w(w, "");
|
w(w, "");
|
||||||
w(w, "# SPECIAL Actions: They will do something check dependant, usually cancel an event.");
|
w(w, "# SPECIAL Actions: They will do something check dependant, usually cancel an event.");
|
||||||
w(w, "# - They start with the word 'special'");
|
w(w, "# - They start with the word 'special'");
|
||||||
@ -344,6 +347,7 @@ public class DefaultConfiguration {
|
|||||||
w(w, "special blockplaceCancel 0 0");
|
w(w, "special blockplaceCancel 0 0");
|
||||||
w(w, "special interactCancel 0 0");
|
w(w, "special interactCancel 0 0");
|
||||||
w(w, "special spamCancel 0 0");
|
w(w, "special spamCancel 0 0");
|
||||||
|
w(w, "special nofallCancel 0 0");
|
||||||
w(w, "");
|
w(w, "");
|
||||||
w(w, "# CONSOLECOMMAND Actions: They will execute a command as if it were typed into the console.");
|
w(w, "# CONSOLECOMMAND Actions: They will execute a command as if it were typed into the console.");
|
||||||
w(w, "# - They start with the word 'consolecommand'");
|
w(w, "# - They start with the word 'consolecommand'");
|
||||||
|
@ -23,6 +23,7 @@ public class Permissions {
|
|||||||
public final static String MOVE_SWIM = _MOVE + ".swimming";
|
public final static String MOVE_SWIM = _MOVE + ".swimming";
|
||||||
public final static String MOVE_FLY = _MOVE + ".flying";
|
public final static String MOVE_FLY = _MOVE + ".flying";
|
||||||
public final static String MOVE_NOCLIP = _MOVE + ".noclip";
|
public final static String MOVE_NOCLIP = _MOVE + ".noclip";
|
||||||
|
public final static String MOVE_NOFALL = _MOVE + ".nofall";
|
||||||
public final static String MOVE_MOREPACKETS = _MOVE + ".morepackets";
|
public final static String MOVE_MOREPACKETS = _MOVE + ".morepackets";
|
||||||
|
|
||||||
public final static String BLOCKBREAK = _CHECKS + ".blockbreak.*";
|
public final static String BLOCKBREAK = _CHECKS + ".blockbreak.*";
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
package cc.co.evenprime.bukkit.nocheat.checks.moving;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import net.minecraft.server.DamageSource;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event.Type;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutor;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.actions.ActionExecutorWithHistory;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.actions.types.LogAction;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.data.MovingData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A check to see if people cheat by tricking the server to not deal them
|
||||||
|
* fall damage.
|
||||||
|
*
|
||||||
|
* @author Evenprime
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class NoFallCheck {
|
||||||
|
|
||||||
|
private final ActionExecutor action;
|
||||||
|
private final NoCheat plugin;
|
||||||
|
|
||||||
|
public NoFallCheck(NoCheat plugin) {
|
||||||
|
this.action = new ActionExecutorWithHistory(plugin);
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate if and how much the player "failed" this check.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void check(final Player player, final Location from, final boolean fromOnOrInGround, final Location to, final boolean toOnOrInGround, final ConfigurationCache cc, final MovingData data) {
|
||||||
|
|
||||||
|
double oldY = from.getY();
|
||||||
|
double newY = to.getY();
|
||||||
|
|
||||||
|
// This check is pretty much always a step behind for technical reasons.
|
||||||
|
if(fromOnOrInGround) {
|
||||||
|
// Start with zero fall distance
|
||||||
|
data.fallDistance = 0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We want to know if the fallDistance recorded by the game is smaller
|
||||||
|
// than the fall distance recorded by the plugin
|
||||||
|
float distance = data.fallDistance - player.getFallDistance();
|
||||||
|
|
||||||
|
if(distance > 0.01 && toOnOrInGround && data.fallDistance > 2.0F) {
|
||||||
|
data.nofallViolationLevel += distance;
|
||||||
|
// Prepare some event-specific values for logging and custom actions
|
||||||
|
HashMap<String, String> params = new HashMap<String, String>();
|
||||||
|
params.put(LogAction.DISTANCE, String.format(Locale.US, "%.2f", data.fallDistance));
|
||||||
|
params.put(LogAction.CHECK, "nofall");
|
||||||
|
|
||||||
|
boolean cancel = action.executeActions(player, cc.moving.nofallActions, (int) data.nofallViolationLevel, params, cc);
|
||||||
|
|
||||||
|
// If "cancelled", the fall damage gets dealt in a way that's visible to other players
|
||||||
|
if(cancel) {
|
||||||
|
// Increase the damage a bit :)
|
||||||
|
float totalDistance = (data.fallDistance - 2.0F)* cc.moving.nofallMultiplier + 2.0F;
|
||||||
|
player.setFallDistance(totalDistance);
|
||||||
|
((CraftPlayer)player).getHandle().b(totalDistance, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
data.fallDistance = 0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reduce falldamage violation level
|
||||||
|
data.nofallViolationLevel *= 0.99D;
|
||||||
|
|
||||||
|
// Increase the fall distance that is recorded by the plugin
|
||||||
|
if(!toOnOrInGround && oldY > newY) {
|
||||||
|
data.fallDistance += (float) (oldY - newY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,7 @@ public class RunFlyCheck {
|
|||||||
private final FlyingCheck flyingCheck;
|
private final FlyingCheck flyingCheck;
|
||||||
private final RunningCheck runningCheck;
|
private final RunningCheck runningCheck;
|
||||||
private final NoclipCheck noclippingCheck;
|
private final NoclipCheck noclippingCheck;
|
||||||
|
private final NoFallCheck noFallCheck;
|
||||||
private final MorePacketsCheck morePacketsCheck;
|
private final MorePacketsCheck morePacketsCheck;
|
||||||
|
|
||||||
private final MovingEventHelper helper;
|
private final MovingEventHelper helper;
|
||||||
@ -31,7 +32,8 @@ public class RunFlyCheck {
|
|||||||
this.helper = new MovingEventHelper();
|
this.helper = new MovingEventHelper();
|
||||||
|
|
||||||
this.flyingCheck = new FlyingCheck(plugin);
|
this.flyingCheck = new FlyingCheck(plugin);
|
||||||
this.runningCheck = new RunningCheck(plugin);
|
this.noFallCheck = new NoFallCheck(plugin);
|
||||||
|
this.runningCheck = new RunningCheck(plugin, noFallCheck);
|
||||||
this.noclippingCheck = new NoclipCheck(plugin);
|
this.noclippingCheck = new NoclipCheck(plugin);
|
||||||
this.morePacketsCheck = new MorePacketsCheck(plugin);
|
this.morePacketsCheck = new MorePacketsCheck(plugin);
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,11 @@ public class RunningCheck {
|
|||||||
|
|
||||||
private final ActionExecutor action;
|
private final ActionExecutor action;
|
||||||
|
|
||||||
public RunningCheck(NoCheat plugin) {
|
private final NoFallCheck noFallCheck;
|
||||||
|
|
||||||
|
public RunningCheck(NoCheat plugin, NoFallCheck noFallCheck) {
|
||||||
this.action = new ActionExecutorWithHistory(plugin);
|
this.action = new ActionExecutorWithHistory(plugin);
|
||||||
|
this.noFallCheck = noFallCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location check(final Player player, final Location from, final Location to, final MovingEventHelper helper, final ConfigurationCache cc, final MovingData data) {
|
public Location check(final Player player, final Location from, final Location to, final MovingEventHelper helper, final ConfigurationCache cc, final MovingData data) {
|
||||||
@ -106,6 +109,13 @@ public class RunningCheck {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********* EXECUTE THE NOFALL CHECK ********************/
|
||||||
|
final boolean checkNoFall = cc.moving.nofallCheck && !player.hasPermission(Permissions.MOVE_NOFALL);
|
||||||
|
|
||||||
|
if(checkNoFall && newToLocation == null) {
|
||||||
|
noFallCheck.check(player, from, fromOnGround || fromInGround, to, toOnGround || toInGround, cc, data);
|
||||||
|
}
|
||||||
|
|
||||||
return newToLocation;
|
return newToLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +186,6 @@ public class RunningCheck {
|
|||||||
double distanceAboveLimit = 0.0D;
|
double distanceAboveLimit = 0.0D;
|
||||||
|
|
||||||
final double toY = to.getY();
|
final double toY = to.getY();
|
||||||
final double fromY = from.getY();
|
|
||||||
|
|
||||||
double limit = data.vertFreedom + cc.moving.jumpheight;
|
double limit = data.vertFreedom + cc.moving.jumpheight;
|
||||||
|
|
||||||
|
@ -31,6 +31,10 @@ public class CCMoving {
|
|||||||
public final boolean noclipCheck;
|
public final boolean noclipCheck;
|
||||||
public final ActionList noclipActions;
|
public final ActionList noclipActions;
|
||||||
|
|
||||||
|
public final boolean nofallCheck;
|
||||||
|
public final float nofallMultiplier;
|
||||||
|
public final ActionList nofallActions;
|
||||||
|
|
||||||
public final boolean morePacketsCheck;
|
public final boolean morePacketsCheck;
|
||||||
public final ActionList morePacketsActions;
|
public final ActionList morePacketsActions;
|
||||||
|
|
||||||
@ -54,6 +58,10 @@ public class CCMoving {
|
|||||||
flyingSpeedLimitHorizontal = ((double) data.getInteger("moving.runfly.flyingspeedlimithorizontal")) / 100D;
|
flyingSpeedLimitHorizontal = ((double) data.getInteger("moving.runfly.flyingspeedlimithorizontal")) / 100D;
|
||||||
flyingActions = data.getActionList("moving.runfly.flyingactions");
|
flyingActions = data.getActionList("moving.runfly.flyingactions");
|
||||||
|
|
||||||
|
nofallCheck = data.getBoolean("moving.runfly.checknofall");
|
||||||
|
nofallMultiplier = ((float) data.getInteger("moving.runfly.nofallmultiplier")) / 100F;
|
||||||
|
nofallActions = data.getActionList("moving.runfly.nofallactions");
|
||||||
|
|
||||||
noclipCheck = data.getBoolean("moving.noclip.check");
|
noclipCheck = data.getBoolean("moving.noclip.check");
|
||||||
noclipActions = data.getActionList("moving.noclip.actions");
|
noclipActions = data.getActionList("moving.noclip.actions");
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@ public class MovingData {
|
|||||||
public double horizFreedom = 0.0D;
|
public double horizFreedom = 0.0D;
|
||||||
public int horizVelocityCounter = 0;
|
public int horizVelocityCounter = 0;
|
||||||
|
|
||||||
|
public double nofallViolationLevel = 0.0D;
|
||||||
|
public float fallDistance = 0.0F;
|
||||||
|
|
||||||
public int noclipX;
|
public int noclipX;
|
||||||
public int noclipY;
|
public int noclipY;
|
||||||
public int noclipZ;
|
public int noclipZ;
|
||||||
|
@ -90,6 +90,7 @@ public class PlayerTeleportEventManager extends PlayerListener implements EventM
|
|||||||
data.morePacketsCounter = 0;
|
data.morePacketsCounter = 0;
|
||||||
data.morePacketsSetbackPoint = null;
|
data.morePacketsSetbackPoint = null;
|
||||||
data.jumpPhase = 0;
|
data.jumpPhase = 0;
|
||||||
|
data.fallDistance = 0F;
|
||||||
|
|
||||||
if(newLocation != null) {
|
if(newLocation != null) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user