From 4300f0b7ab5b08fb7c02c87d9ce60a12f2f39a45 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Fri, 10 Jun 2016 01:14:06 -0500 Subject: [PATCH] Update for 1.10 - make workaround for Spigot API permanent --- .../dynmap/bukkit/BukkitVersionHelperCB.java | 30 +++++++++++++++---- .../bukkit/BukkitVersionHelperGeneric.java | 1 + 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/dynmap/bukkit/BukkitVersionHelperCB.java b/src/main/java/org/dynmap/bukkit/BukkitVersionHelperCB.java index 89a3d07c..d6f0b498 100644 --- a/src/main/java/org/dynmap/bukkit/BukkitVersionHelperCB.java +++ b/src/main/java/org/dynmap/bukkit/BukkitVersionHelperCB.java @@ -5,6 +5,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Map; +import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.Chunk; @@ -12,6 +13,7 @@ import org.bukkit.Server; import org.bukkit.World; import org.dynmap.Log; import org.dynmap.common.BiomeMap; +import org.dynmap.hdmap.HDBlockModels; import org.dynmap.utils.Polygon; /** @@ -36,7 +38,16 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric { private boolean isBadUnload = false; 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 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 }); } else { - longhashset = getOBCClass("org.bukkit.craftbukkit.util.LongHashset"); - lhs_containskey = getMethod(longhashset, new String[] { "containsKey" }, new Class[] { int.class, int.class }); + longhashset = getOBCClassNoFail("org.bukkit.craftbukkit.util.LongHashset"); + if (longhashset != null) { + lhs_containskey = getMethod(longhashset, new String[] { "containsKey" }, new Class[] { int.class, int.class }); + } } - cps_unloadqueue = getFieldNoFail(chunkprovserver, new String[] { "unloadQueue" }, longhashset); + cps_unloadqueue_isSet = false; + if (longhashset != null) { + 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) { Log.info("Unload queue not found - default to unload all chunks"); } /** n.m.s.Chunk */ nmschunk = getNMSClass("net.minecraft.server.Chunk"); 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) { Log.info("inhabitedTicks field not found - inhabited shader not functional"); } diff --git a/src/main/java/org/dynmap/bukkit/BukkitVersionHelperGeneric.java b/src/main/java/org/dynmap/bukkit/BukkitVersionHelperGeneric.java index 2a4309ce..0d9173aa 100644 --- a/src/main/java/org/dynmap/bukkit/BukkitVersionHelperGeneric.java +++ b/src/main/java/org/dynmap/bukkit/BukkitVersionHelperGeneric.java @@ -51,6 +51,7 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper { protected Class longhashset; protected Field nmsw_chunkproviderserver; protected Field cps_unloadqueue; + protected boolean cps_unloadqueue_isSet; protected Method lhs_containskey; /** n.m.s.Chunk */ protected Class nmschunk;