This commit is contained in:
boy0001 2015-02-05 20:24:07 +11:00
parent c306ae32cc
commit 94de00f278
5 changed files with 25 additions and 17 deletions

View File

@ -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 <world>");
case "show-expired":

View File

@ -165,15 +165,13 @@ public class Trim extends SubCommand {
}
}
final Set<Plot> 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);

View File

@ -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) {

View File

@ -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;

View File

@ -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<String, HashMap<Plot, Long>> expiredPlots = new ConcurrentHashMap<>();
public static ConcurrentHashMap<String, Boolean> updatingPlots = new ConcurrentHashMap<>();
public static ConcurrentHashMap<String, Long> 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<Plot, Long> 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,9 +78,11 @@ public class ExpireManager {
}
Set<Plot> plots = expiredPlots.get(world).keySet();
if (plots == null || plots.size() == 0) {
updateExpired(world);
if (updateExpired(world)) {
return;
}
continue;
}
Plot plot = plots.iterator().next();
if (plot.owner != null) {
if (UUIDHandler.uuidWrapper.getPlayer(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);
}