/** * @deprecated Use instead: score(float). * @param factor * @return */ public final float getScore(final float factor) { return score(factor); }
/** * Get moderate lag spikes of the last hour (>150 ms, lowest tracked spike * duration). * * @return the moderate lag spikes * @deprecated What is moderate :) ? */ public static final int getModerateLagSpikes() { spikes[0].update(System.currentTimeMillis()); return (int) spikes[0].score(1f); }
/** * Get heavy lag spikes of the last hour (> 450 ms supposedly, first * duration bigger than 150 ms). * * @return the heavy lag spikes * @deprecated What is heavy :) ? */ public static final int getHeavyLagSpikes() { spikes[1].update(System.currentTimeMillis()); return (int) spikes[1].score(1f); }
/** * Get total number of lag spikes counted at all. This is the number of lag * spikes with a duration above spikeDuations[0] which should be 150 ms. * This is the score of spikes[0]. * * @return the number of lag spikes */ public static final int getNumberOfLagSpikes() { spikes[0].update(System.currentTimeMillis()); return (int) spikes[0].score(1f); }
/** * Get lag spike count according to getLagSpikeDurations() values. Entries * of lower indexes contain the entries of higher indexes (so subtraction * would be necessary to get spikes from...to). * * @return the lag spikes */ public static final int[] getLagSpikes() { final int[] out = new int[spikeDurations.length]; final long now = System.currentTimeMillis(); for (int i = 0; i < spikeDurations.length; i++) { spikes[i].update(now); out[i] = (int) spikes[i].score(1f); } return out; }
@Override protected float getScore(List<Character> chars, long ts) { lastAdd = ts; final char[] a = DigestedWords.toArray(chars); final String key = new String(a); ActionFrequency freq = entries.get(key); if (freq == null){ freq = new ActionFrequency(nBuckets, durBucket); entries.put(key, freq); return 0.0f; } freq.update(ts); float score = Math.min(1.0f, freq.score(factor)); freq.add(ts, 1.0f); return score; }
public boolean check(final Player damager, final Player damaged, final FightData data, final FightConfig cc){ // Check if the Entity Id's are Equals if (damager.getEntityId() != damaged.getEntityId()) return false; boolean cancel = false; // Treat self hitting as instant violation. data.selfHitVL.add(System.currentTimeMillis(), 1.0f); // NOTE: This lets VL decrease slightly over 30 seconds, one could also use a number, but this is more tolerant. cancel = executeActions(damager, data.selfHitVL.score(0.99f), 1.0f, cc.selfHitActions).willCancel(); return cancel; }
final boolean isHeavyLoad = taskLoad.score(1f) > heavyLoad || TickTask.getLag(msMonitored, true) > 1.1f; updatePermissionsLazy.mergePrimaryThread();
/** * Always update data, check bypass on violation only. * * @param player * @param time * @param data * @param cc * @return */ public boolean check(final Player player, final DataPacketFlying packetData, final long time, final NetData data, final NetConfig cc, final IPlayerData pData) { data.flyingFrequencyAll.add(time, 1f); final float allScore = data.flyingFrequencyAll.score(1f); if (allScore / cc.flyingFrequencySeconds > cc.flyingFrequencyPPS && executeActions(player, allScore / cc.flyingFrequencySeconds - cc.flyingFrequencyPPS, 1.0 / cc.flyingFrequencySeconds, cc.flyingFrequencyActions).willCancel()) { return true; } else { return false; } }
public boolean check(final Player player, final ChatConfig cc, final ChatData data) { final long now = System.currentTimeMillis(); // Skip if is too close to the startup time. if (now - TickTask.getTimeStart() < cc.loginsStartupDelay) return false; // Split into 6 buckets always. final long durBucket = 1000L * cc.loginsSeconds / 6; final ActionFrequency freq = getActionFrequency(player.getWorld().getName(), 6, durBucket, cc.loginsPerWorldCount); freq.update(now); final boolean cancel = freq.score(1f) > cc.loginsLimit; // TODO: >= ... This will be 1 after the first login (!). if (!cancel) freq.add(1f); return cancel; }
/** * Checks hasBypass on violation only. * @param player * @param time * @param data * @param cc * @return If to cancel. */ public boolean check(final Player player, final long time, final NetData data, final NetConfig cc, final IPlayerData pData) { data.keepAliveFreq.add(time, 1f); final float first = data.keepAliveFreq.bucketScore(0); if (first > 1f) { // Trigger a violation. final double vl = Math.max(first - 1f, data.keepAliveFreq.score(1f) - data.keepAliveFreq.numberOfBuckets()); if (executeActions(player, vl, 1.0, cc.keepAliveFrequencyActions).willCancel()) { return true; } } return false; }
/** * Actual state. * * @param player * @param data * * @param cc * * @return If to cancel a packet event. */ public boolean check(final Player player, final NetData data, final NetConfig cc) { data.packetFrequency.add(System.currentTimeMillis(), 1f); final long fDur = data.packetFrequency.bucketDuration() * data.packetFrequency.numberOfBuckets(); double amount = data.packetFrequency.score(1f) * 1000f / (float) fDur; // if (data.debug) { // debug(player, "Basic amount: " + amount); // } if (amount > cc.packetFrequencyPacketsPerSecond) { amount /= TickTask.getLag(fDur); if (amount > cc.packetFrequencyPacketsPerSecond) { if (executeActions(player, amount - cc.packetFrequencyPacketsPerSecond, 1.0, cc.packetFrequencyActions).willCancel()) { return true; } } } return false; // Cancel state. }
final float fullScore = data.frequencyBuckets.score(cc.frequencyBucketFactor); final long fullTime = cc.frequencyBucketDur * cc.frequencyBuckets; final boolean lag = pData.getCurrentWorldData().shouldAdjustToLag(type);
final float total = data.speedBuckets.score(cc.speedBucketFactor) * 1000f / (fullLag * fullTime);
final float score = data.wrongBlockVL.score(0.9f); if (score > cc.wrongBLockLevel) { if (executeActions(player, score, 1D, cc.wrongBlockActions).willCancel()) {
final float fullScore = data.fastPlaceBuckets.score(1f);
stViol = 0f; final float fullScore = data.yawFreq.score(1f); final float fullViol; if (fullScore > threshold) {
final float nw = data.commandsWeights.score(1f); final double violation = Math.max(nw - cc.commandsLevel, data.commandsShortTermWeight - cc.commandsShortTermLevel);
final double full = data.improbableCount.score(1.0f); if (full > cc.improbableLevel){ final float lag = pData.getCurrentWorldData().shouldAdjustToLag(type) ? TickTask.getLag(data.improbableCount.bucketDuration() * data.improbableCount.numberOfBuckets(), true) : 1f;