mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-03 15:43:37 +01:00
Make sure chunk unload queue is processed quickly enough on MCPC
This commit is contained in:
parent
bee16ef331
commit
0d25fd2edc
@ -109,5 +109,5 @@ public abstract class BukkitVersionHelper {
|
|||||||
/**
|
/**
|
||||||
* Unload chunk no save needed
|
* Unload chunk no save needed
|
||||||
*/
|
*/
|
||||||
public abstract void unloadChunkNoSave(World w, int cx, int cz);
|
public abstract void unloadChunkNoSave(World w, Chunk c, int cx, int cz);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class BukkitVersionHelperBukkitForge extends BukkitVersionHelperGeneric {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void unloadChunkNoSave(World w, int cx, int cz) {
|
public void unloadChunkNoSave(World w, Chunk c, int cx, int cz) {
|
||||||
w.unloadChunkRequest(cx, cz);
|
w.unloadChunkRequest(cx, cz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
package org.dynmap.bukkit;
|
package org.dynmap.bukkit;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.ChunkSnapshot;
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.dynmap.Log;
|
import org.dynmap.Log;
|
||||||
@ -94,7 +90,8 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
|||||||
nmst_z = getField(nms_tileentity, new String[] { "z" }, int.class);
|
nmst_z = getField(nms_tileentity, new String[] { "z" }, int.class);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void unloadChunkNoSave(World w, int cx, int cz) {
|
public void unloadChunkNoSave(World w, Chunk c, int cx, int cz) {
|
||||||
|
this.removeEntitiesFromChunk(c);
|
||||||
w.unloadChunk(cx, cz, false, false);
|
w.unloadChunk(cx, cz, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
|||||||
failed = true;
|
failed = true;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
private Object getFieldValue(Object obj, Field field, Object def) {
|
protected Object getFieldValue(Object obj, Field field, Object def) {
|
||||||
if((obj != null) && (field != null)) {
|
if((obj != null) && (field != null)) {
|
||||||
try {
|
try {
|
||||||
return field.get(obj);
|
return field.get(obj);
|
||||||
|
@ -16,6 +16,9 @@ import org.dynmap.Log;
|
|||||||
* Helper for isolation of bukkit version specific issues
|
* Helper for isolation of bukkit version specific issues
|
||||||
*/
|
*/
|
||||||
public class BukkitVersionHelperMCPC extends BukkitVersionHelperGeneric {
|
public class BukkitVersionHelperMCPC extends BukkitVersionHelperGeneric {
|
||||||
|
private Method cps_unload100;
|
||||||
|
private int cnt;
|
||||||
|
|
||||||
BukkitVersionHelperMCPC() {
|
BukkitVersionHelperMCPC() {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@ -69,6 +72,8 @@ public class BukkitVersionHelperMCPC extends BukkitVersionHelperGeneric {
|
|||||||
if(cps_unloadqueue == null) {
|
if(cps_unloadqueue == null) {
|
||||||
Log.info("Unload queue not found - default to unload all chunks");
|
Log.info("Unload queue not found - default to unload all chunks");
|
||||||
}
|
}
|
||||||
|
cps_unload100 = getMethod(chunkprovserver, new String[] { "b" }, new Class[0]);
|
||||||
|
|
||||||
nmsc_removeentities = getMethod(nmschunk, new String[] { "d" }, new Class[0]);
|
nmsc_removeentities = getMethod(nmschunk, new String[] { "d" }, new Class[0]);
|
||||||
nmsc_tileentities = getField(nmschunk, new String[] { "i" }, Map.class);
|
nmsc_tileentities = getField(nmschunk, new String[] { "i" }, Map.class);
|
||||||
/* nbt */
|
/* nbt */
|
||||||
@ -89,7 +94,23 @@ public class BukkitVersionHelperMCPC extends BukkitVersionHelperGeneric {
|
|||||||
nmst_z = getField(nms_tileentity, new String[] { "n" }, int.class);
|
nmst_z = getField(nms_tileentity, new String[] { "n" }, int.class);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void unloadChunkNoSave(World w, int cx, int cz) {
|
public void unloadChunkNoSave(World w, Chunk c, int cx, int cz) {
|
||||||
w.unloadChunkRequest(cx, cz);
|
w.unloadChunkRequest(cx, cz);
|
||||||
|
cnt++;
|
||||||
|
if(cnt > 20) {
|
||||||
|
cnt = 0;
|
||||||
|
Object nmsw = this.getNMSWorld(w);
|
||||||
|
if((nmsw != null) && (cps_unload100 != null)) {
|
||||||
|
Object cps = getFieldValue(nmsw, nmsw_chunkproviderserver, null); // Get chunkproviderserver
|
||||||
|
if(cps != null) {
|
||||||
|
try {
|
||||||
|
this.cps_unload100.invoke(cps, new Object[0]);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -935,16 +935,13 @@ public class NewMapChunkCache implements MapChunkCache {
|
|||||||
/* If wasn't loaded before, we need to do unload */
|
/* If wasn't loaded before, we need to do unload */
|
||||||
if (!wasLoaded) {
|
if (!wasLoaded) {
|
||||||
chunks_read++;
|
chunks_read++;
|
||||||
/* It looks like bukkit "leaks" entities - they don't get removed from the world-level table
|
|
||||||
* when chunks are unloaded but not saved - removing them seems to do the trick */
|
|
||||||
helper.removeEntitiesFromChunk(c);
|
|
||||||
/* Since we only remember ones we loaded, and we're synchronous, no player has
|
/* Since we only remember ones we loaded, and we're synchronous, no player has
|
||||||
* moved, so it must be safe (also prevent chunk leak, which appears to happen
|
* moved, so it must be safe (also prevent chunk leak, which appears to happen
|
||||||
* because isChunkInUse defined "in use" as being within 256 blocks of a player,
|
* because isChunkInUse defined "in use" as being within 256 blocks of a player,
|
||||||
* while the actual in-use chunk area for a player where the chunks are managed
|
* while the actual in-use chunk area for a player where the chunks are managed
|
||||||
* by the MC base server is 21x21 (or about a 160 block radius).
|
* by the MC base server is 21x21 (or about a 160 block radius).
|
||||||
* Also, if we did generate it, need to save it */
|
* Also, if we did generate it, need to save it */
|
||||||
helper.unloadChunkNoSave(w, chunk.x, chunk.z);
|
helper.unloadChunkNoSave(w, c, chunk.x, chunk.z);
|
||||||
}
|
}
|
||||||
else if (isunloadpending) { /* Else, if loaded and unload is pending */
|
else if (isunloadpending) { /* Else, if loaded and unload is pending */
|
||||||
w.unloadChunkRequest(chunk.x, chunk.z); /* Request new unload */
|
w.unloadChunkRequest(chunk.x, chunk.z); /* Request new unload */
|
||||||
|
Loading…
Reference in New Issue
Block a user