Пример #1
0
 public static CombinedData getData(final Player player) {
   final String playerName = player.getName();
   CombinedData data = playersMap.get(playerName);
   if (data == null) {
     data = new CombinedData(CombinedConfig.getConfig(player));
     playersMap.put(playerName, data);
   }
   return data;
 }
Пример #2
0
 private boolean checkImprobable(final Player player, final float weight, final long now) {
   if (!isEnabled(player)) return false;
   final CombinedData data = CombinedData.getData(player);
   final CombinedConfig cc = CombinedConfig.getConfig(player);
   data.improbableCount.add(now, weight);
   final float shortTerm = data.improbableCount.bucketScore(0);
   double violation = 0;
   boolean violated = false;
   if (shortTerm * 0.8f > cc.improbableLevel / 20.0) {
     final float lag = cc.lag ? TickTask.getLag(data.improbableCount.bucketDuration(), true) : 1f;
     if (shortTerm / lag > cc.improbableLevel / 20.0) {
       violation += shortTerm * 2d / lag;
       violated = true;
     }
   }
   final double full = data.improbableCount.score(1.0f);
   if (full > cc.improbableLevel) {
     final float lag =
         cc.lag
             ? TickTask.getLag(
                 data.improbableCount.bucketDuration() * data.improbableCount.numberOfBuckets(),
                 true)
             : 1f;
     if (full / lag > cc.improbableLevel) {
       violation += full / lag;
       violated = true;
     }
   }
   boolean cancel = false;
   if (violated) {
     // Execute actions
     data.improbableVL += violation / 10.0;
     cancel = executeActions(player, data.improbableVL, violation / 10.0, cc.improbableActions);
   } else data.improbableVL *= 0.95;
   return cancel;
 }