public static List<Plot> getOldPlots(final String world) {
   final ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlots(world).values());
   final List<Plot> toRemove = new ArrayList<>();
   Iterator<Plot> iter = plots.iterator();
   while (iter.hasNext()) {
     Plot plot = iter.next();
     final Flag keepFlag = FlagManager.getPlotFlag(plot, "keep");
     if (keepFlag != null && (Boolean) keepFlag.getValue()) {
       continue;
     }
     final UUID uuid = plot.owner;
     if (uuid == null) {
       toRemove.add(plot);
       continue;
     }
     final PlotPlayer player = UUIDHandler.getPlayer(uuid);
     if (player != null) {
       continue;
     }
     if (isExpired(plot)) {
       toRemove.add(plot);
     }
   }
   return toRemove;
 }
 public static boolean isExpired(final UUID uuid) {
   if (UUIDHandler.getPlayer(uuid) != null) {
     return false;
   }
   final String name = UUIDHandler.getName(uuid);
   if (name != null) {
     long last;
     if (dates.contains(uuid)) {
       last = dates.get(uuid);
     } else {
       final OfflinePlayer op = Bukkit.getOfflinePlayer(name);
       if (op.hasPlayedBefore()) {
         last = op.getLastPlayed();
         dates.put(uuid, last);
       } else {
         return false;
       }
     }
     if (last == 0) {
       return false;
     }
     final long compared = System.currentTimeMillis() - last;
     if (compared >= (86400000l * Settings.AUTO_CLEAR_DAYS)) {
       return true;
     }
   }
   return false;
 }
Example #3
0
 public static void getPersistentMeta(UUID uuid, String key, RunnableVal<byte[]> result) {
   PlotPlayer player = UUIDHandler.getPlayer(uuid);
   if (player != null) {
     result.run(player.getPersistentMeta(key));
   } else {
     DBFunc.getPersistentMeta(
         uuid,
         new RunnableVal<Map<String, byte[]>>() {
           @Override
           public void run(Map<String, byte[]> value) {
             result.run(value.get(key));
           }
         });
   }
 }