mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-27 14:13:11 +02:00
Reduce (player) morepackets data on confirmed set back teleport.
Distantly related: Often an extra flying packet is sent to confirm a teleport. Here: Reduce effect of set-back loops with morepackets involved.
This commit is contained in:
parent
64c347f801
commit
6ea30131ca
@ -660,9 +660,22 @@ public class MovingData extends ACheckData implements IRemoveSubCheckData {
|
||||
|
||||
public void clearPlayerMorePacketsData() {
|
||||
morePacketsSetback = null;
|
||||
final long now = System.currentTimeMillis();
|
||||
morePacketsFreq.clear(now);
|
||||
morePacketsBurstFreq.clear(now);
|
||||
// TODO: Also reset other data ?
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce the morepackets frequency counters by the given amount, capped at
|
||||
* a minimum of 0.
|
||||
*
|
||||
* @param amount
|
||||
*/
|
||||
public void reducePlayerMorePacketsData(final float amount) {
|
||||
CheckUtils.reduce(System.currentTimeMillis(), amount, morePacketsFreq, morePacketsBurstFreq);
|
||||
}
|
||||
|
||||
public void clearVehicleMorePacketsData() {
|
||||
vehicleMorePacketsLastTime = 0;
|
||||
vehicleMorePacketsBuffer = vehicleMorePacketsBufferDefault;
|
||||
|
@ -1792,6 +1792,9 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
if (data.isTeleportedPosition(to)) {
|
||||
// Set back.
|
||||
confirmSetBack(player, true, data, cc);
|
||||
// Reset some more data.
|
||||
// TODO: Some more?
|
||||
data.reducePlayerMorePacketsData(1);
|
||||
// Log.
|
||||
if (data.debug) {
|
||||
debugTeleportMessage(player, event, "(set back)", to);
|
||||
|
@ -36,6 +36,7 @@ import fr.neatmonster.nocheatplus.hooks.APIUtils;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||
import fr.neatmonster.nocheatplus.logging.StaticLog;
|
||||
import fr.neatmonster.nocheatplus.logging.Streams;
|
||||
import fr.neatmonster.nocheatplus.utilities.ds.count.ActionFrequency;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@ -260,4 +261,36 @@ public class CheckUtils {
|
||||
return NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(Random.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update and then reduce all given ActionFrequency instances by the given
|
||||
* amount, capped at a maximum of 0 for the resulting first bucket score.
|
||||
*
|
||||
* @param amount
|
||||
* The amount to subtract.
|
||||
* @param freqs
|
||||
*/
|
||||
public static void reduce(final long time, final float amount, final ActionFrequency... freqs) {
|
||||
for (int i = 0; i < freqs.length; i++) {
|
||||
final ActionFrequency freq = freqs[i];
|
||||
freq.update(time);
|
||||
freq.setBucket(0, Math.max(0f, freq.bucketScore(0) - amount));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update and then reduce all given ActionFrequency instances by the given
|
||||
* amount, without capping the result.
|
||||
*
|
||||
* @param amount
|
||||
* The amount to subtract.
|
||||
* @param freqs
|
||||
*/
|
||||
public static void subtract(final long time, final float amount, final ActionFrequency... freqs) {
|
||||
for (int i = 0; i < freqs.length; i++) {
|
||||
final ActionFrequency freq = freqs[i];
|
||||
freq.update(time);
|
||||
freq.setBucket(0, freq.bucketScore(0) - amount);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user