mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-27 19:07:45 +01:00
Code cleanup and big performance improvement of "moving" check
This commit is contained in:
parent
ff2f9244a6
commit
e404a65b0f
@ -3,7 +3,7 @@ name: NoCheat
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||
version: 0.9.3
|
||||
version: 0.9.4
|
||||
|
||||
commands:
|
||||
nocheat:
|
||||
|
@ -44,7 +44,7 @@ public class NoCheat extends JavaPlugin {
|
||||
public ItemdupeCheck itemdupeCheck;
|
||||
public BogusitemsCheck bogusitemsCheck;
|
||||
|
||||
public Check[] checks;
|
||||
private Check[] checks;
|
||||
|
||||
private NoCheatConfiguration config;
|
||||
|
||||
|
@ -25,10 +25,10 @@ import cc.co.evenprime.bukkit.nocheat.actions.LogAction;
|
||||
public class NoCheatConfiguration {
|
||||
|
||||
|
||||
public final String configFile = "plugins/NoCheat/nocheat.yml";
|
||||
private final static String configFile = "plugins/NoCheat/nocheat.yml";
|
||||
|
||||
// Our personal logger
|
||||
private final String loggerName = "cc.co.evenprime.nocheat";
|
||||
private final static String loggerName = "cc.co.evenprime.nocheat";
|
||||
public final Logger logger = Logger.getLogger(loggerName);
|
||||
|
||||
// The log level above which information gets logged to the specified logger
|
||||
@ -182,15 +182,15 @@ public class NoCheatConfiguration {
|
||||
|
||||
private String actionsToString(Action[] actions) {
|
||||
|
||||
String s = "";
|
||||
StringBuffer s = new StringBuffer();
|
||||
|
||||
if(actions != null) {
|
||||
for(Action a : actions) {
|
||||
s = s + " " + a.getName();
|
||||
s.append(' ').append(a.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return s.trim();
|
||||
return s.toString().trim();
|
||||
}
|
||||
/**
|
||||
* Convert a string into a log level
|
||||
|
@ -22,7 +22,6 @@ import cc.co.evenprime.bukkit.nocheat.actions.CancelAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.CustomAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.LogAction;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.MovingData;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.MovingData.BlockType;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.PermissionData;
|
||||
import cc.co.evenprime.bukkit.nocheat.listeners.MovingEntityListener;
|
||||
import cc.co.evenprime.bukkit.nocheat.listeners.MovingPlayerListener;
|
||||
@ -41,20 +40,16 @@ public class MovingCheck extends Check {
|
||||
}
|
||||
|
||||
// How many move events can a player have in air before he is expected to lose altitude (or land somewhere)
|
||||
private final int jumpingLimit = 4;
|
||||
private final static int jumpingLimit = 4;
|
||||
|
||||
// How high may a player get compared to his last location with ground contact
|
||||
private final double jumpHeight = 1.3D;
|
||||
private final static double jumpHeight = 1.3D;
|
||||
|
||||
// How high may a player move in one event on ground
|
||||
private final double stepHeight = 0.501D;
|
||||
private final static double stepHeight = 0.501D;
|
||||
|
||||
private final double stepWidth = 0.6D;
|
||||
private final double sneakStepWidth = 0.25D;
|
||||
|
||||
// Limits
|
||||
public final double moveLimits[] = { 0.0D, 0.5D, 2.0D };
|
||||
public final double heightLimits[] = { 0.0D, 0.5D, 2.0D };
|
||||
private final static double stepWidth = 0.6D;
|
||||
private final static double sneakStepWidth = 0.25D;
|
||||
|
||||
public int ticksBeforeSummary = 100;
|
||||
|
||||
@ -92,7 +87,7 @@ public class MovingCheck extends Check {
|
||||
// Should we check at all
|
||||
if(skipCheck(player)) { return; }
|
||||
|
||||
long startTime = System.nanoTime();
|
||||
final long startTime = System.nanoTime();
|
||||
|
||||
// Get the player-specific data
|
||||
final MovingData data = MovingData.get(player);
|
||||
@ -101,6 +96,9 @@ public class MovingCheck extends Check {
|
||||
final Location to = event.getTo();
|
||||
Location from = event.getFrom();
|
||||
|
||||
shouldBeIgnored(player, data, from, to);
|
||||
|
||||
|
||||
// The use of event.getFrom() is intentional
|
||||
if(shouldBeIgnored(player, data, from, to)) {
|
||||
statisticElapsedTimeNano += System.nanoTime() - startTime;
|
||||
@ -114,11 +112,13 @@ public class MovingCheck extends Check {
|
||||
data.teleportTo = null;
|
||||
}
|
||||
|
||||
// First check the distance the player has moved horizontally
|
||||
final double xDistance = Math.abs(from.getX()-to.getX());
|
||||
final double zDistance = Math.abs(from.getZ()-to.getZ());
|
||||
|
||||
final double combined = Math.sqrt((xDistance*xDistance + zDistance*zDistance));
|
||||
// First check the distance the player has moved horizontally
|
||||
final double xDistance = from.getX()-to.getX();
|
||||
final double zDistance = from.getZ()-to.getZ();
|
||||
|
||||
double combined = Math.sqrt((xDistance*xDistance + zDistance*zDistance));
|
||||
|
||||
|
||||
// If the target is a bed and distance not too big, allow it
|
||||
// Bukkit prevents using blocks behind walls already, so I don't have to check for that
|
||||
@ -128,14 +128,8 @@ public class MovingCheck extends Check {
|
||||
return;
|
||||
}
|
||||
|
||||
// pre-calculate boundary values that are needed multiple times in the following checks
|
||||
// the array each contains [lowerX, higherX, Y, lowerZ, higherZ]
|
||||
final int fromValues[] = {lowerBorder(from.getX()), upperBorder(from.getX()), (int)Math.floor(from.getY()), lowerBorder(from.getZ()),upperBorder(from.getZ()) };
|
||||
final int toValues[] = {lowerBorder(to.getX()), upperBorder(to.getX()), (int)Math.floor(to.getY()+0.5D), lowerBorder(to.getZ()), upperBorder(to.getZ()) };
|
||||
|
||||
// compare locations to the world to guess if the player is standing on the ground, a half-block or next to a ladder
|
||||
final boolean onGroundFrom = playerIsOnGround(from.getWorld(), fromValues, from);
|
||||
final boolean onGroundTo = playerIsOnGround(to.getWorld(), toValues, to);
|
||||
final boolean onGroundFrom = playerIsOnGround(from, 0.0D);
|
||||
|
||||
final boolean canFly;
|
||||
if(allowFlying || plugin.hasPermission(player, PermissionData.PERMISSION_FLYING)) {
|
||||
@ -144,7 +138,7 @@ public class MovingCheck extends Check {
|
||||
}
|
||||
else
|
||||
canFly = false;
|
||||
|
||||
|
||||
final boolean canFakeSneak;
|
||||
if(allowFakeSneak || plugin.hasPermission(player, PermissionData.PERMISSION_FAKESNEAK)) {
|
||||
canFakeSneak = true;
|
||||
@ -157,7 +151,7 @@ public class MovingCheck extends Check {
|
||||
int violationLevelSneaking = -1;
|
||||
|
||||
if(!canFakeSneak && player.isSneaking()) {
|
||||
violationLevelSneaking = limitCheck(combined - (data.horizFreedom + sneakStepWidth), moveLimits);
|
||||
violationLevelSneaking = limitCheck(combined - (data.horizFreedom + sneakStepWidth));
|
||||
if(violationLevelSneaking >= 0) {
|
||||
if(combined >= data.sneakingLastDistance)
|
||||
data.sneakingFreedomCounter -= 2;
|
||||
@ -177,9 +171,7 @@ public class MovingCheck extends Check {
|
||||
data.sneakingFreedomCounter += 1;
|
||||
}
|
||||
|
||||
int violationLevelHorizontal = -1;
|
||||
|
||||
violationLevelHorizontal = limitCheck(combined - (data.horizFreedom + stepWidth), moveLimits);
|
||||
int violationLevelHorizontal = limitCheck(combined - (data.horizFreedom + stepWidth));
|
||||
|
||||
violationLevelHorizontal = violationLevelHorizontal > violationLevelSneaking ? violationLevelHorizontal : violationLevelSneaking;
|
||||
|
||||
@ -195,7 +187,7 @@ public class MovingCheck extends Check {
|
||||
// The location we'd use as a new setback if there are no violations
|
||||
Location newSetBack = null;
|
||||
|
||||
double limit = calculateVerticalLimit(data, onGroundFrom, onGroundTo);
|
||||
double limit = calculateVerticalLimit(data, onGroundFrom);
|
||||
|
||||
// Handle 4 distinct cases: Walk, Jump, Land, Fly
|
||||
|
||||
@ -203,25 +195,22 @@ public class MovingCheck extends Check {
|
||||
if(onGroundFrom)
|
||||
{
|
||||
limit += jumpHeight;
|
||||
double distance = to.getY() - from.getY();
|
||||
final double distance = to.getY() - from.getY();
|
||||
|
||||
violationLevelVertical = limitCheck(distance - limit, heightLimits);
|
||||
violationLevelVertical = limitCheck(distance - limit);
|
||||
|
||||
if(violationLevelVertical < 0)
|
||||
{
|
||||
{
|
||||
// reset jumping
|
||||
if(onGroundTo)
|
||||
data.jumpPhase = 0; // Walk
|
||||
else
|
||||
data.jumpPhase = 1; // Jump
|
||||
data.jumpPhase = 0;
|
||||
|
||||
newSetBack = from.clone();
|
||||
newSetBack = from;
|
||||
}
|
||||
}
|
||||
// Land or Fly/Fall
|
||||
else
|
||||
{
|
||||
Location l = null;
|
||||
final Location l;
|
||||
|
||||
if(data.setBackPoint == null || canFly)
|
||||
l = from;
|
||||
@ -232,23 +221,25 @@ public class MovingCheck extends Check {
|
||||
limit += jumpHeight - (data.jumpPhase-jumpingLimit) * 0.2D;
|
||||
else limit += jumpHeight;
|
||||
|
||||
final boolean onGroundTo = playerIsOnGround(to, 0.5D);
|
||||
|
||||
if(onGroundTo) limit += stepHeight;
|
||||
|
||||
double distance = to.getY() - l.getY();
|
||||
final double distance = to.getY() - l.getY();
|
||||
|
||||
// Check if player isn't jumping too high
|
||||
violationLevelVertical = limitCheck(distance - limit, heightLimits);
|
||||
violationLevelVertical = limitCheck(distance - limit);
|
||||
|
||||
if(violationLevelVertical < 0) {
|
||||
if(onGroundTo) { // Land
|
||||
data.jumpPhase = 0; // He is on ground now, so reset the jump
|
||||
newSetBack = to.clone();
|
||||
newSetBack = to;
|
||||
}
|
||||
else { // Fly
|
||||
data.jumpPhase++; // Enter next phase of the flight
|
||||
// If we have no setback point, create one now
|
||||
if(data.setBackPoint == null) {
|
||||
newSetBack = from.clone();
|
||||
newSetBack = from;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -265,7 +256,7 @@ public class MovingCheck extends Check {
|
||||
|
||||
// If we haven't already got a setback point by now, make this location the new setback point
|
||||
if(data.setBackPoint == null) {
|
||||
data.setBackPoint = from.clone();
|
||||
data.setBackPoint = from;
|
||||
}
|
||||
|
||||
if(violationLevel >= 0) {
|
||||
@ -283,7 +274,7 @@ public class MovingCheck extends Check {
|
||||
statisticTotalEvents++;
|
||||
}
|
||||
|
||||
private double calculateVerticalLimit(MovingData data, boolean onGroundFrom, boolean onGroundTo) {
|
||||
private double calculateVerticalLimit(final MovingData data, final boolean onGroundFrom) {
|
||||
|
||||
// A halfway lag-resistant method of allowing vertical acceleration without allowing blatant cheating
|
||||
|
||||
@ -308,10 +299,10 @@ public class MovingCheck extends Check {
|
||||
data.vertFreedomCounter--;
|
||||
}
|
||||
|
||||
double limit = data.vertFreedom;
|
||||
final double limit = data.vertFreedom;
|
||||
|
||||
// If the event counter has been consumed, remove the vertical movement limit increase when landing the next time
|
||||
if(data.vertFreedomCounter <= 0 && (onGroundFrom || onGroundTo)) {
|
||||
if(onGroundFrom && data.vertFreedomCounter <= 0) {
|
||||
data.vertFreedom = 0.0D;
|
||||
}
|
||||
|
||||
@ -326,12 +317,18 @@ public class MovingCheck extends Check {
|
||||
* @param to
|
||||
* @return
|
||||
*/
|
||||
private boolean shouldBeIgnored(Player player, MovingData data, Location from, Location to) {
|
||||
private boolean shouldBeIgnored(final Player player, final MovingData data, final Location from, final Location to) {
|
||||
|
||||
// Identical locations - just ignore the event
|
||||
if(from.equals(to))
|
||||
final double x = from.getX();
|
||||
final double y = from.getY();
|
||||
final double z = from.getZ();
|
||||
final Location l = data.lastLocation;
|
||||
|
||||
if(x == to.getX() && z == to.getZ() && y == to.getY() )
|
||||
return true;
|
||||
// Something or someone moved the player without causing a move event - Can't do much with that
|
||||
else if(!from.equals(data.lastLocation)) {
|
||||
if(!(x == l.getX() && z == l.getZ() && y == l.getY())){
|
||||
resetData(data, to);
|
||||
return true;
|
||||
}
|
||||
@ -486,14 +483,14 @@ public class MovingCheck extends Check {
|
||||
* @param limits
|
||||
* @return
|
||||
*/
|
||||
private int limitCheck(double value, double limits[]) {
|
||||
|
||||
for(int i = limits.length - 1; i >= 0; i--) {
|
||||
if(value > limits[i]) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
private static int limitCheck(final double value) {
|
||||
|
||||
if(value > 0.0D) {
|
||||
if(value > 0.5D) {
|
||||
if(value > 2.0D)
|
||||
return 2;
|
||||
return 1; }
|
||||
return 0; }
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -512,7 +509,7 @@ public class MovingCheck extends Check {
|
||||
// still have to allow the player some freedom with vertical movement due
|
||||
// to lost vertical momentum to prevent him from getting stuck
|
||||
|
||||
if(data.setBackPoint == null) data.setBackPoint = from.clone();
|
||||
if(data.setBackPoint == null) data.setBackPoint = from;
|
||||
|
||||
// Set a flag that gets used while handling teleport events (to determine if
|
||||
// it was my teleport or someone else'
|
||||
@ -544,61 +541,72 @@ public class MovingCheck extends Check {
|
||||
* @param l The precise location that was used for calculation of "values"
|
||||
* @return
|
||||
*/
|
||||
private static boolean playerIsOnGround(World w, int values[], Location l) {
|
||||
private static boolean playerIsOnGround(final Location l, final double ymod) {
|
||||
|
||||
final int types[] = MovingData.types;
|
||||
|
||||
final World w = l.getWorld();
|
||||
|
||||
final int lowerX = lowerBorder(l.getX());
|
||||
final int upperX = upperBorder(l.getX());
|
||||
final int Y = (int)Math.floor(l.getY() + ymod);
|
||||
final int lowerZ = lowerBorder(l.getZ());
|
||||
final int higherZ = upperBorder(l.getZ());
|
||||
|
||||
BlockType types[] = MovingData.types;
|
||||
|
||||
// Check the four borders of the players hitbox for something he could be standing on
|
||||
if(types[w.getBlockTypeIdAt(values[0], values[2]-1, values[3])] != BlockType.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(values[1], values[2]-1, values[3])] != BlockType.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(values[0], values[2]-1, values[4])] != BlockType.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(values[1], values[2]-1, values[4])] != BlockType.NONSOLID )
|
||||
if(types[w.getBlockTypeIdAt(lowerX, Y-1, lowerZ)] != MovingData.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(upperX, Y-1, lowerZ)] != MovingData.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(lowerX, Y-1, higherZ)] != MovingData.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(upperX, Y-1, higherZ)] != MovingData.NONSOLID )
|
||||
return true;
|
||||
// Check if he is hanging onto a ladder
|
||||
else if(types[w.getBlockTypeIdAt(l.getBlockX(), values[2], l.getBlockZ())] == BlockType.LADDER ||
|
||||
types[w.getBlockTypeIdAt(l.getBlockX(), values[2]+1, l.getBlockZ())] == BlockType.LADDER)
|
||||
else if(types[w.getBlockTypeIdAt(l.getBlockX(), Y, l.getBlockZ())] == MovingData.LADDER ||
|
||||
types[w.getBlockTypeIdAt(l.getBlockX(), Y+1, l.getBlockZ())] == MovingData.LADDER)
|
||||
return true;
|
||||
// check if he is standing "in" a block that's potentially solid (we give him the benefit of a doubt and see that as a legit move)
|
||||
// If it is not legit, the MC server already has a safeguard against that (You'll get "xy moved wrongly" on the console in that case)
|
||||
else if(types[w.getBlockTypeIdAt(values[0], values[2], values[3])] != BlockType.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(values[1], values[2], values[3])] != BlockType.NONSOLID||
|
||||
types[w.getBlockTypeIdAt(values[0], values[2], values[4])] != BlockType.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(values[1], values[2], values[4])] != BlockType.NONSOLID)
|
||||
else if(types[w.getBlockTypeIdAt(lowerX, Y, lowerZ)] != MovingData.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(upperX, Y, lowerZ)] != MovingData.NONSOLID||
|
||||
types[w.getBlockTypeIdAt(lowerX, Y, higherZ)] != MovingData.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(upperX, Y, higherZ)] != MovingData.NONSOLID)
|
||||
return true;
|
||||
// check if his head is "stuck" in an block that's potentially solid (we give him the benefit of a doubt and see that as a legit move)
|
||||
// If it is not legit, the MC server already has a safeguard against that (You'll get "xy moved wrongly" on the console in that case)
|
||||
else if(types[w.getBlockTypeIdAt(values[0], values[2]+1, values[3])] != BlockType.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(values[1], values[2]+1, values[3])] != BlockType.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(values[0], values[2]+1, values[4])] != BlockType.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(values[1], values[2]+1, values[4])] != BlockType.NONSOLID)
|
||||
else if(types[w.getBlockTypeIdAt(lowerX, Y+1, lowerZ)] != MovingData.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(upperX, Y+1, lowerZ)] != MovingData.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(lowerX, Y+1, higherZ)] != MovingData.NONSOLID ||
|
||||
types[w.getBlockTypeIdAt(upperX, Y+1, higherZ)] != MovingData.NONSOLID)
|
||||
return true;
|
||||
// Allow using a bug called "water elevator" by checking northwest of the players location for liquids
|
||||
else if(types[w.getBlockTypeIdAt(values[0]+1, values[2]-1, values[3]+1)] == BlockType.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(values[0]+1, values[2], values[3]+1)] == BlockType.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(values[0]+1, values[2]+1, values[3]+1)] == BlockType.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(values[0]+1, values[2]-1, values[3])] == BlockType.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(values[0]+1, values[2], values[3])] == BlockType.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(values[0]+1, values[2]+1, values[3])] == BlockType.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(values[0], values[2]-1, values[3]+1)] == BlockType.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(values[0], values[2], values[3]+1)] == BlockType.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(values[0], values[2]+1, values[3]+1)] == BlockType.LIQUID)
|
||||
else if(types[w.getBlockTypeIdAt(lowerX+1, Y-1, lowerZ+1)] == MovingData.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(lowerX+1, Y, lowerZ+1)] == MovingData.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(lowerX+1, Y+1, lowerZ+1)] == MovingData.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(lowerX+1, Y-1, lowerZ)] == MovingData.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(lowerX+1, Y, lowerZ)] == MovingData.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(lowerX+1, Y+1, lowerZ)] == MovingData.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(lowerX, Y-1, lowerZ+1)] == MovingData.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(lowerX, Y, lowerZ+1)] == MovingData.LIQUID ||
|
||||
types[w.getBlockTypeIdAt(lowerX, Y+1, lowerZ+1)] == MovingData.LIQUID)
|
||||
return true;
|
||||
// Running on fences
|
||||
else if(types[w.getBlockTypeIdAt(values[0], values[2]-2, values[3])] == BlockType.FENCE ||
|
||||
types[w.getBlockTypeIdAt(values[1], values[2]-2, values[3])] == BlockType.FENCE ||
|
||||
types[w.getBlockTypeIdAt(values[0], values[2]-2, values[4])] == BlockType.FENCE ||
|
||||
types[w.getBlockTypeIdAt(values[1], values[2]-2, values[4])] == BlockType.FENCE )
|
||||
else if(types[w.getBlockTypeIdAt(lowerX, Y-2, lowerZ)] == MovingData.FENCE ||
|
||||
types[w.getBlockTypeIdAt(upperX, Y-2, lowerZ)] == MovingData.FENCE ||
|
||||
types[w.getBlockTypeIdAt(lowerX, Y-2, higherZ)] == MovingData.FENCE ||
|
||||
types[w.getBlockTypeIdAt(upperX, Y-2, higherZ)] == MovingData.FENCE )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Personal Rounding function to determine if a player is still touching a block or not
|
||||
* @param d1
|
||||
* @return
|
||||
*/
|
||||
private static int lowerBorder(double d1) {
|
||||
|
||||
double floor = Math.floor(d1);
|
||||
double d4 = floor + magic;
|
||||
|
||||
@ -616,6 +624,7 @@ public class MovingCheck extends Check {
|
||||
* @return
|
||||
*/
|
||||
private static int upperBorder(double d1) {
|
||||
|
||||
double floor = Math.floor(d1);
|
||||
double d4 = floor + magic2;
|
||||
|
||||
|
@ -70,12 +70,12 @@ public class SpeedhackCheck extends Check {
|
||||
|
||||
// If we haven't already got a setback point, create one now
|
||||
if(data.setBackPoint == null) {
|
||||
data.setBackPoint = event.getFrom().clone();
|
||||
data.setBackPoint = event.getFrom();
|
||||
}
|
||||
|
||||
if(plugin.getServerLag() > 200) {
|
||||
// Any data would likely be unreliable with that lag
|
||||
resetData(data, event.getFrom().clone(), ticks);
|
||||
resetData(data, event.getFrom(), ticks);
|
||||
}
|
||||
else {
|
||||
Action action[] = null;
|
||||
@ -87,7 +87,7 @@ public class SpeedhackCheck extends Check {
|
||||
if(data.eventsSinceLastCheck > high) action = actions[2];
|
||||
else if(data.eventsSinceLastCheck > med) action = actions[1];
|
||||
else if(data.eventsSinceLastCheck > low) action = actions[0];
|
||||
else resetData(data, event.getFrom().clone(), ticks);
|
||||
else resetData(data, event.getFrom(), ticks);
|
||||
|
||||
|
||||
if(action != null) data.violationsInARow++;
|
||||
@ -105,7 +105,7 @@ public class SpeedhackCheck extends Check {
|
||||
else if(data.lastCheckTicks + 10 < ticks)
|
||||
{
|
||||
// The player didn't move for the last 10 ticks
|
||||
resetData(data, event.getFrom().clone(), ticks);
|
||||
resetData(data, event.getFrom(), ticks);
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ public class SpeedhackCheck extends Check {
|
||||
|
||||
private static void resetPlayer(PlayerMoveEvent event, SpeedhackData data) {
|
||||
|
||||
if(data.setBackPoint == null) data.setBackPoint = event.getFrom().clone();
|
||||
if(data.setBackPoint == null) data.setBackPoint = event.getFrom();
|
||||
|
||||
// If we have stored a location for the player, we put him back there
|
||||
|
||||
|
@ -12,7 +12,6 @@ public class MovingData {
|
||||
public int jumpPhase = 0;
|
||||
public int violationsInARow[] = { 0, 0, 0 };
|
||||
public double horizFreedom = 0.0D;
|
||||
public int horizFreedomCounter = 0;
|
||||
public double vertFreedom = 0.0D;
|
||||
public int vertFreedomCounter = 0;
|
||||
public Location setBackPoint = null;
|
||||
@ -32,109 +31,115 @@ public class MovingData {
|
||||
public Location teleportInitializedByMe = null;
|
||||
|
||||
// Block types that may be treated specially
|
||||
public enum BlockType {
|
||||
SOLID, NONSOLID, LADDER, LIQUID, UNKNOWN, FENCE;
|
||||
}
|
||||
public static final int SOLID = 0;
|
||||
public static final int NONSOLID = 1;
|
||||
public static final int LADDER = 2;
|
||||
public static final int LIQUID = 3;
|
||||
public static final int UNKNOWN = 4;
|
||||
public static final int FENCE = 5;
|
||||
|
||||
|
||||
// Until I can think of a better way to determine if a block is solid or not, this is what I'll do
|
||||
public static BlockType types[] = new BlockType[256];
|
||||
public static final int types[] = new int[256];
|
||||
|
||||
static {
|
||||
|
||||
for(int i = 0; i < types.length; i++) {
|
||||
types[i] = BlockType.UNKNOWN;
|
||||
types[i] = UNKNOWN;
|
||||
}
|
||||
|
||||
types[Material.AIR.getId()] = BlockType.NONSOLID;
|
||||
types[Material.STONE.getId()] = BlockType.SOLID;
|
||||
types[Material.GRASS.getId()] = BlockType.SOLID;
|
||||
types[Material.DIRT.getId()] = BlockType.SOLID;
|
||||
types[Material.COBBLESTONE.getId()] = BlockType.SOLID;
|
||||
types[Material.WOOD.getId()] = BlockType.SOLID;
|
||||
types[Material.SAPLING.getId()] = BlockType.NONSOLID;
|
||||
types[Material.BEDROCK.getId()] = BlockType.SOLID;
|
||||
types[Material.WATER.getId()] = BlockType.LIQUID;
|
||||
types[Material.STATIONARY_WATER.getId()] = BlockType.LIQUID;
|
||||
types[Material.LAVA.getId()] = BlockType.LIQUID;
|
||||
types[Material.STATIONARY_LAVA.getId()] = BlockType.LIQUID;
|
||||
types[Material.SAND.getId()] = BlockType.SOLID;
|
||||
types[Material.GRAVEL.getId()] = BlockType.SOLID;
|
||||
types[Material.GOLD_ORE.getId()] = BlockType.SOLID;
|
||||
types[Material.IRON_ORE.getId()] = BlockType.SOLID;
|
||||
types[Material.COAL_ORE.getId()] = BlockType.SOLID;
|
||||
types[Material.LOG.getId()] = BlockType.SOLID;
|
||||
types[Material.LEAVES.getId()] = BlockType.SOLID;
|
||||
types[Material.SPONGE.getId()] = BlockType.SOLID;
|
||||
types[Material.GLASS.getId()] = BlockType.SOLID;
|
||||
types[Material.LAPIS_ORE.getId()] = BlockType.SOLID;
|
||||
types[Material.LAPIS_BLOCK.getId()] = BlockType.SOLID;
|
||||
types[Material.DISPENSER.getId()] = BlockType.SOLID;
|
||||
types[Material.SANDSTONE.getId()] = BlockType.SOLID;
|
||||
types[Material.NOTE_BLOCK.getId()]= BlockType.SOLID;
|
||||
types[Material.WOOL.getId()]= BlockType.SOLID;
|
||||
types[Material.YELLOW_FLOWER.getId()]= BlockType.NONSOLID;
|
||||
types[Material.RED_ROSE.getId()]= BlockType.NONSOLID;
|
||||
types[Material.BROWN_MUSHROOM.getId()]= BlockType.NONSOLID;
|
||||
types[Material.RED_MUSHROOM.getId()]= BlockType.NONSOLID;
|
||||
types[Material.GOLD_BLOCK.getId()]= BlockType.SOLID;
|
||||
types[Material.IRON_BLOCK.getId()]= BlockType.SOLID;
|
||||
types[Material.DOUBLE_STEP.getId()]= BlockType.UNKNOWN;
|
||||
types[Material.STEP.getId()]= BlockType.UNKNOWN;
|
||||
types[Material.BRICK.getId()]= BlockType.SOLID;
|
||||
types[Material.TNT.getId()]= BlockType.SOLID;
|
||||
types[Material.BOOKSHELF.getId()]= BlockType.SOLID;
|
||||
types[Material.MOSSY_COBBLESTONE.getId()] = BlockType.SOLID;
|
||||
types[Material.OBSIDIAN.getId()]= BlockType.SOLID;
|
||||
types[Material.TORCH.getId()]= BlockType.NONSOLID;
|
||||
types[Material.FIRE.getId()]= BlockType.NONSOLID;
|
||||
types[Material.MOB_SPAWNER.getId()]= BlockType.SOLID;
|
||||
types[Material.WOOD_STAIRS.getId()]= BlockType.UNKNOWN;
|
||||
types[Material.CHEST.getId()]= BlockType.SOLID;
|
||||
types[Material.REDSTONE_WIRE.getId()]= BlockType.NONSOLID;
|
||||
types[Material.DIAMOND_ORE.getId()]= BlockType.SOLID;
|
||||
types[Material.DIAMOND_BLOCK.getId()]= BlockType.SOLID;
|
||||
types[Material.WORKBENCH.getId()]= BlockType.SOLID;
|
||||
types[Material.CROPS.getId()]= BlockType.NONSOLID;
|
||||
types[Material.SOIL.getId()]= BlockType.SOLID;
|
||||
types[Material.FURNACE.getId()]= BlockType.SOLID;
|
||||
types[Material.BURNING_FURNACE.getId()]= BlockType.SOLID;
|
||||
types[Material.SIGN_POST.getId()]= BlockType.NONSOLID;
|
||||
types[Material.WOODEN_DOOR.getId()]= BlockType.NONSOLID;
|
||||
types[Material.LADDER.getId()]= BlockType.LADDER;
|
||||
types[Material.RAILS.getId()]= BlockType.NONSOLID;
|
||||
types[Material.COBBLESTONE_STAIRS.getId()]= BlockType.UNKNOWN;
|
||||
types[Material.WALL_SIGN.getId()]= BlockType.NONSOLID;
|
||||
types[Material.LEVER.getId()]= BlockType.NONSOLID;
|
||||
types[Material.STONE_PLATE.getId()]= BlockType.UNKNOWN;
|
||||
types[Material.IRON_DOOR_BLOCK.getId()]= BlockType.NONSOLID;
|
||||
types[Material.WOOD_PLATE.getId()]= BlockType.NONSOLID;
|
||||
types[Material.REDSTONE_ORE.getId()]= BlockType.SOLID;
|
||||
types[Material.GLOWING_REDSTONE_ORE.getId()]= BlockType.SOLID;
|
||||
types[Material.REDSTONE_TORCH_OFF.getId()]= BlockType.NONSOLID;
|
||||
types[Material.REDSTONE_TORCH_ON.getId()]= BlockType.NONSOLID;
|
||||
types[Material.STONE_BUTTON.getId()]= BlockType.NONSOLID;
|
||||
types[Material.SNOW.getId()]= BlockType.UNKNOWN;
|
||||
types[Material.ICE.getId()]= BlockType.UNKNOWN;
|
||||
types[Material.SNOW_BLOCK.getId()]= BlockType.SOLID;
|
||||
types[Material.CACTUS.getId()]= BlockType.SOLID;
|
||||
types[Material.CLAY.getId()]= BlockType.SOLID;
|
||||
types[Material.SUGAR_CANE_BLOCK.getId()]= BlockType.NONSOLID;
|
||||
types[Material.JUKEBOX.getId()]= BlockType.SOLID;
|
||||
types[Material.FENCE.getId()]= BlockType.FENCE;
|
||||
types[Material.PUMPKIN.getId()]= BlockType.SOLID;
|
||||
types[Material.NETHERRACK.getId()]= BlockType.SOLID;
|
||||
types[Material.SOUL_SAND.getId()]= BlockType.UNKNOWN;
|
||||
types[Material.GLOWSTONE.getId()]= BlockType.SOLID;
|
||||
types[Material.PORTAL.getId()]= BlockType.NONSOLID;
|
||||
types[Material.JACK_O_LANTERN.getId()]= BlockType.SOLID;
|
||||
types[Material.CAKE_BLOCK.getId()]= BlockType.UNKNOWN;
|
||||
types[Material.AIR.getId()] = NONSOLID;
|
||||
types[Material.STONE.getId()] = SOLID;
|
||||
types[Material.GRASS.getId()] = SOLID;
|
||||
types[Material.DIRT.getId()] = SOLID;
|
||||
types[Material.COBBLESTONE.getId()] = SOLID;
|
||||
types[Material.WOOD.getId()] = SOLID;
|
||||
types[Material.SAPLING.getId()] = NONSOLID;
|
||||
types[Material.BEDROCK.getId()] = SOLID;
|
||||
types[Material.WATER.getId()] = LIQUID;
|
||||
types[Material.STATIONARY_WATER.getId()] = LIQUID;
|
||||
types[Material.LAVA.getId()] = LIQUID;
|
||||
types[Material.STATIONARY_LAVA.getId()] = LIQUID;
|
||||
types[Material.SAND.getId()] = SOLID;
|
||||
types[Material.GRAVEL.getId()] = SOLID;
|
||||
types[Material.GOLD_ORE.getId()] = SOLID;
|
||||
types[Material.IRON_ORE.getId()] = SOLID;
|
||||
types[Material.COAL_ORE.getId()] = SOLID;
|
||||
types[Material.LOG.getId()] = SOLID;
|
||||
types[Material.LEAVES.getId()] = SOLID;
|
||||
types[Material.SPONGE.getId()] = SOLID;
|
||||
types[Material.GLASS.getId()] = SOLID;
|
||||
types[Material.LAPIS_ORE.getId()] = SOLID;
|
||||
types[Material.LAPIS_BLOCK.getId()] = SOLID;
|
||||
types[Material.DISPENSER.getId()] = SOLID;
|
||||
types[Material.SANDSTONE.getId()] = SOLID;
|
||||
types[Material.NOTE_BLOCK.getId()]= SOLID;
|
||||
types[Material.WOOL.getId()]= SOLID;
|
||||
types[Material.YELLOW_FLOWER.getId()]= NONSOLID;
|
||||
types[Material.RED_ROSE.getId()]= NONSOLID;
|
||||
types[Material.BROWN_MUSHROOM.getId()]= NONSOLID;
|
||||
types[Material.RED_MUSHROOM.getId()]= NONSOLID;
|
||||
types[Material.GOLD_BLOCK.getId()]= SOLID;
|
||||
types[Material.IRON_BLOCK.getId()]= SOLID;
|
||||
types[Material.DOUBLE_STEP.getId()]= UNKNOWN;
|
||||
types[Material.STEP.getId()]= UNKNOWN;
|
||||
types[Material.BRICK.getId()]= SOLID;
|
||||
types[Material.TNT.getId()]= SOLID;
|
||||
types[Material.BOOKSHELF.getId()]= SOLID;
|
||||
types[Material.MOSSY_COBBLESTONE.getId()] = SOLID;
|
||||
types[Material.OBSIDIAN.getId()]= SOLID;
|
||||
types[Material.TORCH.getId()]= NONSOLID;
|
||||
types[Material.FIRE.getId()]= NONSOLID;
|
||||
types[Material.MOB_SPAWNER.getId()]= SOLID;
|
||||
types[Material.WOOD_STAIRS.getId()]= UNKNOWN;
|
||||
types[Material.CHEST.getId()]= SOLID;
|
||||
types[Material.REDSTONE_WIRE.getId()]= NONSOLID;
|
||||
types[Material.DIAMOND_ORE.getId()]= SOLID;
|
||||
types[Material.DIAMOND_BLOCK.getId()]= SOLID;
|
||||
types[Material.WORKBENCH.getId()]= SOLID;
|
||||
types[Material.CROPS.getId()]= NONSOLID;
|
||||
types[Material.SOIL.getId()]= SOLID;
|
||||
types[Material.FURNACE.getId()]= SOLID;
|
||||
types[Material.BURNING_FURNACE.getId()]= SOLID;
|
||||
types[Material.SIGN_POST.getId()]= NONSOLID;
|
||||
types[Material.WOODEN_DOOR.getId()]= NONSOLID;
|
||||
types[Material.LADDER.getId()]= LADDER;
|
||||
types[Material.RAILS.getId()]= NONSOLID;
|
||||
types[Material.COBBLESTONE_STAIRS.getId()]= UNKNOWN;
|
||||
types[Material.WALL_SIGN.getId()]= NONSOLID;
|
||||
types[Material.LEVER.getId()]= NONSOLID;
|
||||
types[Material.STONE_PLATE.getId()]= UNKNOWN;
|
||||
types[Material.IRON_DOOR_BLOCK.getId()]= NONSOLID;
|
||||
types[Material.WOOD_PLATE.getId()]= NONSOLID;
|
||||
types[Material.REDSTONE_ORE.getId()]= SOLID;
|
||||
types[Material.GLOWING_REDSTONE_ORE.getId()]= SOLID;
|
||||
types[Material.REDSTONE_TORCH_OFF.getId()]= NONSOLID;
|
||||
types[Material.REDSTONE_TORCH_ON.getId()]= NONSOLID;
|
||||
types[Material.STONE_BUTTON.getId()]= NONSOLID;
|
||||
types[Material.SNOW.getId()]= UNKNOWN;
|
||||
types[Material.ICE.getId()]= UNKNOWN;
|
||||
types[Material.SNOW_BLOCK.getId()]= SOLID;
|
||||
types[Material.CACTUS.getId()]= SOLID;
|
||||
types[Material.CLAY.getId()]= SOLID;
|
||||
types[Material.SUGAR_CANE_BLOCK.getId()]= NONSOLID;
|
||||
types[Material.JUKEBOX.getId()]= SOLID;
|
||||
types[Material.FENCE.getId()]= FENCE;
|
||||
types[Material.PUMPKIN.getId()]= SOLID;
|
||||
types[Material.NETHERRACK.getId()]= SOLID;
|
||||
types[Material.SOUL_SAND.getId()]= UNKNOWN;
|
||||
types[Material.GLOWSTONE.getId()]= SOLID;
|
||||
types[Material.PORTAL.getId()]= NONSOLID;
|
||||
types[Material.JACK_O_LANTERN.getId()]= SOLID;
|
||||
types[Material.CAKE_BLOCK.getId()]= UNKNOWN;
|
||||
}
|
||||
|
||||
public static MovingData get(Player p) {
|
||||
public static MovingData get(final Player p) {
|
||||
|
||||
NoCheatData data = NoCheatData.getPlayerData(p);
|
||||
final NoCheatData data = NoCheatData.getPlayerData(p);
|
||||
|
||||
if(data.moving == null) {
|
||||
data.moving = new MovingData();
|
||||
data.moving.lastLocation = p.getLocation();
|
||||
}
|
||||
|
||||
return data.moving;
|
||||
|
@ -9,7 +9,7 @@ import cc.co.evenprime.bukkit.nocheat.checks.BogusitemsCheck;
|
||||
|
||||
public class BogusitemsPlayerListener extends PlayerListener {
|
||||
|
||||
BogusitemsCheck check;
|
||||
private BogusitemsCheck check;
|
||||
|
||||
public BogusitemsPlayerListener(BogusitemsCheck bogusitemsCheck) {
|
||||
check = bogusitemsCheck;
|
||||
|
@ -7,7 +7,7 @@ import cc.co.evenprime.bukkit.nocheat.checks.ItemdupeCheck;
|
||||
|
||||
public class ItemdupeEntityListener extends EntityListener {
|
||||
|
||||
ItemdupeCheck check;
|
||||
private ItemdupeCheck check;
|
||||
|
||||
public ItemdupeEntityListener(ItemdupeCheck itemdupeCheck) {
|
||||
check = itemdupeCheck;
|
||||
|
Loading…
Reference in New Issue
Block a user