mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 05:05:16 +01:00
Add full support for CTM material connection method
This commit is contained in:
parent
a2ab8c4f2f
commit
5396d0b823
@ -124,4 +124,8 @@ public abstract class BukkitVersionHelper {
|
||||
* Get biome name list
|
||||
*/
|
||||
public abstract String[] getBiomeNames();
|
||||
/**
|
||||
* Get block material index list
|
||||
*/
|
||||
public abstract int[] getBlockMaterialMap();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -16,8 +17,10 @@ import org.dynmap.common.BiomeMap;
|
||||
public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
private Class<?> nmsblock;
|
||||
private Class<?> nmsblockarray;
|
||||
private Class<?> nmsmaterial;
|
||||
private Field blockbyid;
|
||||
private Field blockname;
|
||||
private Field material;
|
||||
|
||||
BukkitVersionHelperCB() {
|
||||
}
|
||||
@ -39,8 +42,10 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
// Get block fields
|
||||
nmsblock = getNMSClass("net.minecraft.server.Block");
|
||||
nmsblockarray = getNMSClass("[Lnet.minecraft.server.Block;");
|
||||
nmsmaterial = getNMSClass("net.minecraft.server.Material");
|
||||
blockbyid = getField(nmsblock, new String[] { "byId" }, nmsblockarray);
|
||||
blockname = getPrivateField(nmsblock, new String[] { "name" }, String.class);
|
||||
material = getField(nmsblock, new String[] { "material" }, nmsmaterial);
|
||||
|
||||
/* Set up biomebase fields */
|
||||
biomebase = getNMSClass("net.minecraft.server.BiomeBase");
|
||||
@ -143,4 +148,33 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
}
|
||||
return names;
|
||||
}
|
||||
/**
|
||||
* Get block material index list
|
||||
*/
|
||||
public int[] getBlockMaterialMap() {
|
||||
try {
|
||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||
int[] map = new int[byid.length];
|
||||
ArrayList<Object> mats = new ArrayList<Object>();
|
||||
for (int i = 0; i < map.length; i++) {
|
||||
if (byid[i] != null) {
|
||||
Object mat = (Object)material.get(byid[i]);
|
||||
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;
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
return new int[0];
|
||||
}
|
||||
}
|
||||
|
@ -756,6 +756,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
core.setDataFolder(dataDirectory);
|
||||
core.setServer(new BukkitServer());
|
||||
core.setBlockNames(helper.getBlockShortNames());
|
||||
core.setBlockMaterialMap(helper.getBlockMaterialMap());
|
||||
core.setBiomeNames(helper.getBiomeNames());
|
||||
|
||||
/* Load configuration */
|
||||
|
Loading…
Reference in New Issue
Block a user