示例#1
0
 static {
   final Map<CheckType, Set<CheckType>> map = new HashMap<CheckType, Set<CheckType>>();
   for (final CheckType type : CheckType.values()) map.put(type, new HashSet<CheckType>());
   for (final CheckType type : CheckType.values())
     for (final CheckType other : CheckType.values())
       if (isParent(other, type)) map.get(other).add(type);
   for (final CheckType parent : map.keySet())
     childrenMap.put(parent, map.get(parent).toArray(new CheckType[] {}));
 }
示例#2
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();
   }
 }
 /** Remove all exemptions. */
 public static final void clear() {
   // Use put with a new map to keep entries to stay thread safe.
   for (final CheckType checkType : CheckType.values()) {
     if (APIUtils.needsSynchronization(checkType)) {
       exempted.put(checkType, Collections.synchronizedSet(new HashSet<UUID>()));
     } else {
       exempted.put(checkType, new HashSet<UUID>());
     }
   }
 }
示例#4
0
 /**
  * Match for CheckType, some smart method, to also match after first "_" for convenience of input.
  *
  * @param input
  * @return
  */
 public static List<String> getCheckTypeTabMatches(final String input) {
   final String ref = input.toUpperCase().replace('-', '_').replace('.', '_');
   final List<String> res = new ArrayList<String>();
   for (final CheckType checkType : CheckType.values()) {
     final String name = checkType.name();
     if (name.startsWith(ref)) {
       res.add(name);
     }
   }
   if (ref.indexOf('_') == -1) {
     for (final CheckType checkType : CheckType.values()) {
       final String name = checkType.name();
       final String[] split = name.split("_", 2);
       if (split.length > 1 && split[1].startsWith(ref)) {
         res.add(name);
       }
     }
   }
   if (!res.isEmpty()) {
     Collections.sort(res);
     return res;
   }
   return null;
 }