mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-03 01:00:20 +01:00
A little bit improved handling of velocity-changing plugins
Potential fix for respawn-events with changed respawn-location
This commit is contained in:
parent
84c8e98054
commit
bfae43effc
@ -3,7 +3,7 @@ name: NoCheat
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||
version: 1.04
|
||||
version: 1.04b
|
||||
|
||||
softdepend: [ Permissions, CraftIRC ]
|
||||
|
||||
|
@ -39,7 +39,6 @@ public class MovingCheck extends Check {
|
||||
|
||||
public MovingCheck(NoCheat plugin, NoCheatConfiguration config) {
|
||||
super(plugin, "moving", PermissionData.PERMISSION_MOVING, config);
|
||||
|
||||
}
|
||||
|
||||
// How many move events can a player have in air before he is expected to lose altitude (or land somewhere)
|
||||
@ -106,6 +105,9 @@ public class MovingCheck extends Check {
|
||||
Location from = data.teleportTo != null ? data.teleportTo : event.getFrom();
|
||||
data.teleportTo = null;
|
||||
|
||||
|
||||
updateVelocity(player.getVelocity(), data);
|
||||
|
||||
if(shouldBeIgnored(player, data, from, to)) {
|
||||
statisticElapsedTimeNano += System.nanoTime() - startTime;
|
||||
statisticTotalEvents++;
|
||||
@ -130,6 +132,7 @@ public class MovingCheck extends Check {
|
||||
|
||||
final int onGroundFrom = playerIsOnGround(from, 0.0D);
|
||||
|
||||
|
||||
// Do various checks on the players horizontal movement
|
||||
int sn = getSneakingViolationLevel(combined, data, player);
|
||||
int sw = getSwimmingViolationLevel(combined, data, onGroundFrom == MovingData.LIQUID, player);
|
||||
@ -377,16 +380,24 @@ public class MovingCheck extends Check {
|
||||
*/
|
||||
private boolean shouldBeIgnored(final Player player, final MovingData data, final Location from, final Location to) {
|
||||
|
||||
// Identical locations - just ignore the event
|
||||
final double x = from.getX();
|
||||
final double y = from.getY();
|
||||
final double z = from.getZ();
|
||||
// First the simple yes/no checks
|
||||
if(data.respawned || data.insideVehicle || player.isInsideVehicle() || data.worldChanged) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// More sophisticated checks
|
||||
final Location l = data.lastLocation;
|
||||
|
||||
// Player is currently changing worlds
|
||||
if(data.worldChanged) {
|
||||
if(l.getWorld() != from.getWorld()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final double x = from.getX();
|
||||
final double y = from.getY();
|
||||
final double z = from.getZ();
|
||||
|
||||
// Player didn't move at all
|
||||
if(x == to.getX() && z == to.getZ() && y == to.getY() ) {
|
||||
return true;
|
||||
}
|
||||
@ -394,15 +405,7 @@ public class MovingCheck extends Check {
|
||||
else if(!(x == l.getX() && z == l.getZ() && y == l.getY())){
|
||||
return true;
|
||||
}
|
||||
// Player respawned just before, this causes all kinds of weirdness - better ignore it
|
||||
else if(data.respawned) {
|
||||
data.respawned = false;
|
||||
return true;
|
||||
}
|
||||
// Player is inside a vehicle, this causes all kinds of weirdness - better ignore it
|
||||
else if(data.insideVehicle || player.isInsideVehicle()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -448,6 +451,8 @@ public class MovingCheck extends Check {
|
||||
|
||||
MovingData data = MovingData.get(event.getPlayer());
|
||||
|
||||
if(data.respawned) data.respawned = false;
|
||||
|
||||
if(!event.isCancelled()) {
|
||||
data.lastLocation = event.getTo();
|
||||
data.teleportTo = event.getTo();
|
||||
|
Loading…
Reference in New Issue
Block a user