mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-30 20:37:52 +01:00
Adapted to CB 950+: Fixed teleports, reduced false positives while
moving/jumping around randomly.
This commit is contained in:
parent
a4bb515ee0
commit
c3b6148245
@ -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.06a
|
version: 1.07
|
||||||
|
|
||||||
softdepend: [ Permissions, CraftIRC ]
|
softdepend: [ Permissions, CraftIRC ]
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ public class MovingCheck extends Check {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
||||||
private final static int jumpingLimit = 4;
|
private final static int jumpingLimit = 5;
|
||||||
|
|
||||||
// How high may a player get compared to his last location with ground contact
|
// How high may a player get compared to his last location with ground contact
|
||||||
private final static double jumpHeight = 1.3D;
|
private final static double jumpHeight = 1.35D;
|
||||||
|
|
||||||
// How high may a player move in one event on ground
|
// How high may a player move in one event on ground
|
||||||
private final static double stepHeight = 0.501D;
|
private final static double stepHeight = 0.501D;
|
||||||
@ -102,21 +102,24 @@ public class MovingCheck extends Check {
|
|||||||
// Get the player-specific data
|
// Get the player-specific data
|
||||||
final MovingData data = MovingData.get(player);
|
final MovingData data = MovingData.get(player);
|
||||||
|
|
||||||
|
|
||||||
// Get the two locations of the event
|
// Get the two locations of the event
|
||||||
final Location to = event.getTo();
|
final Location to = event.getTo();
|
||||||
|
|
||||||
// use our self-defined from-location, instead of the one from the event
|
Location from = event.getFrom();
|
||||||
Location from = data.lastLocation;
|
|
||||||
|
|
||||||
updateVelocity(player.getVelocity(), data);
|
updateVelocity(player.getVelocity(), data);
|
||||||
|
|
||||||
// event.getFrom() is intentional here
|
// event.getFrom() is intentional here
|
||||||
if(shouldBeIgnored(player, data, event.getFrom(), to)) {
|
if(shouldBeIgnored(player, data, from, to)) {
|
||||||
statisticElapsedTimeNano += System.nanoTime() - startTime;
|
statisticElapsedTimeNano += System.nanoTime() - startTime;
|
||||||
statisticTotalEvents++;
|
statisticTotalEvents++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(to.distanceSquared(data.lastLocation) < to.distanceSquared(from)) {
|
||||||
|
from = data.lastLocation;
|
||||||
|
}
|
||||||
/**** Horizontal movement check START ****/
|
/**** Horizontal movement check START ****/
|
||||||
|
|
||||||
// First check the distance the player has moved horizontally
|
// First check the distance the player has moved horizontally
|
||||||
@ -193,7 +196,7 @@ public class MovingCheck extends Check {
|
|||||||
limit += jumpHeight - (data.jumpPhase-jumpingLimit) * 0.2D;
|
limit += jumpHeight - (data.jumpPhase-jumpingLimit) * 0.2D;
|
||||||
else limit += jumpHeight;
|
else limit += jumpHeight;
|
||||||
|
|
||||||
final int onGroundTo = playerIsOnGround(to, 0.5D);
|
final int onGroundTo = playerIsOnGround(to, 0.0D);
|
||||||
|
|
||||||
if(onGroundTo != MovingData.NONSOLID) limit += stepHeight;
|
if(onGroundTo != MovingData.NONSOLID) limit += stepHeight;
|
||||||
|
|
||||||
@ -205,7 +208,7 @@ public class MovingCheck extends Check {
|
|||||||
if(violationLevelVertical < 0) {
|
if(violationLevelVertical < 0) {
|
||||||
if(onGroundTo != MovingData.NONSOLID) { // Land
|
if(onGroundTo != MovingData.NONSOLID) { // Land
|
||||||
data.jumpPhase = 0; // He is on ground now, so reset the jump
|
data.jumpPhase = 0; // He is on ground now, so reset the jump
|
||||||
newSetBack = to;
|
//newSetBack = to;
|
||||||
}
|
}
|
||||||
else { // Fly
|
else { // Fly
|
||||||
data.jumpPhase++; // Enter next phase of the flight
|
data.jumpPhase++; // Enter next phase of the flight
|
||||||
@ -387,12 +390,12 @@ public class MovingCheck extends Check {
|
|||||||
if(data.insideVehicle || player.isInsideVehicle()) {
|
if(data.insideVehicle || player.isInsideVehicle()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// More sophisticated checks
|
if(!from.getWorld().equals(data.lastLocation.getWorld())) {
|
||||||
final Location l = data.lastLocation;
|
return true;
|
||||||
|
}
|
||||||
// Player is currently changing worlds
|
|
||||||
if(!l.getWorld().equals(from.getWorld())) {
|
if(data.teleportTo != null && from.getX() == data.teleportTo.getX() && from.getY() == data.teleportTo.getY() && from.getZ() == data.teleportTo.getZ()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,10 +407,6 @@ public class MovingCheck extends Check {
|
|||||||
if(x == to.getX() && z == to.getZ() && y == to.getY() ) {
|
if(x == to.getX() && z == to.getZ() && y == to.getY() ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Something or someone moved the player without causing a move event - Can't do much with that
|
|
||||||
else if(!(x == l.getX() && z == l.getZ() && y == l.getY())){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -460,8 +459,9 @@ public class MovingCheck extends Check {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!event.isCancelled()) {
|
if(!event.isCancelled()) {
|
||||||
data.lastLocation = event.getTo();
|
|
||||||
data.jumpPhase = 0;
|
data.jumpPhase = 0;
|
||||||
|
data.teleportTo = event.getTo().clone();
|
||||||
|
data.lastLocation = event.getTo().clone();
|
||||||
data.setBackPoint = event.getTo().clone();
|
data.setBackPoint = event.getTo().clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -472,7 +472,6 @@ public class MovingCheck extends Check {
|
|||||||
*/
|
*/
|
||||||
public void respawned(PlayerRespawnEvent event) {
|
public void respawned(PlayerRespawnEvent event) {
|
||||||
MovingData data = MovingData.get(event.getPlayer());
|
MovingData data = MovingData.get(event.getPlayer());
|
||||||
data.lastLocation = event.getRespawnLocation();
|
|
||||||
data.setBackPoint = event.getRespawnLocation().clone();
|
data.setBackPoint = event.getRespawnLocation().clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public class MovingPlayerMonitor extends PlayerListener {
|
|||||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
check.teleported(event);
|
check.teleported(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
check.updateVelocity(event.getPlayer().getVelocity(), MovingData.get(event.getPlayer()));
|
check.updateVelocity(event.getPlayer().getVelocity(), MovingData.get(event.getPlayer()));
|
||||||
|
Loading…
Reference in New Issue
Block a user