mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-30 22:24:06 +01:00
Update to support CB 1.7.2-R0.1
This commit is contained in:
parent
b4a3b61c11
commit
0c9d397144
@ -1,6 +1,7 @@
|
|||||||
package org.dynmap.bukkit;
|
package org.dynmap.bukkit;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
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;
|
||||||
@ -21,6 +22,7 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
|||||||
private Field blockbyid;
|
private Field blockbyid;
|
||||||
private Field blockname;
|
private Field blockname;
|
||||||
private Field material;
|
private Field material;
|
||||||
|
private Method blockbyidfunc; // 1.7+ method for getting block by id
|
||||||
|
|
||||||
BukkitVersionHelperCB() {
|
BukkitVersionHelperCB() {
|
||||||
}
|
}
|
||||||
@ -43,17 +45,20 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
|||||||
nmsblock = getNMSClass("net.minecraft.server.Block");
|
nmsblock = getNMSClass("net.minecraft.server.Block");
|
||||||
nmsblockarray = getNMSClass("[Lnet.minecraft.server.Block;");
|
nmsblockarray = getNMSClass("[Lnet.minecraft.server.Block;");
|
||||||
nmsmaterial = getNMSClass("net.minecraft.server.Material");
|
nmsmaterial = getNMSClass("net.minecraft.server.Material");
|
||||||
blockbyid = getField(nmsblock, new String[] { "byId" }, nmsblockarray);
|
blockbyid = getFieldNoFail(nmsblock, new String[] { "byId" }, nmsblockarray);
|
||||||
|
if (blockbyid == null) {
|
||||||
|
blockbyidfunc = getMethod(nmsblock, new String[] { "e" }, new Class[] { int.class });
|
||||||
|
}
|
||||||
blockname = getPrivateField(nmsblock, new String[] { "name", "b" }, String.class);
|
blockname = getPrivateField(nmsblock, new String[] { "name", "b" }, String.class);
|
||||||
material = getField(nmsblock, new String[] { "material" }, nmsmaterial);
|
material = getPrivateField(nmsblock, new String[] { "material" }, nmsmaterial);
|
||||||
|
|
||||||
/* Set up biomebase fields */
|
/* Set up biomebase fields */
|
||||||
biomebase = getNMSClass("net.minecraft.server.BiomeBase");
|
biomebase = getNMSClass("net.minecraft.server.BiomeBase");
|
||||||
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
|
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
|
||||||
biomebaselist = getField(biomebase, new String[] { "biomes" }, biomebasearray);
|
biomebaselist = getPrivateField(biomebase, new String[] { "biomes" }, biomebasearray);
|
||||||
biomebasetemp = getField(biomebase, new String[] { "temperature", "F" }, float.class);
|
biomebasetemp = getField(biomebase, new String[] { "temperature", "F" }, float.class);
|
||||||
biomebasehumi = getField(biomebase, new String[] { "humidity", "G" }, float.class);
|
biomebasehumi = getField(biomebase, new String[] { "humidity", "G" }, float.class);
|
||||||
biomebaseidstring = getField(biomebase, new String[] { "y" }, String.class);
|
biomebaseidstring = getField(biomebase, new String[] { "y", "af" }, String.class);
|
||||||
biomebaseid = getField(biomebase, new String[] { "id" }, int.class);
|
biomebaseid = getField(biomebase, new String[] { "id" }, int.class);
|
||||||
/* n.m.s.World */
|
/* n.m.s.World */
|
||||||
nmsworld = getNMSClass("net.minecraft.server.WorldServer");
|
nmsworld = getNMSClass("net.minecraft.server.WorldServer");
|
||||||
@ -89,15 +94,15 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
|||||||
nbttagstring = getNMSClass("net.minecraft.server.NBTTagString");
|
nbttagstring = getNMSClass("net.minecraft.server.NBTTagString");
|
||||||
nbttagintarray = getNMSClass("net.minecraft.server.NBTTagIntArray");
|
nbttagintarray = getNMSClass("net.minecraft.server.NBTTagIntArray");
|
||||||
compound_get = getMethod(nbttagcompound, new String[] { "get" }, new Class[] { String.class });
|
compound_get = getMethod(nbttagcompound, new String[] { "get" }, new Class[] { String.class });
|
||||||
nbttagbyte_val = getField(nbttagbyte, new String[] { "data" }, byte.class);
|
nbttagbyte_val = getPrivateField(nbttagbyte, new String[] { "data" }, byte.class);
|
||||||
nbttagshort_val = getField(nbttagshort, new String[] { "data" }, short.class);
|
nbttagshort_val = getPrivateField(nbttagshort, new String[] { "data" }, short.class);
|
||||||
nbttagint_val = getField(nbttagint, new String[] { "data" }, int.class);
|
nbttagint_val = getPrivateField(nbttagint, new String[] { "data" }, int.class);
|
||||||
nbttaglong_val = getField(nbttaglong, new String[] { "data" }, long.class);
|
nbttaglong_val = getPrivateField(nbttaglong, new String[] { "data" }, long.class);
|
||||||
nbttagfloat_val = getField(nbttagfloat, new String[] { "data" }, float.class);
|
nbttagfloat_val = getPrivateField(nbttagfloat, new String[] { "data" }, float.class);
|
||||||
nbttagdouble_val = getField(nbttagdouble, new String[] { "data" }, double.class);
|
nbttagdouble_val = getPrivateField(nbttagdouble, new String[] { "data" }, double.class);
|
||||||
nbttagbytearray_val = getField(nbttagbytearray, new String[] { "data" }, byte[].class);
|
nbttagbytearray_val = getPrivateField(nbttagbytearray, new String[] { "data" }, byte[].class);
|
||||||
nbttagstring_val = getField(nbttagstring, new String[] { "data" }, String.class);
|
nbttagstring_val = getPrivateField(nbttagstring, new String[] { "data" }, String.class);
|
||||||
nbttagintarray_val = getField(nbttagintarray, new String[] { "data" }, int[].class);
|
nbttagintarray_val = getPrivateField(nbttagintarray, new String[] { "data" }, int[].class);
|
||||||
|
|
||||||
/** Tile entity */
|
/** Tile entity */
|
||||||
nms_tileentity = getNMSClass("net.minecraft.server.TileEntity");
|
nms_tileentity = getNMSClass("net.minecraft.server.TileEntity");
|
||||||
@ -117,16 +122,27 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
|||||||
@Override
|
@Override
|
||||||
public String[] getBlockShortNames() {
|
public String[] getBlockShortNames() {
|
||||||
try {
|
try {
|
||||||
|
String[] names = new String[4096];
|
||||||
|
if (blockbyid != null) {
|
||||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||||
String[] names = new String[byid.length];
|
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (int i = 0; i < names.length; i++) {
|
||||||
if (byid[i] != null) {
|
if (byid[i] != null) {
|
||||||
names[i] = (String)blockname.get(byid[i]);
|
names[i] = (String)blockname.get(byid[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (int i = 0; i < names.length; i++) {
|
||||||
|
Object blk = blockbyidfunc.invoke(nmsblock, i);
|
||||||
|
if (blk != null) {
|
||||||
|
names[i] = (String)blockname.get(blk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return names;
|
return names;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
}
|
}
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
@ -153,8 +169,9 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
|||||||
*/
|
*/
|
||||||
public int[] getBlockMaterialMap() {
|
public int[] getBlockMaterialMap() {
|
||||||
try {
|
try {
|
||||||
|
int[] map = new int[4096];
|
||||||
|
if (blockbyid != null) {
|
||||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||||
int[] map = new int[byid.length];
|
|
||||||
ArrayList<Object> mats = new ArrayList<Object>();
|
ArrayList<Object> mats = new ArrayList<Object>();
|
||||||
for (int i = 0; i < map.length; i++) {
|
for (int i = 0; i < map.length; i++) {
|
||||||
if (byid[i] != null) {
|
if (byid[i] != null) {
|
||||||
@ -171,9 +188,30 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ArrayList<Object> mats = new ArrayList<Object>();
|
||||||
|
for (int i = 0; i < map.length; i++) {
|
||||||
|
Object blk = blockbyidfunc.invoke(nmsblock, i);
|
||||||
|
if (blk != null) {
|
||||||
|
Object mat = (Object)material.get(blk);
|
||||||
|
if (mat != null) {
|
||||||
|
map[i] = mats.indexOf(mat);
|
||||||
|
if (map[i] < 0) {
|
||||||
|
map[i] = mats.size();
|
||||||
|
mats.add(mat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
map[i] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return map;
|
return map;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
}
|
}
|
||||||
return new int[0];
|
return new int[0];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user