Fixed sleeping + fixed hidden water ladders + version bump

Players going to sleep can now stand further away from the
bed without triggering a violation.
Quick fix for hidden water ladders.
This commit is contained in:
Evenprime 2011-03-03 20:14:09 +01:00
parent ac44b17c31
commit 8c11e72095
3 changed files with 17 additions and 12 deletions

View File

@ -3,5 +3,5 @@ name: NoCheatPlugin
author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheatPlugin
version: 0.6.1
version: 0.6.2

View File

@ -37,7 +37,7 @@ public class DupebydeathCheck {
for(int i = 0; i < playerInventory.getSize(); i++) {
if(playerInventory.getItem(i).equals(drop)) {
playerInventory.clear(i);
i = playerInventory.getSize();
break;
}
}
}

View File

@ -142,15 +142,20 @@ public class MovingCheck {
Location from = event.getFrom();
Location to = event.getTo();
Level vl = null; // The violation level (none, minor, normal, heavy)
// First check the distance the player has moved horizontally
// TODO: Make this check much more precise
double xDistance = Math.abs(from.getX() - to.getX());
double zDistance = Math.abs(from.getZ() - to.getZ());
double combined = xDistance * xDistance + zDistance * zDistance;
// How far are we off?
// If the target is a bed and distance not too big, allow it
if(to.getWorld().getBlockTypeIdAt(to) == Material.BED_BLOCK.getId() && xDistance < 5.0D && zDistance < 5.0D) {
return; // players are allowed to "teleport" into a bed over short distances
}
Level vl = null; // The violation level (none, minor, normal, heavy)
// How far are we off?
if(combined > movingDistanceHigh) {
vl = max(vl, Level.SEVERE);
}
@ -161,12 +166,6 @@ public class MovingCheck {
vl = max(vl, Level.INFO);
}
// If the target is a bed, allow it
if(to.getWorld().getBlockTypeIdAt(to) == Material.BED_BLOCK.getId() && (vl == null || vl.intValue() < Level.SEVERE.intValue())) {
return; // players are allowed to "teleport" into a bed over short distances
}
// pre-calculate boundary values that are needed multiple times in the following checks
// the array each contains [lowerX, higherX, Y, lowerZ, higherZ]
int fromValues[] = {floor_double(from.getX() - 0.3D), (int)Math.floor(from.getX() + 0.3D), from.getBlockY(), floor_double(from.getZ() - 0.3D),(int)Math.floor(from.getZ() + 0.3D) };
@ -433,10 +432,16 @@ public class MovingCheck {
types[w.getBlockTypeIdAt(values[0], values[2]+1, values[4])] != BlockType.NONSOLID ||
types[w.getBlockTypeIdAt(values[1], values[2]+1, values[4])] != BlockType.NONSOLID)
return true;
// Allow using a bug called "water elevator"
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)
return true;
else
return false;
}
public static int floor_double(double d)
{
int i = (int)d;