mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-18 09:51:17 +02:00
[experimental] Reset yawrate on teleports.
This commit is contained in:
parent
0f763782e0
commit
47faa014bf
@ -126,6 +126,23 @@ public class Combined {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the yawrate data to yaw and time.
|
||||||
|
* @param player
|
||||||
|
* @param yaw
|
||||||
|
* @param time
|
||||||
|
* @param clear If to clear yaws.
|
||||||
|
*/
|
||||||
|
public static final void resetYawRate(final Player player, float yaw, final long time, final boolean clear){
|
||||||
|
if (yaw <= -360f) yaw = -((-yaw) % 360f);
|
||||||
|
else if (yaw >= 360f) yaw = yaw % 360f;
|
||||||
|
final CombinedData data = CombinedData.getData(player);
|
||||||
|
data.lastYaw = yaw;
|
||||||
|
data.lastYawTime = time; // TODO: One might set to some past-time to allow any move at first.
|
||||||
|
data.sumYaw = 0;
|
||||||
|
if (clear) data.yawFreq.clear(time);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow to pass a config flag if to check or only to feed.
|
* Allow to pass a config flag if to check or only to feed.
|
||||||
* @param player
|
* @param player
|
||||||
|
@ -663,17 +663,20 @@ public class MovingListener extends CheckListener{
|
|||||||
|
|
||||||
// If it was a teleport initialized by NoCheatPlus, do it anyway even if another plugin said "no".
|
// If it was a teleport initialized by NoCheatPlus, do it anyway even if another plugin said "no".
|
||||||
final Location to = event.getTo();
|
final Location to = event.getTo();
|
||||||
|
final Location ref;
|
||||||
if (teleported != null && teleported.equals(to)) {
|
if (teleported != null && teleported.equals(to)) {
|
||||||
// Teleport by NCP.
|
// Teleport by NCP.
|
||||||
// Prevent cheaters getting rid of flying data (morepackets, other).
|
// Prevent cheaters getting rid of flying data (morepackets, other).
|
||||||
// TODO: even more strict enforcing ?
|
// TODO: even more strict enforcing ?
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
event.setCancelled(false);
|
event.setCancelled(false);
|
||||||
event.setTo(teleported);
|
event.setTo(teleported); // ?
|
||||||
event.setFrom(teleported);
|
event.setFrom(teleported);
|
||||||
|
ref = teleported;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Not cancelled but NCP teleport.
|
// Not cancelled but NCP teleport.
|
||||||
|
ref = to;
|
||||||
}
|
}
|
||||||
// TODO: This could be done on MONITOR.
|
// TODO: This could be done on MONITOR.
|
||||||
data.onSetBack(teleported);
|
data.onSetBack(teleported);
|
||||||
@ -682,14 +685,15 @@ public class MovingListener extends CheckListener{
|
|||||||
// TODO: check if to do with cancelled teleports !
|
// TODO: check if to do with cancelled teleports !
|
||||||
data.clearMorePacketsData();
|
data.clearMorePacketsData();
|
||||||
data.clearFlyData();
|
data.clearFlyData();
|
||||||
data.resetPositions(event.isCancelled() ? event.getFrom() : to);
|
ref = event.isCancelled() ? event.getFrom() : to;
|
||||||
|
data.resetPositions(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Always drop data from fly checks, as it always loses its validity after teleports. Always!
|
|
||||||
// TODO: NoFall might be necessary to be checked here ?
|
// TODO: NoFall might be necessary to be checked here ?
|
||||||
data.teleported = null;
|
data.teleported = null;
|
||||||
|
|
||||||
|
// Reset yawrate (experimental: might help preventing cascading improbable with rubberbanding).
|
||||||
|
Combined.resetYawRate(player, ref.getYaw(), System.currentTimeMillis(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user