mirror of
https://github.com/encounter/dynmap.git
synced 2026-03-30 11:08:39 -07:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c5899d6234 | |||
| 20320c578f | |||
| 829a02b636 | |||
| 0253a644bf | |||
| 96a11c4711 | |||
| 9d2755cab1 | |||
| e69fc065cd | |||
| f440e3948f | |||
| ffc950d33a | |||
| d579879fbc | |||
| 3126de8eec | |||
| 4292d8540e | |||
| 0a4b1fd14b | |||
| ac1d4a8af0 | |||
| 2e5d27d0d5 |
@@ -79,19 +79,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
@@ -154,5 +141,5 @@
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<version>2.3-SNAPSHOT</version>
|
||||
</project>
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.utils.Polygon;
|
||||
|
||||
/**
|
||||
* Helper for isolation of bukkit version specific issues
|
||||
@@ -87,10 +88,6 @@ public abstract class BukkitVersionHelper {
|
||||
* Test if normal chunk snapshot
|
||||
*/
|
||||
// public abstract boolean isCraftChunkSnapshot(ChunkSnapshot css);
|
||||
/**
|
||||
* Remove entities from given chunk
|
||||
*/
|
||||
public abstract void removeEntitiesFromChunk(Chunk c);
|
||||
/**
|
||||
* Get inhabited ticks count from chunk
|
||||
*/
|
||||
@@ -143,4 +140,8 @@ public abstract class BukkitVersionHelper {
|
||||
* Get player health
|
||||
*/
|
||||
public abstract double getHealth(Player p);
|
||||
/**
|
||||
* Get world border
|
||||
*/
|
||||
public Polygon getWorldBorder(World world) { return null; }
|
||||
}
|
||||
|
||||
@@ -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.utils.Polygon;
|
||||
|
||||
/**
|
||||
* Helper for isolation of bukkit version specific issues
|
||||
@@ -24,6 +26,12 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
private Field blockname;
|
||||
private Field material;
|
||||
private Method blockbyidfunc; // 1.7+ method for getting block by id
|
||||
private Method getworldborder; // 1.8+ method for getting world border
|
||||
private Class<?> nmsworldborder;
|
||||
private Method worldborderminx;
|
||||
private Method worldbordermaxx;
|
||||
private Method worldborderminz;
|
||||
private Method worldbordermaxz;
|
||||
|
||||
BukkitVersionHelperCB() {
|
||||
}
|
||||
@@ -55,16 +63,23 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
|
||||
/* Set up biomebase fields */
|
||||
biomebase = getNMSClass("net.minecraft.server.BiomeBase");
|
||||
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
|
||||
biomebaselist = getPrivateField(biomebase, new String[] { "biomes" }, biomebasearray);
|
||||
biomebasetemp = getField(biomebase, new String[] { "temperature", "F" }, float.class);
|
||||
biomebasehumi = getField(biomebase, new String[] { "humidity", "G" }, float.class);
|
||||
biomebaseidstring = getField(biomebase, new String[] { "y", "af", "ah" }, String.class);
|
||||
biomebaseid = getField(biomebase, new String[] { "id" }, int.class);
|
||||
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
|
||||
biomebaselist = getPrivateFieldNoFail(biomebase, new String[] { "biomes" }, biomebasearray);
|
||||
if (biomebaselist == null) {
|
||||
biomebaseset = getPrivateField(biomebase, new String[] { "i" }, Set.class); // 1.9
|
||||
}
|
||||
biomebasetemp = getPrivateField(biomebase, new String[] { "temperature", "C", "F" }, float.class);
|
||||
biomebasehumi = getPrivateField(biomebase, new String[] { "humidity", "D", "G" }, float.class);
|
||||
biomebaseidstring = getPrivateField(biomebase, new String[] { "z", "y", "af", "ah" }, String.class);
|
||||
biomebaseid = getPrivateField(biomebase, new String[] { "id", "E" }, int.class);
|
||||
/* n.m.s.World */
|
||||
nmsworld = getNMSClass("net.minecraft.server.WorldServer");
|
||||
chunkprovserver = getNMSClass("net.minecraft.server.ChunkProviderServer");
|
||||
nmsw_chunkproviderserver = getField(nmsworld, new String[] { "chunkProviderServer" }, chunkprovserver);
|
||||
nmsw_chunkproviderserver = getFieldNoFail(nmsworld, new String[] { "chunkProviderServer" }, chunkprovserver);
|
||||
if (nmsw_chunkproviderserver == null) {
|
||||
nmsw_getchunkproviderserver = getMethod(nmsworld, new String[] { "getChunkProviderServer" }, nulltypes); // 1.9
|
||||
}
|
||||
getworldborder = getMethodNoFail(nmsworld, new String[] { "getWorldBorder", "af" }, nulltypes);
|
||||
|
||||
longhashset = getOBCClassNoFail("org.bukkit.craftbukkit.util.LongHashSet");
|
||||
if(longhashset != null) {
|
||||
@@ -81,12 +96,20 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
}
|
||||
/** n.m.s.Chunk */
|
||||
nmschunk = getNMSClass("net.minecraft.server.Chunk");
|
||||
nmsc_removeentities = getMethod(nmschunk, new String[] { "removeEntities" }, new Class[0]);
|
||||
nmsc_tileentities = getField(nmschunk, new String[] { "tileEntities" }, Map.class);
|
||||
nmsc_inhabitedticks = getFieldNoFail(nmschunk, new String[] { "s", "q", "u" }, long.class);
|
||||
nmsc_inhabitedticks = getPrivateFieldNoFail(nmschunk, new String[] { "v", "s", "q", "u" }, long.class);
|
||||
if (nmsc_inhabitedticks == null) {
|
||||
Log.info("inhabitedTicks field not found - inhabited shader not functional");
|
||||
}
|
||||
/** n.m.s.WorldBorder */
|
||||
nmsworldborder = getNMSClassNoFail("net.minecraft.server.WorldBorder");
|
||||
if (nmsworldborder != null) {
|
||||
worldborderminx = getMethod(nmsworldborder, new String[] { "b" }, nulltypes);
|
||||
worldborderminz = getMethod(nmsworldborder, new String[] { "c" }, nulltypes);
|
||||
worldbordermaxx = getMethod(nmsworldborder, new String[] { "d" }, nulltypes);
|
||||
worldbordermaxz = getMethod(nmsworldborder, new String[] { "e" }, nulltypes);
|
||||
}
|
||||
|
||||
/** nbt classes */
|
||||
nbttagcompound = getNMSClass("net.minecraft.server.NBTTagCompound");
|
||||
nbttagbyte = getNMSClass("net.minecraft.server.NBTTagByte");
|
||||
@@ -111,7 +134,7 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
|
||||
/** Tile entity */
|
||||
nms_tileentity = getNMSClass("net.minecraft.server.TileEntity");
|
||||
nmst_readnbt = getMethod(nms_tileentity, new String[] { "b" }, new Class[] { nbttagcompound });
|
||||
nmst_readnbt = getMethod(nms_tileentity, new String[] { "a", "b" }, new Class[] { nbttagcompound });
|
||||
nmst_getposition = getMethodNoFail(nms_tileentity, new String[] { "getPosition" }, new Class[0]); // Try 1.8 method
|
||||
if (nmst_getposition == null) {
|
||||
nmst_x = getField(nms_tileentity, new String[] { "x" }, int.class);
|
||||
@@ -127,7 +150,6 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
}
|
||||
@Override
|
||||
public void unloadChunkNoSave(World w, Chunk c, int cx, int cz) {
|
||||
this.removeEntitiesFromChunk(c);
|
||||
w.unloadChunk(cx, cz, false, false);
|
||||
}
|
||||
/**
|
||||
@@ -229,4 +251,28 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
}
|
||||
return new int[0];
|
||||
}
|
||||
@Override
|
||||
public Polygon getWorldBorder(World world) {
|
||||
Polygon p = null;
|
||||
if ((getworldborder == null) || (world == null)) {
|
||||
return null;
|
||||
}
|
||||
Object cw = getNMSWorld(world);
|
||||
if (cw == null) return null;
|
||||
Object wb = callMethod(cw, getworldborder, nullargs, null);
|
||||
if (wb != null) {
|
||||
double minx = (Double) callMethod(wb, worldborderminx, nullargs, Double.MIN_VALUE);
|
||||
double minz = (Double) callMethod(wb, worldborderminz, nullargs, Double.MIN_VALUE);
|
||||
double maxx = (Double) callMethod(wb, worldbordermaxx, nullargs, Double.MAX_VALUE);
|
||||
double maxz = (Double) callMethod(wb, worldbordermaxz, nullargs, Double.MAX_VALUE);
|
||||
if (maxx < 1E7) {
|
||||
p = new Polygon();
|
||||
p.addVertex(minx, minz);
|
||||
p.addVertex(minx, maxz);
|
||||
p.addVertex(maxx, maxz);
|
||||
p.addVertex(maxx, minz);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@@ -23,7 +24,8 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
private String obc_package; // Package used for org.bukkit.craftbukkit
|
||||
protected String nms_package; // Package used for net.minecraft.server
|
||||
private boolean failed;
|
||||
private static final Object[] nullargs = new Object[0];
|
||||
protected static final Object[] nullargs = new Object[0];
|
||||
protected static final Class[] nulltypes = new Class[0];
|
||||
private static final Map nullmap = Collections.emptyMap();
|
||||
|
||||
/** CraftChunkSnapshot */
|
||||
@@ -40,6 +42,7 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
protected Class<?> biomebase;
|
||||
protected Class<?> biomebasearray;
|
||||
protected Field biomebaselist;
|
||||
protected Field biomebaseset;
|
||||
protected Field biomebasetemp;
|
||||
protected Field biomebasehumi;
|
||||
protected Field biomebaseidstring;
|
||||
@@ -49,11 +52,11 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
protected Class<?> chunkprovserver;
|
||||
protected Class<?> longhashset;
|
||||
protected Field nmsw_chunkproviderserver;
|
||||
protected Method nmsw_getchunkproviderserver;
|
||||
protected Field cps_unloadqueue;
|
||||
protected Method lhs_containskey;
|
||||
/** n.m.s.Chunk */
|
||||
protected Class<?> nmschunk;
|
||||
protected Method nmsc_removeentities;
|
||||
protected Field nmsc_tileentities;
|
||||
protected Field nmsc_inhabitedticks;
|
||||
/** nbt classes */
|
||||
@@ -143,7 +146,11 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
protected Class<?> getNMSClass(String classname) {
|
||||
return getClassByName(classname, "net.minecraft.server", nms_package, false);
|
||||
}
|
||||
|
||||
|
||||
protected Class<?> getNMSClassNoFail(String classname) {
|
||||
return getClassByName(classname, "net.minecraft.server", nms_package, true);
|
||||
}
|
||||
|
||||
protected Class<?> getClassByName(String classname, String base, String mapping, boolean nofail) {
|
||||
String n = classname;
|
||||
int idx = classname.indexOf(base);
|
||||
@@ -197,6 +204,12 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
* Get private field
|
||||
*/
|
||||
protected Field getPrivateField(Class<?> cls, String[] ids, Class<?> type) {
|
||||
return getPrivateField(cls, ids, type, false);
|
||||
}
|
||||
protected Field getPrivateFieldNoFail(Class<?> cls, String[] ids, Class<?> type) {
|
||||
return getPrivateField(cls, ids, type, true);
|
||||
}
|
||||
private Field getPrivateField(Class<?> cls, String[] ids, Class<?> type, boolean nofail) {
|
||||
if((cls == null) || (type == null)) return null;
|
||||
for(String id : ids) {
|
||||
try {
|
||||
@@ -208,8 +221,10 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
} catch (NoSuchFieldException nsfx) {
|
||||
}
|
||||
}
|
||||
Log.severe("Unable to find field " + ids[0] + " for " + cls.getName());
|
||||
failed = true;
|
||||
if(!nofail) {
|
||||
Log.severe("Unable to find field " + ids[0] + " for " + cls.getName());
|
||||
failed = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
protected Object getFieldValue(Object obj, Field field, Object def) {
|
||||
@@ -249,7 +264,7 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private Object callMethod(Object obj, Method meth, Object[] args, Object def) {
|
||||
protected Object callMethod(Object obj, Method meth, Object[] args, Object def) {
|
||||
if((obj == null) || (meth == null)) {
|
||||
return def;
|
||||
}
|
||||
@@ -267,7 +282,11 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
* Get list of defined biomebase objects
|
||||
*/
|
||||
public Object[] getBiomeBaseList() {
|
||||
return (Object[]) getFieldValue(biomebase, biomebaselist, new Object[0]);
|
||||
if (biomebaselist != null) {
|
||||
return (Object[]) getFieldValue(biomebase, biomebaselist, new Object[0]);
|
||||
} else {
|
||||
return ((Set) getFieldValue(biomebase, biomebaselist, Collections.emptySet())).toArray();
|
||||
}
|
||||
}
|
||||
/** Get temperature from biomebase */
|
||||
public float getBiomeBaseTemperature(Object bb) {
|
||||
@@ -293,7 +312,12 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
|
||||
/* Get unload queue for given NMS world */
|
||||
public Object getUnloadQueue(World world) {
|
||||
Object cps = getFieldValue(getNMSWorld(world), nmsw_chunkproviderserver, null); // Get chunkproviderserver
|
||||
Object cps = null;
|
||||
if (nmsw_chunkproviderserver != null) {
|
||||
cps = getFieldValue(getNMSWorld(world), nmsw_chunkproviderserver, null);
|
||||
} else {
|
||||
cps = callMethod(getNMSWorld(world), nmsw_getchunkproviderserver, nullargs, null);
|
||||
}
|
||||
if(cps != null) {
|
||||
return getFieldValue(cps, cps_unloadqueue, null);
|
||||
}
|
||||
@@ -317,13 +341,7 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
/** Remove entities from given chunk */
|
||||
public void removeEntitiesFromChunk(Chunk c) {
|
||||
Object omsc = callMethod(c, cc_gethandle, nullargs, null);
|
||||
if(omsc != null) {
|
||||
callMethod(omsc, nmsc_removeentities, nullargs, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get inhabited ticks count from chunk
|
||||
*/
|
||||
|
||||
@@ -91,12 +91,6 @@ public class BukkitVersionHelperGlowstone extends BukkitVersionHelper {
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntitiesFromChunk(Chunk c) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getInhabitedTicks(Chunk c) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.Polygon;
|
||||
import org.dynmap.utils.TileFlags;
|
||||
|
||||
public class BukkitWorld extends DynmapWorld {
|
||||
@@ -242,5 +243,8 @@ public class BukkitWorld extends DynmapWorld {
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Polygon getWorldBorder() {
|
||||
return DynmapPlugin.plugin.getWorldBorder(world);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ import org.dynmap.hdmap.HDMap;
|
||||
import org.dynmap.markers.MarkerAPI;
|
||||
import org.dynmap.modsupport.ModSupportImpl;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.Polygon;
|
||||
import org.dynmap.utils.VisibilityLimit;
|
||||
|
||||
public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
@@ -955,11 +956,13 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
@Override
|
||||
public final int triggerRenderOfVolume(String wid, int minx, int miny, int minz,
|
||||
int maxx, int maxy, int maxz) {
|
||||
sscache.invalidateSnapshot(wid, minx, miny, minz, maxx, maxy, maxz);
|
||||
return core.triggerRenderOfVolume(wid, minx, miny, minz, maxx, maxy, maxz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int triggerRenderOfBlock(String wid, int x, int y, int z) {
|
||||
sscache.invalidateSnapshot(wid, x, y, z);
|
||||
return core.triggerRenderOfBlock(wid, x, y, z);
|
||||
}
|
||||
|
||||
@@ -1619,4 +1622,8 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
String[] lines, String playerid) {
|
||||
core.processSignChange(blkid, world, x, y, z, lines, playerid);
|
||||
}
|
||||
|
||||
Polygon getWorldBorder(World w) {
|
||||
return helper.getWorldBorder(w);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# The definitions of these templates are in normal-hi_boost_xhi.txt, nether-hi_boost_xhi.txt, and the_end-hi_boost_xhi.txt
|
||||
deftemplatesuffix: hires
|
||||
|
||||
# Map storage scheme: only uncommoent one 'type' value
|
||||
# Map storage scheme: only uncomment one 'type' value
|
||||
# filetree: classic and default scheme: tree of files, with all map data under the directory indicated by 'tilespath' setting
|
||||
# sqlite: single SQLite database file (this can get VERY BIG), located at 'dbfile' setting (default is file dynmap.db in data directory)
|
||||
# mysql: MySQL database, at hostname:port in database, accessed via userid with password
|
||||
@@ -125,6 +125,8 @@ components:
|
||||
spawnbedhidebydefault: true
|
||||
spawnbedminzoom: 0
|
||||
spawnbedformat: "%name%'s bed"
|
||||
# (optional) show world border (vanilla 1.8+)
|
||||
showworldborder: true
|
||||
|
||||
- class: org.dynmap.ClientComponent
|
||||
type: chat
|
||||
@@ -274,7 +276,7 @@ custom-colors-support: true
|
||||
#refreshskins: false
|
||||
|
||||
# Customize URL used for fetching player skins (%player% is macro for name)
|
||||
skin-url: "http://s3.amazonaws.com/MinecraftSkins/%player%.png"
|
||||
skin-url: "http://skins.minecraft.net/MinecraftSkins/%player%.png"
|
||||
|
||||
# Control behavior for new (1.0+) compass orientation (sunrise moved 90 degrees: east is now what used to be south)
|
||||
# default is 'newrose' (preserve pre-1.0 maps, rotate rose)
|
||||
@@ -473,4 +475,4 @@ verbose: false
|
||||
#debuggers:
|
||||
# - class: org.dynmap.debug.LogDebugger
|
||||
# Debug: dump blocks missing render data
|
||||
dump-missing-blocks: false
|
||||
dump-missing-blocks: false
|
||||
|
||||
Reference in New Issue
Block a user