mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-27 10:57:47 +01:00
[Bleeding] Replace LagMeasureTask by TickTask.
Contains some fixes. Removes the debugging message for lag. Might in some places use wild guesses for lag estimation (TickTask.getLag(1000) < 1.5).
This commit is contained in:
parent
48705669dd
commit
fd2469490a
@ -55,15 +55,14 @@ import fr.neatmonster.nocheatplus.event.IHaveMethodOrder;
|
|||||||
import fr.neatmonster.nocheatplus.event.ListenerManager;
|
import fr.neatmonster.nocheatplus.event.ListenerManager;
|
||||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||||
import fr.neatmonster.nocheatplus.metrics.Metrics;
|
import fr.neatmonster.nocheatplus.metrics.Metrics;
|
||||||
import fr.neatmonster.nocheatplus.metrics.MetricsData;
|
|
||||||
import fr.neatmonster.nocheatplus.metrics.Metrics.Graph;
|
import fr.neatmonster.nocheatplus.metrics.Metrics.Graph;
|
||||||
import fr.neatmonster.nocheatplus.metrics.Metrics.Plotter;
|
import fr.neatmonster.nocheatplus.metrics.Metrics.Plotter;
|
||||||
|
import fr.neatmonster.nocheatplus.metrics.MetricsData;
|
||||||
import fr.neatmonster.nocheatplus.permissions.PermissionUtil;
|
import fr.neatmonster.nocheatplus.permissions.PermissionUtil;
|
||||||
import fr.neatmonster.nocheatplus.permissions.PermissionUtil.CommandProtectionEntry;
|
import fr.neatmonster.nocheatplus.permissions.PermissionUtil.CommandProtectionEntry;
|
||||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||||
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
|
||||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||||
import fr.neatmonster.nocheatplus.utilities.Updates;
|
import fr.neatmonster.nocheatplus.utilities.Updates;
|
||||||
@ -357,10 +356,6 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
|||||||
metrics = null;
|
metrics = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop the lag measuring task.
|
|
||||||
if (verbose) LogUtil.logInfo("[NoCheatPlus] Stop LagMeasureTask...");
|
|
||||||
LagMeasureTask.cancel();
|
|
||||||
|
|
||||||
// Just to be sure nothing gets left out.
|
// Just to be sure nothing gets left out.
|
||||||
if (verbose) LogUtil.logInfo("[NoCheatPlus] Stop all remaining tasks...");
|
if (verbose) LogUtil.logInfo("[NoCheatPlus] Stop all remaining tasks...");
|
||||||
getServer().getScheduler().cancelTasks(this);
|
getServer().getScheduler().cancelTasks(this);
|
||||||
@ -498,9 +493,6 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
|||||||
CommandHandler commandHandler = new CommandHandler(this, notifyReload);
|
CommandHandler commandHandler = new CommandHandler(this, notifyReload);
|
||||||
command.setExecutor(commandHandler);
|
command.setExecutor(commandHandler);
|
||||||
// (CommandHandler is TabExecutor.)
|
// (CommandHandler is TabExecutor.)
|
||||||
|
|
||||||
// Set up a task to monitor server lag.
|
|
||||||
LagMeasureTask.start(this);
|
|
||||||
|
|
||||||
// Set up the tick task.
|
// Set up the tick task.
|
||||||
TickTask.start(this);
|
TickTask.start(this);
|
||||||
|
@ -178,6 +178,7 @@ public abstract class Check {
|
|||||||
if (!type.isEnabled(player) || player.hasPermission(type.getPermission()))
|
if (!type.isEnabled(player) || player.hasPermission(type.getPermission()))
|
||||||
return false;
|
return false;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
// TODO: this should be mostly obsolete.
|
||||||
LogUtil.logSevere(e);
|
LogUtil.logSevere(e);
|
||||||
}
|
}
|
||||||
return !NCPExemptionManager.isExempted(player, type);
|
return !NCPExemptionManager.isExempted(player, type);
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
|
|||||||
import fr.neatmonster.nocheatplus.checks.Check;
|
import fr.neatmonster.nocheatplus.checks.Check;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MMP"""""""MM dP
|
* MMP"""""""MM dP
|
||||||
@ -122,9 +122,11 @@ public class Angle extends Check {
|
|||||||
// Is the violation is superior to the threshold defined in the configuration?
|
// Is the violation is superior to the threshold defined in the configuration?
|
||||||
if (violation > cc.angleThreshold) {
|
if (violation > cc.angleThreshold) {
|
||||||
// Has the server lagged?
|
// Has the server lagged?
|
||||||
if (!LagMeasureTask.skipCheck())
|
if (TickTask.getLag(1000) < 1.5f){
|
||||||
|
// TODO: 1.5 is a fantasy value.
|
||||||
// If it hasn't, increment the violation level.
|
// If it hasn't, increment the violation level.
|
||||||
data.angleVL += violation;
|
data.angleVL += violation;
|
||||||
|
}
|
||||||
|
|
||||||
// Execute whatever actions are associated with this check and the violation level and find out if we should
|
// Execute whatever actions are associated with this check and the violation level and find out if we should
|
||||||
// cancel the event.
|
// cancel the event.
|
||||||
|
@ -6,9 +6,12 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
|
|
||||||
import fr.neatmonster.nocheatplus.checks.Check;
|
import fr.neatmonster.nocheatplus.checks.Check;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||||
|
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
|
||||||
|
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
|
||||||
|
import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
|
||||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
|
||||||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
||||||
|
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MM'""""'YMM oo dP oo dP
|
* MM'""""'YMM oo dP oo dP
|
||||||
@ -49,6 +52,7 @@ public class Critical extends Check {
|
|||||||
final PlayerLocation location = new PlayerLocation(mcAccess, mcAccess.getBlockCache(loc.getWorld()));
|
final PlayerLocation location = new PlayerLocation(mcAccess, mcAccess.getBlockCache(loc.getWorld()));
|
||||||
location.set(loc, player);
|
location.set(loc, player);
|
||||||
if (location.isIllegal()) {
|
if (location.isIllegal()) {
|
||||||
|
// TODO: This should be impossible !
|
||||||
location.cleanup();
|
location.cleanup();
|
||||||
CheckUtils.onIllegalMove(player);
|
CheckUtils.onIllegalMove(player);
|
||||||
return true;
|
return true;
|
||||||
@ -59,23 +63,30 @@ public class Critical extends Check {
|
|||||||
if (player.getFallDistance() > 0f && !location.isOnGround() && !location.isOnClimbable() && !location.isInLiquid()
|
if (player.getFallDistance() > 0f && !location.isOnGround() && !location.isOnClimbable() && !location.isInLiquid()
|
||||||
&& !player.hasPotionEffect(PotionEffectType.BLINDNESS)){
|
&& !player.hasPotionEffect(PotionEffectType.BLINDNESS)){
|
||||||
// It was a critical hit, now check if the player has jumped or has sent a packet to mislead the server.
|
// It was a critical hit, now check if the player has jumped or has sent a packet to mislead the server.
|
||||||
if (player.getFallDistance() < cc.criticalFallDistance
|
if (player.getFallDistance() < cc.criticalFallDistance || Math.abs(player.getVelocity().getY()) < cc.criticalVelocity) {
|
||||||
|| Math.abs(player.getVelocity().getY()) < cc.criticalVelocity) {
|
final MovingConfig ccM = MovingConfig.getConfig(player);
|
||||||
final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance())
|
final MovingData dataM = MovingData.getData(player);
|
||||||
/ cc.criticalFallDistance;
|
if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)){
|
||||||
final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY()))
|
final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance())
|
||||||
/ cc.criticalVelocity;
|
/ cc.criticalFallDistance;
|
||||||
final double delta = deltaFallDistance > 0D ? deltaFallDistance
|
final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY()))
|
||||||
: 0D + deltaVelocity > 0D ? deltaVelocity : 0D;
|
/ cc.criticalVelocity;
|
||||||
|
final double delta = deltaFallDistance > 0D ? deltaFallDistance
|
||||||
|
: 0D + deltaVelocity > 0D ? deltaVelocity : 0D;
|
||||||
|
|
||||||
// Player failed the check, but this is influenced by lag so don't do it if there was lag.
|
// Player failed the check, but this is influenced by lag so don't do it if there was lag.
|
||||||
if (!LagMeasureTask.skipCheck())
|
if (TickTask.getLag(1000) < 1.5){
|
||||||
// Increment the violation level.
|
// TODO: 1.5 is a fantasy value.
|
||||||
data.criticalVL += delta;
|
// Increment the violation level.
|
||||||
|
data.criticalVL += delta;
|
||||||
|
}
|
||||||
|
|
||||||
// Execute whatever actions are associated with this check and the violation level and find out if we
|
|
||||||
// should cancel the event.
|
// Execute whatever actions are associated with this check and the violation level and find out if we
|
||||||
cancel = executeActions(player, data.criticalVL, delta, cc.criticalActions);
|
// should cancel the event.
|
||||||
|
cancel = executeActions(player, data.criticalVL, delta, cc.criticalActions);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import fr.neatmonster.nocheatplus.checks.Check;
|
import fr.neatmonster.nocheatplus.checks.Check;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||||
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* M""MMMMM""M dP dP dP
|
* M""MMMMM""M dP dP dP
|
||||||
@ -40,6 +40,8 @@ public class Knockback extends Check {
|
|||||||
final FightData data = FightData.getData(player);
|
final FightData data = FightData.getData(player);
|
||||||
|
|
||||||
boolean cancel = false;
|
boolean cancel = false;
|
||||||
|
|
||||||
|
final long time = System.currentTimeMillis();
|
||||||
|
|
||||||
// If the item has the knockback enchantment, do not check.
|
// If the item has the knockback enchantment, do not check.
|
||||||
if (player.getItemInHand().containsEnchantment(Enchantment.KNOCKBACK)
|
if (player.getItemInHand().containsEnchantment(Enchantment.KNOCKBACK)
|
||||||
@ -47,14 +49,15 @@ public class Knockback extends Check {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// How long ago has the player started sprinting?
|
// How long ago has the player started sprinting?
|
||||||
if (data.knockbackSprintTime > 0L
|
final long usedTime = (time - data.knockbackSprintTime);
|
||||||
&& System.currentTimeMillis() - data.knockbackSprintTime < cc.knockbackInterval) {
|
final long effectiveTime = (long) ((float) usedTime * (cc.lag ? TickTask.getLag(usedTime): 1f));
|
||||||
final double difference = cc.knockbackInterval - System.currentTimeMillis() + data.knockbackSprintTime;
|
// Pretty rough: Completely skip on lag.
|
||||||
|
if (data.knockbackSprintTime > 0L && effectiveTime < cc.knockbackInterval) {
|
||||||
|
final double difference = cc.knockbackInterval - time + data.knockbackSprintTime;
|
||||||
|
|
||||||
// Player failed the check, but this is influenced by lag, so don't do it if there was lag.
|
// Player failed the check, but this is influenced by lag, so don't do it if there was lag.
|
||||||
if (!LagMeasureTask.skipCheck())
|
// Increment the violation level
|
||||||
// Increment the violation level
|
data.knockbackVL += difference;
|
||||||
data.knockbackVL += difference;
|
|
||||||
|
|
||||||
// Execute whatever actions are associated with this check and the violation level and find out if we should
|
// Execute whatever actions are associated with this check and the violation level and find out if we should
|
||||||
// cancel the event.
|
// cancel the event.
|
||||||
|
@ -14,7 +14,7 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
|
|||||||
import fr.neatmonster.nocheatplus.checks.combined.Improbable;
|
import fr.neatmonster.nocheatplus.checks.combined.Improbable;
|
||||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MM"""""""`MM dP
|
* MM"""""""`MM dP
|
||||||
@ -103,8 +103,10 @@ public class Reach extends Check {
|
|||||||
|
|
||||||
if (violation > 0) {
|
if (violation > 0) {
|
||||||
// He failed, increment violation level. This is influenced by lag, so don't do it if there was lag.
|
// He failed, increment violation level. This is influenced by lag, so don't do it if there was lag.
|
||||||
if (!LagMeasureTask.skipCheck())
|
if (TickTask.getLag(1000) < 1.5f){
|
||||||
data.reachVL += violation;
|
// TODO: 1.5 is a fantasy value.
|
||||||
|
data.reachVL += violation;
|
||||||
|
}
|
||||||
|
|
||||||
// Execute whatever actions are associated with this check and the violation level and find out if we should
|
// Execute whatever actions are associated with this check and the violation level and find out if we should
|
||||||
// cancel the event.
|
// cancel the event.
|
||||||
|
@ -8,7 +8,6 @@ import fr.neatmonster.nocheatplus.actions.ParameterName;
|
|||||||
import fr.neatmonster.nocheatplus.checks.Check;
|
import fr.neatmonster.nocheatplus.checks.Check;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||||
import fr.neatmonster.nocheatplus.checks.ViolationData;
|
import fr.neatmonster.nocheatplus.checks.ViolationData;
|
||||||
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
|
||||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -81,8 +80,7 @@ public class Speed extends Check {
|
|||||||
// Too many attacks?
|
// Too many attacks?
|
||||||
if (max > cc.speedLimit) {
|
if (max > cc.speedLimit) {
|
||||||
// If there was lag, don't count it towards violation level.
|
// If there was lag, don't count it towards violation level.
|
||||||
if (!LagMeasureTask.skipCheck())
|
data.speedVL += max - cc.speedLimit;
|
||||||
data.speedVL += max - cc.speedLimit;
|
|
||||||
|
|
||||||
// Execute whatever actions are associated with this check and the violation level and find out if we should
|
// Execute whatever actions are associated with this check and the violation level and find out if we should
|
||||||
// cancel the event.
|
// cancel the event.
|
||||||
|
@ -997,9 +997,9 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||||||
* @param cc
|
* @param cc
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public final boolean shouldCheckSurvivalFly(final Player player, final MovingData data, final MovingConfig cc){
|
public static final boolean shouldCheckSurvivalFly(final Player player, final MovingData data, final MovingConfig cc){
|
||||||
if (player.hasPermission(Permissions.MOVING_CREATIVEFLY)) return false;
|
if (player.hasPermission(Permissions.MOVING_CREATIVEFLY)) return false;
|
||||||
else if (!survivalFly.isEnabled(player)) return false;
|
else if (!cc.survivalFlyCheck || NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY) || player.hasPermission(Permissions.MOVING_SURVIVALFLY)) return false;
|
||||||
else if ((cc.ignoreCreative || player.getGameMode() != GameMode.CREATIVE) && (cc.ignoreAllowFlight || !player.getAllowFlight())){
|
else if ((cc.ignoreCreative || player.getGameMode() != GameMode.CREATIVE) && (cc.ignoreAllowFlight || !player.getAllowFlight())){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,112 +0,0 @@
|
|||||||
package fr.neatmonster.nocheatplus.utilities;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
|
||||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
|
||||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
|
||||||
import fr.neatmonster.nocheatplus.metrics.MetricsData;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* M""MMMMMMMM M"""""`'"""`YM
|
|
||||||
* M MMMMMMMM M mm. mm. M
|
|
||||||
* M MMMMMMMM .d8888b. .d8888b. M MMM MMM M .d8888b. .d8888b. .d8888b. dP dP 88d888b. .d8888b.
|
|
||||||
* M MMMMMMMM 88' `88 88' `88 M MMM MMM M 88ooood8 88' `88 Y8ooooo. 88 88 88' `88 88ooood8
|
|
||||||
* M MMMMMMMM 88. .88 88. .88 M MMM MMM M 88. ... 88. .88 88 88. .88 88 88. ...
|
|
||||||
* M M `88888P8 `8888P88 M MMM MMM M `88888P' `88888P8 `88888P' `88888P' dP `88888P'
|
|
||||||
* MMMMMMMMMMM .88 MMMMMMMMMMMMMM
|
|
||||||
* d8888P
|
|
||||||
*
|
|
||||||
* M""""""""M dP
|
|
||||||
* Mmmm mmmM 88
|
|
||||||
* MMMM MMMM .d8888b. .d8888b. 88 .dP
|
|
||||||
* MMMM MMMM 88' `88 Y8ooooo. 88888"
|
|
||||||
* MMMM MMMM 88. .88 88 88 `8b.
|
|
||||||
* MMMM MMMM `88888P8 `88888P' dP `YP
|
|
||||||
* MMMMMMMMMM
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* A task running in the background that measures tick time vs. real time.
|
|
||||||
*/
|
|
||||||
public class LagMeasureTask implements Runnable {
|
|
||||||
|
|
||||||
/** The instance of the class for a static access. */
|
|
||||||
private static LagMeasureTask instance = new LagMeasureTask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancel the task.
|
|
||||||
*/
|
|
||||||
public static void cancel() {
|
|
||||||
if (instance.lagMeasureTaskId != -1) {
|
|
||||||
try {
|
|
||||||
Bukkit.getServer().getScheduler().cancelTask(instance.lagMeasureTaskId);
|
|
||||||
} catch (final Exception e) {
|
|
||||||
LogUtil.logWarning("[NoCheatPlus] Couldn't cancel LagMeasureTask: " + e.getMessage() + ".");
|
|
||||||
}
|
|
||||||
instance.lagMeasureTaskId = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if checking must be skipped (lag).
|
|
||||||
*
|
|
||||||
* @return true, if successful
|
|
||||||
*/
|
|
||||||
public static boolean skipCheck() {
|
|
||||||
return instance.skipCheck;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start the task.
|
|
||||||
*
|
|
||||||
* @param plugin
|
|
||||||
* the instance of NoCheatPlus
|
|
||||||
*/
|
|
||||||
public static void start(final NoCheatPlus plugin) {
|
|
||||||
instance.lagMeasureTaskId = Bukkit.getServer().getScheduler()
|
|
||||||
.scheduleSyncRepeatingTask(plugin, instance, 20L, 20L);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The last in game second time. */
|
|
||||||
private long lastInGameSecondTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
/** The last in game second duration. */
|
|
||||||
private long lastInGameSecondDuration = 2000L;
|
|
||||||
|
|
||||||
/** The lag measure task id. */
|
|
||||||
private int lagMeasureTaskId = -1;
|
|
||||||
|
|
||||||
/** The skip check. */
|
|
||||||
private boolean skipCheck = false;
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Runnable#run()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
final boolean oldStatus = skipCheck;
|
|
||||||
// If the previous second took to long, skip checks during this second.
|
|
||||||
skipCheck = lastInGameSecondDuration > 2000;
|
|
||||||
|
|
||||||
// Add the number of ticks the last second have contained to the Metrics data.
|
|
||||||
int ticks = (int) Math.round(20000D / lastInGameSecondDuration);
|
|
||||||
if (ticks > 20)
|
|
||||||
ticks = 20;
|
|
||||||
MetricsData.addTicks(ticks);
|
|
||||||
|
|
||||||
// Show the debug messages.
|
|
||||||
if (ConfigManager.getConfigFile().getBoolean(ConfPaths.LOGGING_DEBUG))
|
|
||||||
if (oldStatus != skipCheck && skipCheck)
|
|
||||||
LogUtil.logInfo("[NoCheatPlus] Detected server lag, some checks will not work.");
|
|
||||||
else if (oldStatus != skipCheck && !skipCheck)
|
|
||||||
LogUtil.logInfo("[NoCheatPlus] Server lag seems to have stopped, reenabling checks.");
|
|
||||||
|
|
||||||
final long time = System.currentTimeMillis();
|
|
||||||
lastInGameSecondDuration = time - lastInGameSecondTime;
|
|
||||||
lastInGameSecondTime = time;
|
|
||||||
} catch (final Exception e) {
|
|
||||||
// Just prevent this thread from dying for whatever reason.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,6 +15,7 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
|
|||||||
import fr.neatmonster.nocheatplus.checks.ViolationData;
|
import fr.neatmonster.nocheatplus.checks.ViolationData;
|
||||||
import fr.neatmonster.nocheatplus.checks.access.ICheckData;
|
import fr.neatmonster.nocheatplus.checks.access.ICheckData;
|
||||||
import fr.neatmonster.nocheatplus.components.TickListener;
|
import fr.neatmonster.nocheatplus.components.TickListener;
|
||||||
|
import fr.neatmonster.nocheatplus.metrics.MetricsData;
|
||||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -409,6 +410,12 @@ public class TickTask implements Runnable {
|
|||||||
updatePermissions();
|
updatePermissions();
|
||||||
// Listeners.
|
// Listeners.
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
// Metrics
|
||||||
|
if (tick > 0 && (tick % 20) == 0){
|
||||||
|
// Count every second.
|
||||||
|
final int ticks = Math.min(20, (int) (1000f / (50f * getLag(1000, true))));
|
||||||
|
MetricsData.addTicks(ticks);
|
||||||
|
}
|
||||||
|
|
||||||
// Measure time after heavy stuff.
|
// Measure time after heavy stuff.
|
||||||
final long time = System.currentTimeMillis();
|
final long time = System.currentTimeMillis();
|
||||||
|
Loading…
Reference in New Issue
Block a user