diff --git a/src/main/java/com/gmail/nossr50/datatypes/InactiveChunk.java b/src/main/java/com/gmail/nossr50/datatypes/InactiveChunk.java deleted file mode 100755 index d58a4d332..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/InactiveChunk.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.gmail.nossr50.datatypes; - -import org.bukkit.Chunk; - -public class InactiveChunk { - public Chunk chunk; - public int inactiveTime = 0; - - public InactiveChunk(Chunk chunk, int inactiveTime) { - this.chunk = chunk; - this.inactiveTime = inactiveTime; - } - - public InactiveChunk(Chunk chunk) { - this(chunk, 0); - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index bf140f5b2..3a450fc27 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -69,7 +69,6 @@ import com.gmail.nossr50.listeners.WorldListener; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.runnables.BleedTimer; -import com.gmail.nossr50.runnables.ChunkletUnloader; import com.gmail.nossr50.runnables.MobStoreCleaner; import com.gmail.nossr50.runnables.SaveTimer; import com.gmail.nossr50.runnables.SkillMonitor; @@ -198,8 +197,6 @@ public class mcMMO extends JavaPlugin { scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20); //Bleed timer (Runs every two seconds) scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 0, 40); - //Chunklet unloader (Runs every 20 seconds by default) - scheduler.scheduleSyncRepeatingTask(this, new ChunkletUnloader(), 0, ChunkletUnloader.RUN_INTERVAL * 20); //Old & Powerless User remover int purgeInterval = Config.getInstance().getPurgeInterval(); diff --git a/src/main/java/com/gmail/nossr50/runnables/ChunkletUnloader.java b/src/main/java/com/gmail/nossr50/runnables/ChunkletUnloader.java deleted file mode 100644 index 03de4d957..000000000 --- a/src/main/java/com/gmail/nossr50/runnables/ChunkletUnloader.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.gmail.nossr50.runnables; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import org.bukkit.Chunk; -import org.bukkit.World; - -import com.gmail.nossr50.datatypes.InactiveChunk; -import com.gmail.nossr50.mcMMO; - -public class ChunkletUnloader implements Runnable { - private static Map unloadedChunks = new HashMap(); - private static int minimumInactiveTime = 60; //Should be a multiple of RUN_INTERVAL for best performance - public static final int RUN_INTERVAL = 20; - - public static void addToList(Chunk chunk) { - if (chunk == null || chunk.getWorld() == null) - return; - - String key = chunk.getWorld().getName() + "," + chunk.getX() + "," + chunk.getZ(); - - if (unloadedChunks.containsKey(key)) - return; - - unloadedChunks.put(key, new InactiveChunk(chunk)); - } - - public static void addToList(int cx, int cz, World world) { - addToList(world.getChunkAt(cx, cz)); - } - - @Override - public void run() { - for (Iterator> unloadedChunkIterator = unloadedChunks.entrySet().iterator() ; unloadedChunkIterator.hasNext() ; ) { - Entry entry = unloadedChunkIterator.next(); - - if (entry.getKey() == null || entry.getValue() == null) { - unloadedChunkIterator.remove(); - continue; - } - - if (entry.getValue().chunk == null) { - unloadedChunkIterator.remove(); - continue; - } - - Chunk chunk = entry.getValue().chunk; - - if (!chunk.isLoaded()) { - int inactiveTime = entry.getValue().inactiveTime + RUN_INTERVAL; - - //Chunklets are unloaded only if their chunk has been unloaded for minimumInactiveTime - if (inactiveTime >= minimumInactiveTime) { - if (mcMMO.placeStore == null) - return; - - mcMMO.placeStore.unloadChunk(chunk.getX(), chunk.getZ(), chunk.getWorld()); - unloadedChunkIterator.remove(); - continue; - } - - entry.getValue().inactiveTime = inactiveTime; - } - else { - //Just remove the entry if the chunk has been reloaded. - unloadedChunkIterator.remove(); - } - } - } -} diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java index 1b0d7f53b..c97af7c02 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java @@ -15,8 +15,6 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.block.Block; -import com.gmail.nossr50.runnables.ChunkletUnloader; - public class HashChunkletManager implements ChunkletManager { public HashMap store = new HashMap(); @@ -99,7 +97,7 @@ public class HashChunkletManager implements ChunkletManager { @Override public void chunkUnloaded(int cx, int cz, World world) { - ChunkletUnloader.addToList(cx, cx, world); + unloadChunk(cx, cx, world); } @Override