diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index a3ab1275a..3210ea27d 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.6.3 + 2.6.4 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java index 46fe45187..6088a5dd6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -48,6 +48,7 @@ import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; @@ -113,37 +114,6 @@ public class Trim extends SubCommand { return false; } - public ArrayList getOldPlots(String world) { - final Collection plots = PlotMain.getPlots(world).values(); - final ArrayList toRemove = new ArrayList<>(); - Set remove = new HashSet<>(); - Set keep = new HashSet<>(); - for (Plot plot : plots) { - UUID uuid = plot.owner; - if (uuid == null || remove.contains(uuid)) { - toRemove.add(plot); - continue; - } - if (keep.contains(uuid)) { - continue; - } - OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); - if (!op.hasPlayedBefore()) { - toRemove.add(plot); - PlotMain.removePlot(plot.world, plot.id, true); - continue; - } - long last = op.getLastPlayed(); - long compared = System.currentTimeMillis() - last; - if (TimeUnit.MILLISECONDS.toDays(compared) >= Settings.AUTO_CLEAR_DAYS) { - toRemove.add(plot); - remove.add(uuid); - } - keep.add(uuid); - } - return toRemove; - } - public boolean runTrimTask(final World world) { if (Trim.TASK) { return false; @@ -194,13 +164,13 @@ public class Trim extends SubCommand { } } } - final ArrayList plots = getOldPlots(world.getName()); + final Set plots = ExpireManager.getOldPlots(world.getName()).keySet(); int count2 = 0; Trim.TASK_ID = Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotMain.getMain(), new Runnable() { @Override public void run() { if (manager != null && plots.size() > 0) { - Plot plot = plots.get(0); + Plot plot = plots.iterator().next(); boolean modified = false; if (plot.hasOwner()) { modified = HybridPlotManager.checkModified(plot, 0); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java index 185501830..58fc1154b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -123,7 +123,7 @@ public class Settings { * Days until a plot gets cleared */ public static int AUTO_CLEAR_DAYS = 360; - public static boolean AUTO_CLEAR_CHECK_DISK = true; + public static boolean AUTO_CLEAR_CHECK_DISK = false; public static int MIN_BLOCKS_CHANGED = -1; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index 7804ea281..82dd5b36b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -124,7 +124,7 @@ public class ExpireManager { if (op.hasPlayedBefore()) { long last = op.getLastPlayed(); long compared = System.currentTimeMillis() - last; - if (compared >= 86400000 * Settings.AUTO_CLEAR_DAYS) { + if (compared >= 86400000l * Settings.AUTO_CLEAR_DAYS) { return true; } } @@ -140,7 +140,14 @@ public class ExpireManager { for (Plot plot : plots) { UUID uuid = plot.owner; if (uuid == null || remove.containsKey(uuid)) { - toRemove.put(plot, remove.get(uuid)); + Long stamp; + if (uuid == null) { + stamp = 0l; + } + else { + stamp = remove.get(uuid); + } + toRemove.put(plot, stamp); continue; } if (keep.contains(uuid)) { @@ -157,7 +164,7 @@ public class ExpireManager { } long last = op.getLastPlayed(); long compared = System.currentTimeMillis() - last; - if (compared >= 86400000 * Settings.AUTO_CLEAR_DAYS) { + if (compared >= 86400000l * Settings.AUTO_CLEAR_DAYS) { if (Settings.AUTO_CLEAR_CHECK_DISK) { String worldname = Bukkit.getWorlds().get(0).getName(); String foldername; @@ -187,7 +194,7 @@ public class ExpireManager { try { last = playerFile.lastModified(); compared = System.currentTimeMillis() - last; - if (compared < 86400000 * Settings.AUTO_CLEAR_DAYS) { + if (compared < 86400000l * Settings.AUTO_CLEAR_DAYS) { keep.add(uuid); continue; } @@ -200,6 +207,7 @@ public class ExpireManager { } toRemove.put(plot, last); remove.put(uuid, last); + continue; } keep.add(uuid); }