Preparations for new Bukkit version

This commit is contained in:
Evenprime 2011-03-29 13:32:05 +02:00
parent 3e92d0b9a2
commit 8b8e5c2267
7 changed files with 23 additions and 22 deletions

View File

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

View File

@ -38,7 +38,7 @@ public class NoCheatConfiguration {
this.plugin = plugin;
this.config(configurationFile);
config(configurationFile);
}
/**

View File

@ -157,7 +157,7 @@ public class NoCheatPlugin extends JavaPlugin {
pm.registerEvent(Event.Type.PLAYER_MOVE, new SpeedhackListener(speedhackCheck), Priority.High, this);
// Register listeners for airbuild check
pm.registerEvent(Event.Type.BLOCK_PLACED, new AirbuildListener(airbuildCheck), Priority.Low, this);
pm.registerEvent(Event.Type.BLOCK_PLACE, new AirbuildListener(airbuildCheck), Priority.Low, this);
// Register listeners for bedteleport check
pm.registerEvent(Event.Type.PLAYER_TELEPORT, new BedteleportListener(bedteleportCheck), Priority.Lowest, this);

View File

@ -32,7 +32,7 @@ public class MovingCheck extends Check {
private double stepHeight = 0.501D;
// Limits
public final double moveLimits[] = { 0.1D, 2.0D, 5.0D };
public final double moveLimits[] = { 0.0D, 0.5D, 2.0D };
public final double heightLimits[] = { 0.0D, 0.5D, 2.0D };
@ -201,13 +201,14 @@ public class MovingCheck extends Check {
// 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;
double xDistance = from.getX()-to.getX();
double zDistance = from.getZ()-to.getZ();
double combined = Math.sqrt((xDistance*xDistance + zDistance*zDistance)) - 0.6D;
System.out.println(combined);
// 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
if(to.getWorld().getBlockTypeIdAt(to) == Material.BED_BLOCK.getId() && xDistance < 8.0D && zDistance < 8.0D) {
return; // players are allowed to "teleport" into a bed over "short" distances
}
int vl = -1;
@ -231,8 +232,8 @@ public class MovingCheck extends Check {
// pre-calculate boundary values that are needed multiple times in the following checks
// the array each contains [lowerX, higherX, Y, lowerZ, higherZ]
int fromValues[] = {lowerBorder(from.getX()), upperBorder(from.getX()), from.getBlockY(), lowerBorder(from.getZ()),upperBorder(from.getZ()) };
int toValues[] = {lowerBorder(to.getX()), upperBorder(to.getX()), to.getBlockY(), lowerBorder(to.getZ()), upperBorder(to.getZ()) };
int fromValues[] = {lowerBorder(from.getX()), upperBorder(from.getX()), (int)Math.floor(from.getY()+0.5D), lowerBorder(from.getZ()),upperBorder(from.getZ()) };
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
boolean onGroundFrom = playerIsOnGround(from.getWorld(), fromValues, from);
@ -250,7 +251,7 @@ public class MovingCheck extends Check {
// Walk
if(onGroundFrom && onGroundTo)
{
double limit = stepHeight;
double limit = jumpHeight;
double distance = to.getY() - from.getY();
vl = max(vl, heightLimitCheck(limit, distance));
@ -459,13 +460,13 @@ public class MovingCheck extends Check {
// Lets try it that way. Maybe now people don't "disappear" any longer
event.setFrom(l.clone());
event.setTo(l.clone());
event.getPlayer().teleportTo(l.clone());
event.getPlayer().teleport(l.clone());
event.setCancelled(true);
}
else {
// Lets try it that way. Maybe now people don't "disappear" any longer
event.setTo(event.getFrom().clone());
event.getPlayer().teleportTo(event.getFrom().clone());
event.getPlayer().teleport(event.getFrom().clone());
event.setCancelled(true);
}
}

View File

@ -113,13 +113,13 @@ public class SpeedhackCheck extends Check {
event.setFrom(l);
event.setTo(l);
event.setCancelled(true);
event.getPlayer().teleportTo(l);
event.getPlayer().teleport(l);
}
else {
event.setFrom(event.getFrom());
event.setTo(event.getFrom().clone());
event.setCancelled(true);
event.getPlayer().teleportTo(event.getFrom());
event.getPlayer().teleport(event.getFrom());
}
}

View File

@ -1,7 +1,7 @@
package cc.co.evenprime.bukkit.nocheat.listeners;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import cc.co.evenprime.bukkit.nocheat.checks.BedteleportCheck;
@ -14,7 +14,7 @@ public class BedteleportListener extends PlayerListener {
}
@Override
public void onPlayerTeleport(PlayerMoveEvent event) {
public void onPlayerTeleport(PlayerTeleportEvent event) {
if(!event.isCancelled() && check.isActive()) {
check.check(event);

View File

@ -1,7 +1,7 @@
package cc.co.evenprime.bukkit.nocheat.listeners;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import cc.co.evenprime.bukkit.nocheat.checks.MovingCheck;
@ -14,7 +14,7 @@ public class MovingMonitor extends PlayerListener {
}
@Override
public void onPlayerTeleport(PlayerMoveEvent event) {
public void onPlayerTeleport(PlayerTeleportEvent event) {
check.teleported(event);
}