Potential fix for Multiworld support:

- If a player "moves" between worlds he won't be checked
- If a player gets teleported by something else than my plugin the
setback locations for moving and speedhack checks get discarded.
This commit is contained in:
Evenprime 2011-03-11 07:39:04 +01:00
parent 5df7af20b3
commit 36953f4f08
5 changed files with 32 additions and 12 deletions

View File

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

View File

@ -139,8 +139,8 @@ public class NoCheatPlugin extends JavaPlugin {
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Lowest, this); // used for speedhack and moving checks
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Monitor, this); // used to delete old data of users
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Low, this); // used for airbuild check
pm.registerEvent(Event.Type.PLAYER_TELEPORT, playerListener, Priority.Lowest, this); // used for teleportfrombed check
pm.registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.Lowest, this); // used for moving check to reset jumpingphase
pm.registerEvent(Event.Type.PLAYER_TELEPORT, playerListener, Priority.Lowest, this); // used for moving, speedhack and teleportfrombed check
pm.registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.Lowest, this); // used for moving check to reset jumping phase
PluginDescriptionFile pdfFile = this.getDescription();

View File

@ -129,17 +129,28 @@ public class MovingCheck {
types[Material.JACK_O_LANTERN.getId()]= BlockType.SOLID;
types[Material.CAKE_BLOCK.getId()]= BlockType.UNKNOWN;
}
public static void check(NoCheatData data, PlayerMoveEvent event) {
public static void check(PlayerMoveEvent event) {
// Should we check at all
if(NoCheatPlugin.hasPermission(event.getPlayer(), "nocheat.moving"))
return;
// Get the player-specific data
NoCheatData data = NoCheatPlugin.getPlayerData(event.getPlayer());
// Get the two locations of the event
Location from = event.getFrom();
Location to = event.getTo();
if(from.getWorld() != to.getWorld()) {
// Moving between different worlds is considered ok
// Also prevent accidential back teleporting by discarding old-world coordinates
data.movingSetBackPoint = null;
data.speedhackSetBackPoint = null;
return;
}
// First check the distance the player has moved horizontally
// TODO: Make this check much more precise

View File

@ -18,12 +18,15 @@ public class SpeedhackCheck {
private static final long interval = 1000;
private static final int violationsLimit = 3;
public static void check(NoCheatData data, PlayerMoveEvent event) {
public static void check(PlayerMoveEvent event) {
// Should we check at all?
if(NoCheatPlugin.hasPermission(event.getPlayer(), "nocheat.speedhack"))
return;
// Get the player-specific data
NoCheatData data = NoCheatPlugin.getPlayerData(event.getPlayer());
// Get the time of the server
long time = System.currentTimeMillis();

View File

@ -32,14 +32,12 @@ public class NoCheatPlayerListener extends PlayerListener {
@Override
public void onPlayerMove(PlayerMoveEvent event) {
// Get the player-specific data
NoCheatData data = NoCheatPlugin.getPlayerData(event.getPlayer());
if(!event.isCancelled() && NoCheatConfiguration.speedhackCheckActive)
SpeedhackCheck.check(data, event);
SpeedhackCheck.check(event);
if(!event.isCancelled() && NoCheatConfiguration.movingCheckActive)
MovingCheck.check(data, event);
MovingCheck.check(event);
}
@Override
@ -48,5 +46,13 @@ public class NoCheatPlayerListener extends PlayerListener {
if(!event.isCancelled() && NoCheatConfiguration.bedteleportCheckActive) {
BedteleportCheck.check(event);
}
if(!event.isCancelled()) {
NoCheatData data = NoCheatPlugin.getPlayerData(event.getPlayer());
if(!event.getTo().equals(data.movingSetBackPoint) && !event.getTo().equals(data.speedhackSetBackPoint)) {
data.speedhackSetBackPoint = null;
data.movingSetBackPoint = null;
}
}
}
}