mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-18 18:01:17 +02: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
|
author: Evenprime
|
||||||
|
|
||||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||||
version: 1.04
|
version: 1.04b
|
||||||
|
|
||||||
softdepend: [ Permissions, CraftIRC ]
|
softdepend: [ Permissions, CraftIRC ]
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ public class MovingCheck extends Check {
|
|||||||
|
|
||||||
public MovingCheck(NoCheat plugin, NoCheatConfiguration config) {
|
public MovingCheck(NoCheat plugin, NoCheatConfiguration config) {
|
||||||
super(plugin, "moving", PermissionData.PERMISSION_MOVING, 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)
|
// 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();
|
Location from = data.teleportTo != null ? data.teleportTo : event.getFrom();
|
||||||
data.teleportTo = null;
|
data.teleportTo = null;
|
||||||
|
|
||||||
|
|
||||||
|
updateVelocity(player.getVelocity(), data);
|
||||||
|
|
||||||
if(shouldBeIgnored(player, data, from, to)) {
|
if(shouldBeIgnored(player, data, from, to)) {
|
||||||
statisticElapsedTimeNano += System.nanoTime() - startTime;
|
statisticElapsedTimeNano += System.nanoTime() - startTime;
|
||||||
statisticTotalEvents++;
|
statisticTotalEvents++;
|
||||||
@ -130,6 +132,7 @@ public class MovingCheck extends Check {
|
|||||||
|
|
||||||
final int onGroundFrom = playerIsOnGround(from, 0.0D);
|
final int onGroundFrom = playerIsOnGround(from, 0.0D);
|
||||||
|
|
||||||
|
|
||||||
// Do various checks on the players horizontal movement
|
// Do various checks on the players horizontal movement
|
||||||
int sn = getSneakingViolationLevel(combined, data, player);
|
int sn = getSneakingViolationLevel(combined, data, player);
|
||||||
int sw = getSwimmingViolationLevel(combined, data, onGroundFrom == MovingData.LIQUID, 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) {
|
private boolean shouldBeIgnored(final Player player, final MovingData data, final Location from, final Location to) {
|
||||||
|
|
||||||
// Identical locations - just ignore the event
|
// First the simple yes/no checks
|
||||||
final double x = from.getX();
|
if(data.respawned || data.insideVehicle || player.isInsideVehicle() || data.worldChanged) {
|
||||||
final double y = from.getY();
|
return true;
|
||||||
final double z = from.getZ();
|
}
|
||||||
|
|
||||||
|
// More sophisticated checks
|
||||||
final Location l = data.lastLocation;
|
final Location l = data.lastLocation;
|
||||||
|
|
||||||
// Player is currently changing worlds
|
// Player is currently changing worlds
|
||||||
if(data.worldChanged) {
|
if(l.getWorld() != from.getWorld()) {
|
||||||
return true;
|
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() ) {
|
if(x == to.getX() && z == to.getZ() && y == to.getY() ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -394,15 +405,7 @@ public class MovingCheck extends Check {
|
|||||||
else if(!(x == l.getX() && z == l.getZ() && y == l.getY())){
|
else if(!(x == l.getX() && z == l.getZ() && y == l.getY())){
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,6 +451,8 @@ public class MovingCheck extends Check {
|
|||||||
|
|
||||||
MovingData data = MovingData.get(event.getPlayer());
|
MovingData data = MovingData.get(event.getPlayer());
|
||||||
|
|
||||||
|
if(data.respawned) data.respawned = false;
|
||||||
|
|
||||||
if(!event.isCancelled()) {
|
if(!event.isCancelled()) {
|
||||||
data.lastLocation = event.getTo();
|
data.lastLocation = event.getTo();
|
||||||
data.teleportTo = event.getTo();
|
data.teleportTo = event.getTo();
|
||||||
|
Loading…
Reference in New Issue
Block a user