mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-27 01:41:28 +01:00
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:
parent
5df7af20b3
commit
36953f4f08
@ -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:
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user