From 94de00f278ad4b8f8a7b498d95f35b44b365b80a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 5 Feb 2015 20:24:07 +1100 Subject: [PATCH] fixes --- .../plot/commands/DebugExec.java | 3 +- .../plot/commands/Trim.java | 4 +-- .../plot/generator/HybridPop.java | 1 - .../plot/listeners/PlayerEvents.java | 2 +- .../plot/util/ExpireManager.java | 32 ++++++++++++------- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 195c97059..ff4bfc5a6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -74,8 +74,9 @@ public class DebugExec extends SubCommand { if (world == null) { return PlayerFunctions.sendMessage(null, "Invalid world: "+args[1]); } + PlayerFunctions.sendMessage(null, "Updating expired plot list"); ExpireManager.updateExpired(args[1]); - return PlayerFunctions.sendMessage(null, "Updating expired plot list"); + return true; } return PlayerFunctions.sendMessage(null, "Use /plot debugexec update-expired "); case "show-expired": 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 6088a5dd6..096f4a49d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -165,15 +165,13 @@ public class Trim extends SubCommand { } } 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.iterator().next(); - boolean modified = false; if (plot.hasOwner()) { - modified = HybridPlotManager.checkModified(plot, 0); + HybridPlotManager.checkModified(plot, 0); } if (plot.owner == null || !HybridPlotManager.checkModified(plot, plotworld.REQUIRED_CHANGES)) { PlotMain.removePlot(worldname, plot.id, true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index 0e8bedcaf..4d09481e6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -118,7 +118,6 @@ public class HybridPop extends BlockPopulator { @Override public void populate(final World w, final Random r, final Chunk c) { - // initializing with bedrock pre-made int cx = c.getX(), cz = c.getZ(); if (doState) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 0a5685b78..b0b511452 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -882,7 +882,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = (Player) d; final boolean aPlr = a instanceof Player; final PlotWorld pW = getPlotWorld(l.getWorld()); - if (!aPlr && pW.PVE && (!(a instanceof ItemFrame))) { + if (!aPlr && pW.PVE && (!(a instanceof ItemFrame) && !(a.getEntityId() == 416) ) ) { return; } else if (aPlr && pW.PVP) { return; 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 82dd5b36b..64d47d602 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -1,7 +1,6 @@ package com.intellectualcrafters.plot.util; import java.io.File; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -24,28 +23,40 @@ import com.intellectualcrafters.plot.object.PlotManager; public class ExpireManager { - private static long timestamp = 0; public static ConcurrentHashMap> expiredPlots = new ConcurrentHashMap<>(); public static ConcurrentHashMap updatingPlots = new ConcurrentHashMap<>(); + public static ConcurrentHashMap timestamp = new ConcurrentHashMap<>(); public static int task; - public static void updateExpired(final String world) { + public static long getTimeStamp(final String world) { + if (timestamp.containsKey(world)) { + return timestamp.get(world); + } + else { + timestamp.put(world, 0l); + return 0; + } + } + + public static boolean updateExpired(final String world) { updatingPlots.put(world, true); long now = System.currentTimeMillis(); - if (now > timestamp) { - timestamp = now + 86400000; + if (now > getTimeStamp(world)) { + timestamp.put(world, now + 86400000l); TaskManager.runTask(new Runnable() { @Override public void run() { HashMap plots = getOldPlots(world); - PlotMain.sendConsoleSenderMessage("&cFound " + plots.size() + " expired plots!"); + PlotMain.sendConsoleSenderMessage("&cFound " + plots.size() + " expired plots for " + world + "!"); expiredPlots.put(world, plots); updatingPlots.put(world, false); } }); + return true; } else { updatingPlots.put(world, false); + return false; } } @@ -67,8 +78,10 @@ public class ExpireManager { } Set plots = expiredPlots.get(world).keySet(); if (plots == null || plots.size() == 0) { - updateExpired(world); - return; + if (updateExpired(world)) { + return; + } + continue; } Plot plot = plots.iterator().next(); if (plot.owner != null) { @@ -87,14 +100,12 @@ public class ExpireManager { event.setCancelled(true); return; } - for (UUID helper : plot.helpers) { Player player = UUIDHandler.uuidWrapper.getPlayer(helper); if (player != null) { PlayerFunctions.sendMessage(player, C.PLOT_REMOVED_HELPER, plot.id.toString()); } } - final World worldobj = Bukkit.getWorld(world); final PlotManager manager = PlotMain.getPlotManager(world); manager.clearPlot(worldobj, plot, false); @@ -112,7 +123,6 @@ public class ExpireManager { } return; } - } }, 2400, 2400); }