Fix pre-1.13 startup problem without breaking 1.13.1...

This commit is contained in:
Mike Primm 2018-08-27 08:51:13 -05:00
parent 7d72dc4bbd
commit e41b1f9a54
4 changed files with 14 additions and 5 deletions

View File

@ -47,6 +47,11 @@ public class BukkitVersionHelperSpigot113_1 extends BukkitVersionHelperCB {
protected Class<?> datapalettearray; protected Class<?> datapalettearray;
private Field blockid_field; private Field blockid_field;
@Override
protected boolean isBlockIdNeeded() {
return false;
}
public BukkitVersionHelperSpigot113_1() { public BukkitVersionHelperSpigot113_1() {
datapalettearray = getNMSClass("[Lnet.minecraft.server.DataPaletteBlock;"); datapalettearray = getNMSClass("[Lnet.minecraft.server.DataPaletteBlock;");
blockid_field = getPrivateField(craftchunksnapshot, new String[] { "blockids" }, datapalettearray); blockid_field = getPrivateField(craftchunksnapshot, new String[] { "blockids" }, datapalettearray);

View File

@ -46,6 +46,11 @@ public class BukkitVersionHelperSpigot113 extends BukkitVersionHelperCB {
protected Class<?> datapalettearray; protected Class<?> datapalettearray;
private Field blockid_field; private Field blockid_field;
@Override
protected boolean isBlockIdNeeded() {
return false;
}
public BukkitVersionHelperSpigot113() { public BukkitVersionHelperSpigot113() {
datapalettearray = getNMSClass("[Lnet.minecraft.server.DataPaletteBlock;"); datapalettearray = getNMSClass("[Lnet.minecraft.server.DataPaletteBlock;");
blockid_field = getPrivateField(craftchunksnapshot, new String[] { "blockids" }, datapalettearray); blockid_field = getPrivateField(craftchunksnapshot, new String[] { "blockids" }, datapalettearray);

View File

@ -22,7 +22,9 @@ public abstract class BukkitVersionHelper {
public static DynmapBlockState[] stateByID; public static DynmapBlockState[] stateByID;
protected boolean blockidsneeded = true; protected boolean isBlockIdNeeded() {
return true;
}
protected BukkitVersionHelper() { protected BukkitVersionHelper() {

View File

@ -69,14 +69,11 @@ 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");
Log.info("blockidsneeded=" + blockidsneeded); if (isBlockIdNeeded()) { // Not needed for 1.13+
if (blockidsneeded) { // Not needed for 1.13+
blockbyid = getFieldNoFail(nmsblock, new String[] { "byId" }, nmsblockarray); blockbyid = getFieldNoFail(nmsblock, new String[] { "byId" }, nmsblockarray);
if (blockbyid == null) { if (blockbyid == null) {
blockbyidfunc = getMethod(nmsblock, new String[] { "getById", "e" }, new Class[] { int.class }); blockbyidfunc = getMethod(nmsblock, new String[] { "getById", "e" }, new Class[] { int.class });
Log.info("blockbyidfunc found = " + (blockbyidfunc != null));
} }
Log.info("blockbyid found = " + (blockbyid != null));
} }
material = getPrivateField(nmsblock, new String[] { "material" }, nmsmaterial); material = getPrivateField(nmsblock, new String[] { "material" }, nmsmaterial);