mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 11:15:21 +01:00
Add BukkitForge handler - doesn't work right due to BukkitForge API bugs
This commit is contained in:
parent
55a5aacfce
commit
e57634ebb3
@ -25,6 +25,10 @@ public abstract class BukkitVersionHelper {
|
||||
Log.info("Loader version helper for MCPC");
|
||||
helper = new BukkitVersionHelperMCPC();
|
||||
}
|
||||
else if(Bukkit.getServer().getVersion().contains("BukkitForge")) {
|
||||
Log.info("Loader version helper for BukkitForge");
|
||||
helper = new BukkitVersionHelperBukkitForge();
|
||||
}
|
||||
else {
|
||||
helper = new BukkitVersionHelperCB();
|
||||
}
|
||||
|
@ -0,0 +1,99 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.Log;
|
||||
|
||||
/**
|
||||
* Helper for isolation of bukkit version specific issues
|
||||
*/
|
||||
public class BukkitVersionHelperBukkitForge extends BukkitVersionHelperGeneric {
|
||||
BukkitVersionHelperBukkitForge() {
|
||||
}
|
||||
@Override
|
||||
protected String getNMSPackage() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
protected void loadNMS() {
|
||||
/* biomebase */
|
||||
biomebase = getNMSClass("yy");
|
||||
biomebasearray = getNMSClass("[Lyy;");
|
||||
/* world */
|
||||
nmsworld = getNMSClass("in");
|
||||
/* chunk */
|
||||
chunkprovserver = getNMSClass("im");
|
||||
nmschunk = getNMSClass("zz");
|
||||
/* nbt */
|
||||
nbttagcompound = getNMSClass("bq");
|
||||
nbttagbyte = getNMSClass("bp");
|
||||
nbttagshort = getNMSClass("cb");
|
||||
nbttagint = getNMSClass("bx");
|
||||
nbttaglong = getNMSClass("bz");
|
||||
nbttagfloat = getNMSClass("bv");
|
||||
nbttagdouble = getNMSClass("bt");
|
||||
nbttagbytearray = getNMSClass("bo");
|
||||
nbttagstring = getNMSClass("cc");
|
||||
nbttagintarray = getNMSClass("bw");
|
||||
/* tileentity */
|
||||
nms_tileentity = getNMSClass("any");
|
||||
|
||||
/** Set up NMS fields **/
|
||||
/* biomebase */
|
||||
biomebaselist = getField(biomebase, new String[] { "a" }, biomebasearray);
|
||||
biomebasetemp = getField(biomebase, new String[] { "F" }, float.class);
|
||||
biomebasehumi = getField(biomebase, new String[] { "G" }, float.class);
|
||||
biomebaseidstring = getField(biomebase, new String[] { "y" }, String.class);
|
||||
biomebaseid = getField(biomebase, new String[] { "N" }, int.class);
|
||||
/* chunk */
|
||||
nmsw_chunkproviderserver = getField(nmsworld, new String[] { "b" }, chunkprovserver);
|
||||
cps_unloadqueue = getFieldNoFail(chunkprovserver, new String[] { "b" }, longhashset);
|
||||
if(cps_unloadqueue == null) {
|
||||
Log.info("Unload queue not found - default to unload all chunks");
|
||||
}
|
||||
nmsc_removeentities = getMethod(nmschunk, new String[] { "d" }, new Class[0]);
|
||||
nmsc_tileentities = getField(nmschunk, new String[] { "i" }, Map.class);
|
||||
/* nbt */
|
||||
compound_get = getMethod(nbttagcompound, new String[] { "a" }, new Class[] { String.class });
|
||||
nbttagbyte_val = getField(nbttagbyte, new String[] { "a" }, byte.class);
|
||||
nbttagshort_val = getField(nbttagshort, new String[] { "a" }, short.class);
|
||||
nbttagint_val = getField(nbttagint, new String[] { "a" }, int.class);
|
||||
nbttaglong_val = getField(nbttaglong, new String[] { "a" }, long.class);
|
||||
nbttagfloat_val = getField(nbttagfloat, new String[] { "a" }, float.class);
|
||||
nbttagdouble_val = getField(nbttagdouble, new String[] { "a" }, double.class);
|
||||
nbttagbytearray_val = getField(nbttagbytearray, new String[] { "a" }, byte[].class);
|
||||
nbttagstring_val = getField(nbttagstring, new String[] { "a" }, String.class);
|
||||
nbttagintarray_val = getField(nbttagintarray, new String[] { "a" }, int[].class);
|
||||
/* tileentity */
|
||||
nmst_readnbt = getMethod(nms_tileentity, new String[] { "b" }, new Class[] { nbttagcompound });
|
||||
nmst_x = getField(nms_tileentity, new String[] { "l" }, int.class);
|
||||
nmst_y = getField(nms_tileentity, new String[] { "m" }, int.class);
|
||||
nmst_z = getField(nms_tileentity, new String[] { "n" }, int.class);
|
||||
}
|
||||
|
||||
private static long chunkXZ2Int(int par0, int par1)
|
||||
{
|
||||
return (long)par0 & 4294967295L | ((long)par1 & 4294967295L) << 32;
|
||||
}
|
||||
|
||||
/* For testing unload queue for presence of givne chunk */
|
||||
@Override
|
||||
public boolean isInUnloadQueue(Object unloadqueue, int x, int z) {
|
||||
if(unloadqueue != null) {
|
||||
Set uq = (Set)unloadqueue;
|
||||
return uq.contains(Long.valueOf(chunkXZ2Int(x, z)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -46,6 +46,16 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
nmsworld = getNMSClass("net.minecraft.server.WorldServer");
|
||||
chunkprovserver = getNMSClass("net.minecraft.server.ChunkProviderServer");
|
||||
nmsw_chunkproviderserver = getField(nmsworld, new String[] { "chunkProviderServer" }, chunkprovserver);
|
||||
|
||||
longhashset = getOBCClassNoFail("org.bukkit.craftbukkit.util.LongHashSet");
|
||||
if(longhashset != null) {
|
||||
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 });
|
||||
}
|
||||
|
||||
cps_unloadqueue = getFieldNoFail(chunkprovserver, new String[] { "unloadQueue" }, longhashset);
|
||||
if(cps_unloadqueue == null) {
|
||||
Log.info("Unload queue not found - default to unload all chunks");
|
||||
|
@ -92,14 +92,6 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
/* Craftworld fields */
|
||||
craftworld = getOBCClass("org.bukkit.craftbukkit.CraftWorld");
|
||||
cw_gethandle = getMethod(craftworld, new String[] { "getHandle" }, new Class[0]);
|
||||
longhashset = getOBCClassNoFail("org.bukkit.craftbukkit.util.LongHashSet");
|
||||
if(longhashset != null) {
|
||||
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 });
|
||||
}
|
||||
/* CraftChunkSnapshot */
|
||||
craftchunksnapshot = getOBCClass("org.bukkit.craftbukkit.CraftChunkSnapshot");
|
||||
ccss_biome = getPrivateField(craftchunksnapshot, new String[] { "biome" }, biomebasearray);
|
||||
|
@ -45,7 +45,17 @@ public class BukkitVersionHelperMCPC extends BukkitVersionHelperGeneric {
|
||||
nbttagintarray = getNMSClass("bw");
|
||||
/* tileentity */
|
||||
nms_tileentity = getNMSClass("any");
|
||||
|
||||
|
||||
/* Get unload queue classes */
|
||||
longhashset = getOBCClassNoFail("org.bukkit.craftbukkit.util.LongHashSet");
|
||||
if(longhashset != null) {
|
||||
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 });
|
||||
}
|
||||
|
||||
/** Set up NMS fields **/
|
||||
/* biomebase */
|
||||
biomebaselist = getField(biomebase, new String[] { "a" }, biomebasearray);
|
||||
|
Loading…
Reference in New Issue
Block a user