Exemplo n.º 1
0
 /**
  * Check the logged out players for if any data can be removed.<br>
  * Currently only "dumb" full removal is performed. Later it is thinkable to remove "as much as
  * reasonable".
  */
 public void checkExpiration() {
   if (durExpireData <= 0) return;
   final long now = System.currentTimeMillis();
   final Set<CheckDataFactory> factories = new LinkedHashSet<CheckDataFactory>();
   final Set<Entry<String, Long>> entries = lastLogout.entrySet();
   final Iterator<Entry<String, Long>> iterator = entries.iterator();
   while (iterator.hasNext()) {
     final Entry<String, Long> entry = iterator.next();
     final long ts = entry.getValue();
     if (now - ts <= durExpireData) break;
     final String playerName = entry.getKey();
     if (deleteData) {
       factories.clear();
       for (final CheckType type : CheckType.values()) {
         final CheckDataFactory factory = type.getDataFactory();
         if (factory != null) factories.add(factory);
       }
       for (final CheckDataFactory factory : factories) {
         factory.removeData(playerName);
       }
       clearComponentData(CheckType.ALL, playerName);
     }
     if (deleteData || deleteHistory) removeExecutionHistory(CheckType.ALL, playerName);
     if (deleteHistory) ViolationHistory.removeHistory(playerName);
     iterator.remove();
   }
 }
Exemplo n.º 2
0
 /**
  * Remove data and history of all players for the given check type and sub checks.
  *
  * @param checkType
  */
 public static void clearData(final CheckType checkType) {
   final Set<CheckDataFactory> factories = new HashSet<CheckDataFactory>();
   for (final CheckType type : APIUtils.getWithChildren(checkType)) {
     final Map<String, ExecutionHistory> map = instance.executionHistories.get(type);
     if (map != null) map.clear();
     final CheckDataFactory factory = type.getDataFactory();
     if (factory != null) factories.add(factory);
   }
   for (final CheckDataFactory factory : factories) {
     factory.removeAllData();
   }
   for (final IRemoveData rmd : instance.iRemoveData) {
     if (rmd instanceof IHaveCheckType) {
       final CheckType refType = ((IHaveCheckType) rmd).getCheckType();
       if (refType == checkType || APIUtils.isParent(checkType, refType)) rmd.removeAllData();
     }
   }
   ViolationHistory.clear(checkType);
 }
Exemplo n.º 3
0
  /**
   * Remove the player data for a given player and a given check type. CheckType.ALL and null will
   * be interpreted as removing all data.<br>
   *
   * @param playerName Exact player name.
   * @param checkType Check type to remove data for, null is regarded as ALL.
   * @return If any data was present.
   */
  public static boolean removeData(final String playerName, CheckType checkType) {
    if (checkType == null) checkType = CheckType.ALL;
    boolean had = false;

    // Check extended registered components.
    if (clearComponentData(checkType, playerName)) had = true;

    // Collect factories.
    final Set<CheckDataFactory> factories = new HashSet<CheckDataFactory>();
    for (CheckType otherType : APIUtils.getWithChildren(checkType)) {
      final CheckDataFactory otherFactory = otherType.getDataFactory();
      if (otherFactory != null) factories.add(otherFactory);
    }
    // Remove data.
    for (final CheckDataFactory otherFactory : factories) {
      if (otherFactory.removeData(playerName) != null) had = true;
    }

    return had;
  }