Update for 1.10 - make workaround for Spigot API permanent

This commit is contained in:
Mike Primm 2016-06-10 01:14:06 -05:00
parent 95ba9b9521
commit 4300f0b7ab
2 changed files with 26 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -12,6 +13,7 @@ import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.dynmap.Log; import org.dynmap.Log;
import org.dynmap.common.BiomeMap; import org.dynmap.common.BiomeMap;
import org.dynmap.hdmap.HDBlockModels;
import org.dynmap.utils.Polygon; import org.dynmap.utils.Polygon;
/** /**
@ -36,7 +38,16 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
private boolean isBadUnload = false; private boolean isBadUnload = false;
BukkitVersionHelperCB() { BukkitVersionHelperCB() {
isBadUnload = Bukkit.getServer().getBukkitVersion().contains("1.9"); String bukkitver = DynmapPlugin.plugin.getServer().getVersion();
String mcver = "1.0.0";
int idx = bukkitver.indexOf("(MC: ");
if(idx > 0) {
mcver = bukkitver.substring(idx+5);
idx = mcver.indexOf(")");
if(idx > 0) mcver = mcver.substring(0, idx);
}
isBadUnload = HDBlockModels.checkVersionRange(mcver, "1.9-");
Log.verboseinfo("MCVER=" + mcver + ", isBadUnload=" + isBadUnload);
} }
@Override @Override
protected String getNMSPackage() { protected String getNMSPackage() {
@ -94,18 +105,27 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
lhs_containskey = getMethod(longhashset, new String[] { "contains" }, new Class[] { int.class, int.class }); lhs_containskey = getMethod(longhashset, new String[] { "contains" }, new Class[] { int.class, int.class });
} }
else { else {
longhashset = getOBCClass("org.bukkit.craftbukkit.util.LongHashset"); longhashset = getOBCClassNoFail("org.bukkit.craftbukkit.util.LongHashset");
if (longhashset != null) {
lhs_containskey = getMethod(longhashset, new String[] { "containsKey" }, new Class[] { int.class, int.class }); lhs_containskey = getMethod(longhashset, new String[] { "containsKey" }, new Class[] { int.class, int.class });
} }
}
cps_unloadqueue_isSet = false;
if (longhashset != null) {
cps_unloadqueue = getFieldNoFail(chunkprovserver, new String[] { "unloadQueue" }, longhashset); cps_unloadqueue = getFieldNoFail(chunkprovserver, new String[] { "unloadQueue" }, longhashset);
}
if(cps_unloadqueue == null) {
cps_unloadqueue = getFieldNoFail(chunkprovserver, new String[] { "unloadQueue" }, Set.class);
cps_unloadqueue_isSet = true;
}
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");
} }
/** n.m.s.Chunk */ /** n.m.s.Chunk */
nmschunk = getNMSClass("net.minecraft.server.Chunk"); nmschunk = getNMSClass("net.minecraft.server.Chunk");
nmsc_tileentities = getField(nmschunk, new String[] { "tileEntities" }, Map.class); nmsc_tileentities = getField(nmschunk, new String[] { "tileEntities" }, Map.class);
nmsc_inhabitedticks = getPrivateFieldNoFail(nmschunk, new String[] { "s", "q", "u", "v" }, long.class); nmsc_inhabitedticks = getPrivateFieldNoFail(nmschunk, new String[] { "s", "q", "u", "v", "w" }, long.class);
if (nmsc_inhabitedticks == null) { if (nmsc_inhabitedticks == null) {
Log.info("inhabitedTicks field not found - inhabited shader not functional"); Log.info("inhabitedTicks field not found - inhabited shader not functional");
} }

View File

@ -51,6 +51,7 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
protected Class<?> longhashset; protected Class<?> longhashset;
protected Field nmsw_chunkproviderserver; protected Field nmsw_chunkproviderserver;
protected Field cps_unloadqueue; protected Field cps_unloadqueue;
protected boolean cps_unloadqueue_isSet;
protected Method lhs_containskey; protected Method lhs_containskey;
/** n.m.s.Chunk */ /** n.m.s.Chunk */
protected Class<?> nmschunk; protected Class<?> nmschunk;