Potential bugfix for false positives while landing during move event +

Moving check now (somewhat) respects vertical velocity of the player.
This commit is contained in:
Evenprime 2011-03-21 18:28:49 +01:00
parent 49f8b6cb5e
commit 6a6cb9e247
2 changed files with 15 additions and 11 deletions

View File

@ -3,7 +3,7 @@ name: NoCheatPlugin
author: Evenprime author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheatPlugin main: cc.co.evenprime.bukkit.nocheat.NoCheatPlugin
version: 0.7.3a version: 0.7.4
commands: commands:
nocheat: nocheat:

View File

@ -20,13 +20,16 @@ import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
*/ */
public class MovingCheck { public class MovingCheck {
// previously-calculated upper bound values for jumps. Minecraft is very deterministic when it comes to jumps // How many move events can a player have in air before he is expected to lose altitude (or land somewhere)
// Each entry represents the maximum gain in height per move event. static final int jumpingLimit = 3;
static final int jumpingLimit = 1;
// How high may a player get compared to his last location with ground contact
static final double jumpingHeightLimit = 1.3D; static final double jumpingHeightLimit = 1.3D;
// How high may a player move in one event on ground
static double stepHeight = 0.501D; static double stepHeight = 0.501D;
// Limits for the moving check // Limits for the horizontal moving check
public static double movingDistanceLow = 0.1D; public static double movingDistanceLow = 0.1D;
public static double movingDistanceMed = 2.0D; public static double movingDistanceMed = 2.0D;
public static double movingDistanceHigh = 5.0D; public static double movingDistanceHigh = 5.0D;
@ -140,7 +143,7 @@ public class MovingCheck {
// Get the player-specific data // Get the player-specific data
NoCheatData data = NoCheatPlugin.getPlayerData(event.getPlayer()); NoCheatData data = NoCheatPlugin.getPlayerData(event.getPlayer());
// Notice to myself: How world changes with e.g. command /world work: // Notice to myself: How world changes with e.g. command /world work:
// 1. TeleportEvent from the players current position to another position in the _same_ world // 1. TeleportEvent from the players current position to another position in the _same_ world
// 2. MoveEvent(s) (yes, multiple events can be triggered) from that position in the _new_ world // 2. MoveEvent(s) (yes, multiple events can be triggered) from that position in the _new_ world
@ -152,7 +155,7 @@ public class MovingCheck {
// Fun fact: Move event locations always have the same world in from/to, therefore // Fun fact: Move event locations always have the same world in from/to, therefore
// it doesn't matter which one I use // it doesn't matter which one I use
if(data.movingLastWorld != event.getFrom().getWorld()) { if(data.movingLastWorld != event.getFrom().getWorld()) {
data.movingLastWorld = event.getFrom().getWorld(); data.movingLastWorld = event.getFrom().getWorld();
// "Forget" previous setback points // "Forget" previous setback points
data.movingSetBackPoint = null; data.movingSetBackPoint = null;
@ -181,13 +184,15 @@ public class MovingCheck {
data.speedhackSetBackPoint = null; data.speedhackSetBackPoint = null;
return; return;
} }
// The server believes the player should be moved upward, so we ignore this // The server believes the player should be moving up, so we ignore this event
if(event.getPlayer().getVelocity().getY() > 0) { if(event.getPlayer().getVelocity().getY() > 0) {
data.movingSetBackPoint = null; data.movingSetBackPoint = null;
data.speedhackSetBackPoint = null; data.speedhackSetBackPoint = null;
return; return;
} }
// The actual movingCheck starts here // The actual movingCheck starts here
// Get the two locations of the event // Get the two locations of the event
@ -283,7 +288,7 @@ public class MovingCheck {
Location l = data.movingSetBackPoint; Location l = data.movingSetBackPoint;
if(l == null) { l = from; } if(l == null) { l = from; }
double limit = jumpingHeightLimit; double limit = jumpingHeightLimit + stepHeight;
if(to.getY() - l.getY() > limit) { if(to.getY() - l.getY() > limit) {
@ -300,7 +305,6 @@ public class MovingCheck {
} }
// Player is moving through air (during jumping, falling) // Player is moving through air (during jumping, falling)
else { else {
// Check if player isn't landing to high (sounds weird, but has its use)
Location l = data.movingSetBackPoint; Location l = data.movingSetBackPoint;
if(l == null) { l = from; } if(l == null) { l = from; }