Removing ChunkletUnloader and dependents, since they are no longer necessary.

This commit is contained in:
Glitchfinder 2013-01-18 15:39:02 -08:00
parent 00f24fd5bd
commit b424ecfd3e
4 changed files with 1 additions and 96 deletions

View File

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

View File

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

View File

@ -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<String, InactiveChunk> unloadedChunks = new HashMap<String, InactiveChunk>();
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<Entry<String, InactiveChunk>> unloadedChunkIterator = unloadedChunks.entrySet().iterator() ; unloadedChunkIterator.hasNext() ; ) {
Entry<String, InactiveChunk> 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();
}
}
}
}

View File

@ -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<String, ChunkletStore> store = new HashMap<String, ChunkletStore>();
@ -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