mirror of
https://github.com/encounter/dynmap.git
synced 2026-03-30 11:08:39 -07:00
Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3126de8eec | |||
| 4292d8540e | |||
| 0a4b1fd14b | |||
| ac1d4a8af0 | |||
| 2e5d27d0d5 | |||
| f80b456b2c | |||
| 41d1de1fbb | |||
| 274a363a97 | |||
| b0d9f5541a | |||
| 0f722da05d | |||
| af1bcd1094 | |||
| a7f0218d0f | |||
| 3fd4ac7373 | |||
| ac0f756fae | |||
| 551f35f3f9 | |||
| ec9ebf2dbb | |||
| 3702918a6f | |||
| 8085221087 | |||
| 7de967f1c2 | |||
| f6e127b7f0 | |||
| 22d1923ad5 | |||
| d8d3061696 | |||
| 14da080d52 | |||
| 10ce166b54 | |||
| cb9f964348 | |||
| 9850a03945 | |||
| 8abfae3d79 | |||
| f486ad75f1 | |||
| 54b3fb429c | |||
| 86547f8d78 | |||
| 8ec80937e3 | |||
| 0e5e602a90 | |||
| 3239d539c0 | |||
| 05bd2544fd | |||
| 252da2a5c6 | |||
| 5d83ebf8aa | |||
| 026cc72233 | |||
| 0d2cceea4b | |||
| a1dfae7f79 | |||
| d6eb822b26 | |||
| d4f161ca99 | |||
| 376ec447ed | |||
| 926d2a3dbc | |||
| eeffa4f98d | |||
| 8350727a73 | |||
| 3b79890166 | |||
| 17174c177c | |||
| 07e7d53a93 | |||
| 76863aeb71 | |||
| f7d2dac826 | |||
| 3cb7ba342c | |||
| d2ab466dc0 | |||
| d03ed7a461 | |||
| c8469d7aba | |||
| e7c92096b2 | |||
| 0c9d397144 | |||
| b4a3b61c11 | |||
| 564c38b44a | |||
| 664e7da659 | |||
| 9046212a47 | |||
| b6ee68c9b0 | |||
| 7854568d88 | |||
| f1c9417237 | |||
| 336f8302c4 | |||
| d8ccc26109 | |||
| d396046249 | |||
| 1793d910d4 | |||
| f0f881d126 |
@@ -1,11 +1,12 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<groupId>us.dynmap</groupId>
|
||||
<artifactId>dynmap</artifactId>
|
||||
<name>dynmap</name>
|
||||
<properties>
|
||||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
|
||||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<BUILD_NUMBER>Dev${timestamp}</BUILD_NUMBER>
|
||||
</properties>
|
||||
@@ -43,7 +44,7 @@
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
@@ -57,25 +58,44 @@
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>org.dynmap:dynmap-api:jar:*</include>
|
||||
<include>org.dynmap:DynmapCore:jar:*</include>
|
||||
<include>us.dynmap:dynmap-api:jar:*</include>
|
||||
<include>us.dynmap:DynmapCore:jar:*</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</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>
|
||||
<repositories>
|
||||
<repository>
|
||||
<releases>
|
||||
</releases>
|
||||
<snapshots>
|
||||
</snapshots>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<releases>
|
||||
</releases>
|
||||
@@ -94,22 +114,18 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.4.7-R1.0</version>
|
||||
<version>1.7.10-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<groupId>us.dynmap</groupId>
|
||||
<artifactId>dynmap-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<groupId>us.dynmap</groupId>
|
||||
<artifactId>DynmapCore</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.getspout</groupId>
|
||||
@@ -138,5 +154,5 @@
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<version>1.8</version>
|
||||
<version>2.2</version>
|
||||
</project>
|
||||
|
||||
@@ -5,12 +5,15 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
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
|
||||
@@ -21,6 +24,7 @@ public abstract class BukkitVersionHelper {
|
||||
|
||||
public static final BukkitVersionHelper getHelper() {
|
||||
if(helper == null) {
|
||||
Log.info("version=" + Bukkit.getServer().getVersion());
|
||||
if(Bukkit.getServer().getVersion().contains("MCPC")) {
|
||||
Log.severe("*********************************************************************************");
|
||||
Log.severe("* MCPC-Plus is no longer supported via the Bukkit version of Dynmap. *");
|
||||
@@ -35,6 +39,10 @@ public abstract class BukkitVersionHelper {
|
||||
Log.severe("* Add the DynmapCBBridge plugin to enable support for Dynmap-compatible plugins *");
|
||||
Log.severe("*********************************************************************************");
|
||||
}
|
||||
else if(Bukkit.getServer().getClass().getName().contains("GlowServer")) {
|
||||
Log.info("Loading Glowstone support");
|
||||
helper = new BukkitVersionHelperGlowstone();
|
||||
}
|
||||
else {
|
||||
helper = new BukkitVersionHelperCB();
|
||||
}
|
||||
@@ -64,14 +72,10 @@ public abstract class BukkitVersionHelper {
|
||||
* Get ID from biomebase
|
||||
*/
|
||||
public abstract int getBiomeBaseID(Object bb);
|
||||
/**
|
||||
* Get net.minecraft.server.world for given world
|
||||
*/
|
||||
public abstract Object getNMSWorld(World w);
|
||||
/**
|
||||
* Get unload queue for given NMS world
|
||||
*/
|
||||
public abstract Object getUnloadQueue(Object nmsworld);
|
||||
public abstract Object getUnloadQueue(World world);
|
||||
/**
|
||||
* For testing unload queue for presence of givne chunk
|
||||
*/
|
||||
@@ -83,11 +87,15 @@ public abstract class BukkitVersionHelper {
|
||||
/**
|
||||
* Test if normal chunk snapshot
|
||||
*/
|
||||
public abstract boolean isCraftChunkSnapshot(ChunkSnapshot css);
|
||||
// public abstract boolean isCraftChunkSnapshot(ChunkSnapshot css);
|
||||
/**
|
||||
* Remove entities from given chunk
|
||||
*/
|
||||
public abstract void removeEntitiesFromChunk(Chunk c);
|
||||
/**
|
||||
* Get inhabited ticks count from chunk
|
||||
*/
|
||||
public abstract long getInhabitedTicks(Chunk c);
|
||||
/**
|
||||
* Get tile entities map from chunk
|
||||
*/
|
||||
@@ -128,4 +136,16 @@ public abstract class BukkitVersionHelper {
|
||||
* Get block material index list
|
||||
*/
|
||||
public abstract int[] getBlockMaterialMap();
|
||||
/**
|
||||
* Get list of online players
|
||||
*/
|
||||
public abstract Player[] getOnlinePlayers();
|
||||
/**
|
||||
* Get player health
|
||||
*/
|
||||
public abstract double getHealth(Player p);
|
||||
/**
|
||||
* Get world border
|
||||
*/
|
||||
public Polygon getWorldBorder(World world) { return null; }
|
||||
}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
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
|
||||
@@ -21,6 +24,13 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
private Field blockbyid;
|
||||
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() {
|
||||
}
|
||||
@@ -43,22 +53,26 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
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);
|
||||
blockbyid = getFieldNoFail(nmsblock, new String[] { "byId" }, nmsblockarray);
|
||||
if (blockbyid == null) {
|
||||
blockbyidfunc = getMethod(nmsblock, new String[] { "getById", "e" }, new Class[] { int.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 */
|
||||
biomebase = getNMSClass("net.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);
|
||||
biomebasehumi = getField(biomebase, new String[] { "humidity", "G" }, float.class);
|
||||
biomebaseidstring = getField(biomebase, new String[] { "y" }, String.class);
|
||||
biomebaseidstring = getField(biomebase, new String[] { "y", "af", "ah" }, String.class);
|
||||
biomebaseid = getField(biomebase, new String[] { "id" }, 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);
|
||||
getworldborder = getMethodNoFail(nmsworld, new String[] { "af" }, nulltypes);
|
||||
|
||||
longhashset = getOBCClassNoFail("org.bukkit.craftbukkit.util.LongHashSet");
|
||||
if(longhashset != null) {
|
||||
@@ -75,8 +89,21 @@ 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_removeentities = getMethod(nmschunk, new String[] { "removeEntities" }, nulltypes);
|
||||
nmsc_tileentities = getField(nmschunk, new String[] { "tileEntities" }, Map.class);
|
||||
nmsc_inhabitedticks = getFieldNoFail(nmschunk, new String[] { "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");
|
||||
@@ -89,22 +116,31 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
nbttagstring = getNMSClass("net.minecraft.server.NBTTagString");
|
||||
nbttagintarray = getNMSClass("net.minecraft.server.NBTTagIntArray");
|
||||
compound_get = getMethod(nbttagcompound, new String[] { "get" }, new Class[] { String.class });
|
||||
nbttagbyte_val = getField(nbttagbyte, new String[] { "data" }, byte.class);
|
||||
nbttagshort_val = getField(nbttagshort, new String[] { "data" }, short.class);
|
||||
nbttagint_val = getField(nbttagint, new String[] { "data" }, int.class);
|
||||
nbttaglong_val = getField(nbttaglong, new String[] { "data" }, long.class);
|
||||
nbttagfloat_val = getField(nbttagfloat, new String[] { "data" }, float.class);
|
||||
nbttagdouble_val = getField(nbttagdouble, new String[] { "data" }, double.class);
|
||||
nbttagbytearray_val = getField(nbttagbytearray, new String[] { "data" }, byte[].class);
|
||||
nbttagstring_val = getField(nbttagstring, new String[] { "data" }, String.class);
|
||||
nbttagintarray_val = getField(nbttagintarray, new String[] { "data" }, int[].class);
|
||||
nbttagbyte_val = getPrivateField(nbttagbyte, new String[] { "data" }, byte.class);
|
||||
nbttagshort_val = getPrivateField(nbttagshort, new String[] { "data" }, short.class);
|
||||
nbttagint_val = getPrivateField(nbttagint, new String[] { "data" }, int.class);
|
||||
nbttaglong_val = getPrivateField(nbttaglong, new String[] { "data" }, long.class);
|
||||
nbttagfloat_val = getPrivateField(nbttagfloat, new String[] { "data" }, float.class);
|
||||
nbttagdouble_val = getPrivateField(nbttagdouble, new String[] { "data" }, double.class);
|
||||
nbttagbytearray_val = getPrivateField(nbttagbytearray, new String[] { "data" }, byte[].class);
|
||||
nbttagstring_val = getPrivateField(nbttagstring, new String[] { "data" }, String.class);
|
||||
nbttagintarray_val = getPrivateField(nbttagintarray, new String[] { "data" }, int[].class);
|
||||
|
||||
/** Tile entity */
|
||||
nms_tileentity = getNMSClass("net.minecraft.server.TileEntity");
|
||||
nmst_readnbt = getMethod(nms_tileentity, new String[] { "b" }, new Class[] { nbttagcompound });
|
||||
nmst_x = getField(nms_tileentity, new String[] { "x" }, int.class);
|
||||
nmst_y = getField(nms_tileentity, new String[] { "y" }, int.class);
|
||||
nmst_z = getField(nms_tileentity, new String[] { "z" }, int.class);
|
||||
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);
|
||||
nmst_y = getField(nms_tileentity, new String[] { "y" }, int.class);
|
||||
nmst_z = getField(nms_tileentity, new String[] { "z" }, int.class);
|
||||
}
|
||||
else { /* BlockPosition */
|
||||
nms_blockposition = getNMSClass("net.minecraft.server.BlockPosition");
|
||||
nmsbp_getx = getMethod(nms_blockposition, new String[] { "getX" }, new Class[0]);
|
||||
nmsbp_gety = getMethod(nms_blockposition, new String[] { "getY" }, new Class[0]);
|
||||
nmsbp_getz = getMethod(nms_blockposition, new String[] { "getZ" }, new Class[0]);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void unloadChunkNoSave(World w, Chunk c, int cx, int cz) {
|
||||
@@ -117,16 +153,27 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
@Override
|
||||
public String[] getBlockShortNames() {
|
||||
try {
|
||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||
String[] names = new String[byid.length];
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
if (byid[i] != null) {
|
||||
names[i] = (String)blockname.get(byid[i]);
|
||||
String[] names = new String[4096];
|
||||
if (blockbyid != null) {
|
||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
if (byid[i] != null) {
|
||||
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;
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
@@ -153,28 +200,74 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
*/
|
||||
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);
|
||||
int[] map = new int[4096];
|
||||
if (blockbyid != null) {
|
||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||
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;
|
||||
}
|
||||
}
|
||||
else {
|
||||
map[i] = -1;
|
||||
}
|
||||
}
|
||||
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;
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,17 @@ package org.dynmap.bukkit;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.dynmap.Log;
|
||||
|
||||
/**
|
||||
@@ -19,7 +23,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 */
|
||||
@@ -51,6 +56,7 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
protected Class<?> nmschunk;
|
||||
protected Method nmsc_removeentities;
|
||||
protected Field nmsc_tileentities;
|
||||
protected Field nmsc_inhabitedticks;
|
||||
/** nbt classes */
|
||||
protected Class<?> nbttagcompound;
|
||||
protected Class<?> nbttagbyte;
|
||||
@@ -78,6 +84,17 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
protected Field nmst_x;
|
||||
protected Field nmst_y;
|
||||
protected Field nmst_z;
|
||||
protected Method nmst_getposition;
|
||||
/** BlockPosition */
|
||||
protected Class<?> nms_blockposition;
|
||||
protected Method nmsbp_getx;
|
||||
protected Method nmsbp_gety;
|
||||
protected Method nmsbp_getz;
|
||||
|
||||
/** Server */
|
||||
protected Method server_getonlineplayers;
|
||||
/** Player */
|
||||
protected Method player_gethealth;
|
||||
|
||||
BukkitVersionHelperGeneric() {
|
||||
failed = false;
|
||||
@@ -98,6 +115,12 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
/* CraftChunk */
|
||||
craftchunk = getOBCClass("org.bukkit.craftbukkit.CraftChunk");
|
||||
cc_gethandle = getMethod(craftchunk, new String[] { "getHandle" }, new Class[0]);
|
||||
|
||||
/** Server */
|
||||
server_getonlineplayers = getMethod(Server.class, new String[] { "getOnlinePlayers" }, new Class[0]);
|
||||
/** Player */
|
||||
player_gethealth = getMethod(Player.class, new String[] { "getHealth" }, new Class[0]);
|
||||
|
||||
/* Get NMS classes and fields */
|
||||
if(!failed)
|
||||
loadNMS();
|
||||
@@ -121,7 +144,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);
|
||||
@@ -216,7 +243,18 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
failed = true;
|
||||
return null;
|
||||
}
|
||||
private Object callMethod(Object obj, Method meth, Object[] args, Object def) {
|
||||
protected Method getMethodNoFail(Class<?> cls, String[] ids, Class[] args) {
|
||||
if(cls == null) return null;
|
||||
for(String id : ids) {
|
||||
try {
|
||||
return cls.getMethod(id, args);
|
||||
} catch (SecurityException e) {
|
||||
} catch (NoSuchMethodException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
protected Object callMethod(Object obj, Method meth, Object[] args, Object def) {
|
||||
if((obj == null) || (meth == null)) {
|
||||
return def;
|
||||
}
|
||||
@@ -254,13 +292,13 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
}
|
||||
|
||||
/* Get net.minecraft.server.world for given world */
|
||||
public Object getNMSWorld(World w) {
|
||||
protected Object getNMSWorld(World w) {
|
||||
return callMethod(w, cw_gethandle, nullargs, null);
|
||||
}
|
||||
|
||||
/* Get unload queue for given NMS world */
|
||||
public Object getUnloadQueue(Object nmsworld) {
|
||||
Object cps = getFieldValue(nmsworld, nmsw_chunkproviderserver, null); // Get chunkproviderserver
|
||||
public Object getUnloadQueue(World world) {
|
||||
Object cps = getFieldValue(getNMSWorld(world), nmsw_chunkproviderserver, null); // Get chunkproviderserver
|
||||
if(cps != null) {
|
||||
return getFieldValue(cps, cps_unloadqueue, null);
|
||||
}
|
||||
@@ -278,12 +316,12 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
public Object[] getBiomeBaseFromSnapshot(ChunkSnapshot css) {
|
||||
return (Object[])getFieldValue(css, ccss_biome, null);
|
||||
}
|
||||
public boolean isCraftChunkSnapshot(ChunkSnapshot css) {
|
||||
if(craftchunksnapshot != null) {
|
||||
return craftchunksnapshot.isAssignableFrom(css.getClass());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// public boolean isCraftChunkSnapshot(ChunkSnapshot css) {
|
||||
// if(craftchunksnapshot != null) {
|
||||
// return craftchunksnapshot.isAssignableFrom(css.getClass());
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
/** Remove entities from given chunk */
|
||||
public void removeEntitiesFromChunk(Chunk c) {
|
||||
Object omsc = callMethod(c, cc_gethandle, nullargs, null);
|
||||
@@ -291,6 +329,21 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
callMethod(omsc, nmsc_removeentities, nullargs, null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get inhabited ticks count from chunk
|
||||
*/
|
||||
private static final Long zero = new Long(0);
|
||||
public long getInhabitedTicks(Chunk c) {
|
||||
if (nmsc_inhabitedticks == null) {
|
||||
return 0;
|
||||
}
|
||||
Object omsc = callMethod(c, cc_gethandle, nullargs, null);
|
||||
if(omsc != null) {
|
||||
return (Long)getFieldValue(omsc, nmsc_inhabitedticks, zero);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Get tile entities map from chunk */
|
||||
public Map getTileEntitiesForChunk(Chunk c) {
|
||||
Object omsc = callMethod(c, cc_gethandle, nullargs, null);
|
||||
@@ -303,19 +356,37 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
* Get X coordinate of tile entity
|
||||
*/
|
||||
public int getTileEntityX(Object te) {
|
||||
return (Integer)getFieldValue(te, nmst_x, 0);
|
||||
if (nmst_getposition == null) {
|
||||
return (Integer)getFieldValue(te, nmst_x, 0);
|
||||
}
|
||||
else {
|
||||
Object pos = callMethod(te, nmst_getposition, nullargs, null);
|
||||
return (Integer) callMethod(pos, nmsbp_getx, nullargs, null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get Y coordinate of tile entity
|
||||
*/
|
||||
public int getTileEntityY(Object te) {
|
||||
return (Integer)getFieldValue(te, nmst_y, 0);
|
||||
if (nmst_getposition == null) {
|
||||
return (Integer)getFieldValue(te, nmst_y, 0);
|
||||
}
|
||||
else {
|
||||
Object pos = callMethod(te, nmst_getposition, nullargs, null);
|
||||
return (Integer) callMethod(pos, nmsbp_gety, nullargs, null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get Z coordinate of tile entity
|
||||
*/
|
||||
public int getTileEntityZ(Object te) {
|
||||
return (Integer)getFieldValue(te, nmst_z, 0);
|
||||
if (nmst_getposition == null) {
|
||||
return (Integer)getFieldValue(te, nmst_z, 0);
|
||||
}
|
||||
else {
|
||||
Object pos = callMethod(te, nmst_getposition, nullargs, null);
|
||||
return (Integer) callMethod(pos, nmsbp_getz, nullargs, null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Read tile entity NBT
|
||||
@@ -369,4 +440,32 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Get list of online players
|
||||
*/
|
||||
public Player[] getOnlinePlayers() {
|
||||
Object players = callMethod(Bukkit.getServer(), server_getonlineplayers, nullargs, null);
|
||||
if (players instanceof Player[]) { /* Pre 1.7.10 */
|
||||
return (Player[]) players;
|
||||
}
|
||||
else {
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<? extends Player> p = (Collection<? extends Player>) players;
|
||||
return p.toArray(new Player[0]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get player health
|
||||
*/
|
||||
@Override
|
||||
public double getHealth(Player p) {
|
||||
Object health = callMethod(p, player_gethealth, nullargs, null);
|
||||
if (health instanceof Integer) {
|
||||
return (Integer) health;
|
||||
}
|
||||
else {
|
||||
return ((Double) health).intValue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,451 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BukkitVersionHelperGlowstone extends BukkitVersionHelper {
|
||||
private Method rawbiome;
|
||||
private Method server_getonlineplayers;
|
||||
|
||||
public BukkitVersionHelperGlowstone() {
|
||||
try {
|
||||
Class<?> c = Class.forName("net.glowstone.GlowChunkSnapshot");
|
||||
rawbiome = c.getMethod("getRawBiomes", new Class[0]);
|
||||
|
||||
/** Server */
|
||||
server_getonlineplayers = Server.class.getMethod("getOnlinePlayers", new Class[0]);
|
||||
} catch (SecurityException e) {
|
||||
} catch (NoSuchMethodException e) {
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
if ((rawbiome == null) && (server_getonlineplayers == null)) {
|
||||
throw new IllegalArgumentException("Error initializing dynmap - Glowstone version incompatible!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getBiomeBaseList() {
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBiomeBaseTemperature(Object bb) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBiomeBaseHumidity(Object bb) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBiomeBaseIDString(Object bb) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeBaseID(Object bb) {
|
||||
if (bb != null)
|
||||
return (Integer) bb;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getUnloadQueue(World world) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInUnloadQueue(Object unloadqueue, int x, int z) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getBiomeBaseFromSnapshot(ChunkSnapshot css) {
|
||||
Integer b[] = new Integer[256];
|
||||
byte[] rb = null;
|
||||
try {
|
||||
rb = (byte[]) rawbiome.invoke(css, new Object[0]);
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
if (rb != null) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
b[i] = Integer.valueOf(255 & (int)rb[i]);
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntitiesFromChunk(Chunk c) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getInhabitedTicks(Chunk c) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getTileEntitiesForChunk(Chunk c) {
|
||||
// TODO Auto-generated method stub
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTileEntityX(Object te) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTileEntityY(Object te) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTileEntityZ(Object te) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object readTileEntityNBT(Object te) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getFieldValue(Object nbt, String field) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloadChunkNoSave(World w, Chunk c, int cx, int cz) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBlockShortNames() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final String[] bnames = {
|
||||
"Ocean",
|
||||
"Plains",
|
||||
"Desert",
|
||||
"Extreme Hills",
|
||||
"Forest",
|
||||
"Taiga",
|
||||
"Swampland",
|
||||
"River",
|
||||
"Hell",
|
||||
"Sky",
|
||||
"FrozenOcean",
|
||||
"FrozenRiver",
|
||||
"Ice Plains",
|
||||
"Ice Mountains",
|
||||
"MushroomIsland",
|
||||
"MushroomIslandShore",
|
||||
"Beach",
|
||||
"DesertHills",
|
||||
"ForestHills",
|
||||
"TaigaHills",
|
||||
"Extreme Hills Edge",
|
||||
"Jungle",
|
||||
"JungleHills",
|
||||
"JungleEdge",
|
||||
"Deep Ocean",
|
||||
"Stone Beach",
|
||||
"Cold Beach",
|
||||
"Birch Forest",
|
||||
"Birch Forest Hills",
|
||||
"Roofed Forest",
|
||||
"Cold Taiga",
|
||||
"Cold Taiga Hills",
|
||||
"Mega Taiga",
|
||||
"Mega Taiga Hills",
|
||||
"Extreme Hills+",
|
||||
"Savanna",
|
||||
"Savanna Plateau",
|
||||
"Mesa",
|
||||
"Mesa Plateau F",
|
||||
"Mesa Plateau",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"Sunflower Plains",
|
||||
"Desert M",
|
||||
"Extreme Hills M",
|
||||
"Flower Forest",
|
||||
"Taiga M",
|
||||
"Swampland M",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"Ice Plains Spikes",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"Jungle M",
|
||||
null,
|
||||
"JungleEdge M",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"Birch Forest M",
|
||||
"Birch Forest Hills M",
|
||||
"Roofed Forest M",
|
||||
"Cold Taiga M",
|
||||
null,
|
||||
"Mega Spruce Taiga",
|
||||
"Mega Spruce Taiga",
|
||||
"Extreme Hills+ M",
|
||||
"Savanna M",
|
||||
"Savanna Plateau M",
|
||||
"Mesa (Bryce)",
|
||||
"Mesa Plateau F M",
|
||||
"Mesa Plateau M",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
};
|
||||
|
||||
@Override
|
||||
public String[] getBiomeNames() {
|
||||
return bnames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getBlockMaterialMap() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of online players
|
||||
*/
|
||||
public Player[] getOnlinePlayers() {
|
||||
Object players;
|
||||
try {
|
||||
players = server_getonlineplayers.invoke(Bukkit.getServer(), new Object[0]);
|
||||
if (players instanceof Player[]) { /* Pre 1.7.10 */
|
||||
return (Player[]) players;
|
||||
}
|
||||
else {
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<? extends Player> p = (Collection<? extends Player>) players;
|
||||
return p.toArray(new Player[0]);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
return new Player[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealth(Player p) {
|
||||
return p.getHealth();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,12 +11,14 @@ import java.util.List;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
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 {
|
||||
@@ -36,6 +38,20 @@ public class BukkitWorld extends DynmapWorld {
|
||||
this.env = env;
|
||||
skylight = (env == World.Environment.NORMAL);
|
||||
new Permission("dynmap.world." + getName(), "Dynmap access for world " + getName(), PermissionDefault.OP);
|
||||
// Generate non-default environment lighting table
|
||||
switch (env) {
|
||||
case NETHER:
|
||||
{
|
||||
float f = 0.1F;
|
||||
for (int i = 0; i <= 15; ++i) {
|
||||
float f1 = 1.0F - (float)i / 15.0F;
|
||||
this.setBrightnessTableEntry(i, (1.0F - f1) / (f1 * 3.0F + 1.0F) * (1.0F - f) + f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set world online
|
||||
@@ -110,7 +126,10 @@ public class BukkitWorld extends DynmapWorld {
|
||||
@Override
|
||||
public int getLightLevel(int x, int y, int z) {
|
||||
if(world != null) {
|
||||
return world.getBlockAt(x, y, z).getLightLevel();
|
||||
if ((y >= 0) && (y < this.worldheight)) {
|
||||
return world.getBlockAt(x, y, z).getLightLevel();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
@@ -135,7 +154,12 @@ public class BukkitWorld extends DynmapWorld {
|
||||
@Override
|
||||
public int getSkyLightLevel(int x, int y, int z) {
|
||||
if(world != null) {
|
||||
return world.getBlockAt(x, y, z).getLightFromSky();
|
||||
if ((y >= 0) && (y < this.worldheight)) {
|
||||
return world.getBlockAt(x, y, z).getLightFromSky();
|
||||
}
|
||||
else {
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
@@ -219,5 +243,8 @@ public class BukkitWorld extends DynmapWorld {
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Polygon getWorldBorder() {
|
||||
return DynmapPlugin.plugin.getWorldBorder(world);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
@@ -91,7 +92,9 @@ import org.dynmap.common.DynmapServerInterface;
|
||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
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 {
|
||||
@@ -99,15 +102,16 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
private PermissionProvider permissions;
|
||||
private String version;
|
||||
public SnapshotCache sscache;
|
||||
private boolean has_spout = false;
|
||||
public PlayerList playerList;
|
||||
private MapManager mapManager;
|
||||
public static DynmapPlugin plugin;
|
||||
public SpoutPluginBlocks spb;
|
||||
public PluginManager pm;
|
||||
private Metrics metrics;
|
||||
private BukkitEnableCoreCallback enabCoreCB = new BukkitEnableCoreCallback();
|
||||
private Method ismodloaded;
|
||||
private Method instance;
|
||||
private Method getindexedmodlist;
|
||||
private Method getversion;
|
||||
private HashMap<String, BukkitWorld> world_by_name = new HashMap<String, BukkitWorld>();
|
||||
private HashSet<String> modsused = new HashSet<String>();
|
||||
// TPS calculator
|
||||
@@ -151,7 +155,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
|
||||
return bw;
|
||||
}
|
||||
private final void removeWorld(World w) {
|
||||
final void removeWorld(World w) {
|
||||
world_by_name.remove(w.getName());
|
||||
if(w == last_world) {
|
||||
last_world = null;
|
||||
@@ -162,26 +166,10 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
private class BukkitEnableCoreCallback extends DynmapCore.EnableCoreCallbacks {
|
||||
@Override
|
||||
public void configurationLoaded() {
|
||||
/* Check for Spout */
|
||||
if(detectSpout()) {
|
||||
if(core.configuration.getBoolean("spout/enabled", true)) {
|
||||
has_spout = true;
|
||||
Log.info("Detected Spout");
|
||||
if(spb == null) {
|
||||
spb = new SpoutPluginBlocks(DynmapPlugin.this);
|
||||
}
|
||||
modsused.add("SpoutPlugin");
|
||||
}
|
||||
else {
|
||||
Log.info("Detected Spout - Support Disabled");
|
||||
}
|
||||
File st = new File(core.getDataFolder(), "renderdata/spout-texture.txt");
|
||||
if(st.exists()) {
|
||||
st.delete();
|
||||
}
|
||||
if(!has_spout) { /* If not, clean up old spout texture, if needed */
|
||||
File st = new File(core.getDataFolder(), "renderdata/spout-texture.txt");
|
||||
if(st.exists())
|
||||
st.delete();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,6 +187,10 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
try {
|
||||
Class<?> c = Class.forName("cpw.mods.fml.common.Loader");
|
||||
ismodloaded = c.getMethod("isModLoaded", String.class);
|
||||
instance = c.getMethod("instance");
|
||||
getindexedmodlist = c.getMethod("getIndexedModList");
|
||||
c = Class.forName("cpw.mods.fml.common.ModContainer");
|
||||
getversion = c.getMethod("getVersion");
|
||||
} catch (NoSuchMethodException nsmx) {
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
@@ -207,10 +199,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
/**
|
||||
* Server access abstraction class
|
||||
*/
|
||||
public class BukkitServer implements DynmapServerInterface {
|
||||
/* Chunk load handling */
|
||||
private Object loadlock = new Object();
|
||||
|
||||
public class BukkitServer extends DynmapServerInterface {
|
||||
@Override
|
||||
public int getBlockIDAt(String wname, int x, int y, int z) {
|
||||
World w = getServer().getWorld(wname);
|
||||
@@ -226,7 +215,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
}
|
||||
@Override
|
||||
public DynmapPlayer[] getOnlinePlayers() {
|
||||
Player[] players = getServer().getOnlinePlayers();
|
||||
Player[] players = helper.getOnlinePlayers();
|
||||
DynmapPlayer[] dplay = new DynmapPlayer[players.length];
|
||||
for(int i = 0; i < players.length; i++)
|
||||
dplay[i] = new BukkitPlayer(players[i]);
|
||||
@@ -268,6 +257,11 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isServerThread() {
|
||||
return Bukkit.getServer().isPrimaryThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String stripChatColor(String s) {
|
||||
return ChatColor.stripColor(s);
|
||||
@@ -335,7 +329,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
break;
|
||||
case SIGN_CHANGE:
|
||||
pm.registerEvents(new Listener() {
|
||||
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
|
||||
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
|
||||
public void onSignChange(SignChangeEvent evt) {
|
||||
Block b = evt.getBlock();
|
||||
Location l = b.getLocation();
|
||||
@@ -452,20 +446,18 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
public Boolean call() throws Exception {
|
||||
boolean exhausted = true;
|
||||
|
||||
synchronized(loadlock) {
|
||||
if (prev_tick != cur_tick) {
|
||||
prev_tick = cur_tick;
|
||||
cur_tick_starttime = System.nanoTime();
|
||||
}
|
||||
if(chunks_in_cur_tick > 0) {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int cnt = chunks_in_cur_tick;
|
||||
if (cnt > 5) cnt = 5;
|
||||
chunks_in_cur_tick -= cc.loadChunks(cnt);
|
||||
exhausted = (chunks_in_cur_tick == 0) || ((System.nanoTime() - cur_tick_starttime) > perTickLimit);
|
||||
done = exhausted || cc.isDoneLoading();
|
||||
}
|
||||
if (prev_tick != cur_tick) {
|
||||
prev_tick = cur_tick;
|
||||
cur_tick_starttime = System.nanoTime();
|
||||
}
|
||||
if(chunks_in_cur_tick > 0) {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int cnt = chunks_in_cur_tick;
|
||||
if (cnt > 5) cnt = 5;
|
||||
chunks_in_cur_tick -= cc.loadChunks(cnt);
|
||||
exhausted = (chunks_in_cur_tick == 0) || ((System.nanoTime() - cur_tick_starttime) > perTickLimit);
|
||||
done = exhausted || cc.isDoneLoading();
|
||||
}
|
||||
}
|
||||
return exhausted;
|
||||
@@ -501,7 +493,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
}
|
||||
@Override
|
||||
public int getCurrentPlayers() {
|
||||
return getServer().getOnlinePlayers().length;
|
||||
return helper.getOnlinePlayers().length;
|
||||
}
|
||||
@Override
|
||||
public boolean isModLoaded(String name) {
|
||||
@@ -521,11 +513,46 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public String getModVersion(String name) {
|
||||
if((instance != null) && (getindexedmodlist != null) && (getversion != null)) {
|
||||
try {
|
||||
Object inst = instance.invoke(null);
|
||||
Map<?,?> modmap = (Map<?,?>) getindexedmodlist.invoke(inst);
|
||||
Object mod = modmap.get(name);
|
||||
if (mod != null) {
|
||||
return (String) getversion.invoke(mod);
|
||||
}
|
||||
} catch (IllegalArgumentException iax) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getServerTPS() {
|
||||
return tps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerIP() {
|
||||
return Bukkit.getServer().getIp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, String> getBlockIDMap() {
|
||||
String[] bsn = helper.getBlockShortNames();
|
||||
HashMap<Integer, String> map = new HashMap<Integer, String>();
|
||||
for (int i = 0; i < bsn.length; i++) {
|
||||
if (bsn[i] != null) {
|
||||
map.put(i, bsn[i]);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Player access abstraction class
|
||||
@@ -593,9 +620,9 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int getHealth() {
|
||||
public double getHealth() {
|
||||
if(player != null)
|
||||
return player.getHealth();
|
||||
return helper.getHealth(player);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -689,25 +716,32 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadExtraBiomes() {
|
||||
public void loadExtraBiomes(String mcver) {
|
||||
int cnt = 0;
|
||||
|
||||
BiomeMap.loadWellKnownByVersion(mcver);
|
||||
/* Find array of biomes in biomebase */
|
||||
Object[] biomelist = helper.getBiomeBaseList();
|
||||
/* Loop through list, starting afer well known biomes */
|
||||
for(int i = BiomeMap.LAST_WELL_KNOWN+1; i < biomelist.length; i++) {
|
||||
/* Loop through list, skipping well known biomes */
|
||||
for(int i = 0; i < biomelist.length; i++) {
|
||||
Object bb = biomelist[i];
|
||||
if(bb != null) {
|
||||
String id = helper.getBiomeBaseIDString(bb);
|
||||
if(id == null) {
|
||||
id = "BIOME_" + i;
|
||||
}
|
||||
float tmp = helper.getBiomeBaseTemperature(bb);
|
||||
float hum = helper.getBiomeBaseHumidity(bb);
|
||||
|
||||
BiomeMap m = new BiomeMap(i, id, tmp, hum);
|
||||
Log.verboseinfo("Add custom biome [" + m.toString() + "] (" + i + ")");
|
||||
cnt++;
|
||||
BiomeMap bmap = BiomeMap.byBiomeID(i);
|
||||
if (bmap.isDefault()) {
|
||||
String id = helper.getBiomeBaseIDString(bb);
|
||||
if(id == null) {
|
||||
id = "BIOME_" + i;
|
||||
}
|
||||
BiomeMap m = new BiomeMap(i, id, tmp, hum);
|
||||
Log.verboseinfo("Add custom biome [" + m.toString() + "] (" + i + ")");
|
||||
cnt++;
|
||||
}
|
||||
else {
|
||||
bmap.setTemperature(tmp);
|
||||
bmap.setRainfall(hum);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(cnt > 0) {
|
||||
@@ -721,6 +755,8 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
|
||||
helper = BukkitVersionHelper.getHelper();
|
||||
pm = this.getServer().getPluginManager();
|
||||
|
||||
ModSupportImpl.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -732,8 +768,18 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
version = pdfFile.getVersion();
|
||||
|
||||
/* Get MC version */
|
||||
String bukkitver = getServer().getVersion();
|
||||
String mcver = "1.0.0";
|
||||
int idx = bukkitver.indexOf("(MC: ");
|
||||
if(idx > 0) {
|
||||
mcver = bukkitver.substring(idx+5);
|
||||
idx = mcver.indexOf(")");
|
||||
if(idx > 0) mcver = mcver.substring(0, idx);
|
||||
}
|
||||
|
||||
/* Load extra biomes, if any */
|
||||
loadExtraBiomes();
|
||||
loadExtraBiomes(mcver);
|
||||
|
||||
/* Set up player login/quit event handler */
|
||||
registerPlayerLoginListener();
|
||||
@@ -748,12 +794,12 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
permissions = PEXPermissions.create(getServer(), "dynmap");
|
||||
if (permissions == null)
|
||||
permissions = bPermPermissions.create(getServer(), "dynmap", perdefs);
|
||||
if (permissions == null)
|
||||
permissions = GroupManagerPermissions.create(getServer(), "dynmap");
|
||||
if (permissions == null)
|
||||
permissions = PermBukkitPermissions.create(getServer(), "dynmap", perdefs);
|
||||
if (permissions == null)
|
||||
permissions = NijikokunPermissions.create(getServer(), "dynmap");
|
||||
if (permissions == null)
|
||||
permissions = GroupManagerPermissions.create(getServer(), "dynmap");
|
||||
if (permissions == null)
|
||||
permissions = BukkitPermissions.create("dynmap", perdefs);
|
||||
if (permissions == null)
|
||||
@@ -762,17 +808,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
File dataDirectory = this.getDataFolder();
|
||||
if(dataDirectory.exists() == false)
|
||||
dataDirectory.mkdirs();
|
||||
|
||||
/* Get MC version */
|
||||
String bukkitver = getServer().getVersion();
|
||||
String mcver = "1.0.0";
|
||||
int idx = bukkitver.indexOf("(MC: ");
|
||||
if(idx > 0) {
|
||||
mcver = bukkitver.substring(idx+5);
|
||||
idx = mcver.indexOf(")");
|
||||
if(idx > 0) mcver = mcver.substring(0, idx);
|
||||
}
|
||||
|
||||
|
||||
/* Instantiate core */
|
||||
if(core == null)
|
||||
core = new DynmapCore();
|
||||
@@ -797,7 +833,6 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
|
||||
public void onPluginEnabled(PluginEnableEvent evt) {
|
||||
if (!readyToEnable()) {
|
||||
spb.markPluginEnabled(evt.getPlugin());
|
||||
if (readyToEnable()) { /* If we;re ready now, finish enable */
|
||||
doEnable(); /* Finish enable */
|
||||
}
|
||||
@@ -822,18 +857,10 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
}
|
||||
|
||||
private boolean readyToEnable() {
|
||||
if (spb != null) {
|
||||
return spb.isReady();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void doEnable() {
|
||||
/* Prep spout support, if needed */
|
||||
if(spb != null) {
|
||||
spb.processSpoutBlocks(this, core);
|
||||
}
|
||||
|
||||
/* Enable core */
|
||||
if(!core.enableCore(enabCoreCB)) {
|
||||
this.setEnabled(false);
|
||||
@@ -1470,18 +1497,6 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean detectSpout() {
|
||||
Plugin p = this.getServer().getPluginManager().getPlugin("Spout");
|
||||
if(p != null) {
|
||||
return p.isEnabled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasSpout() {
|
||||
return has_spout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertPlayerInvisibility(String player, boolean is_invisible,
|
||||
String plugin_id) {
|
||||
@@ -1532,14 +1547,6 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
features.addPlotter(new Metrics.Plotter("Spout") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
if(plugin.has_spout)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
features.addPlotter(new Metrics.Plotter("Login Security") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
@@ -1608,4 +1615,13 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
// Failed to submit the stats :-(
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void processSignChange(int blkid, String world, int x, int y, int z,
|
||||
String[] lines, String playerid) {
|
||||
core.processSignChange(blkid, world, x, y, z, lines, playerid);
|
||||
}
|
||||
|
||||
Polygon getWorldBorder(World w) {
|
||||
return helper.getWorldBorder(w);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,9 +56,9 @@ import java.util.logging.Level;
|
||||
* <p> The metrics class obtains data about a plugin and submits statistics about it to the metrics backend. </p> <p>
|
||||
* Public methods provided by this class: </p>
|
||||
* <code>
|
||||
* Graph createGraph(String name); <br/>
|
||||
* void addCustomData(BukkitMetrics.Plotter plotter); <br/>
|
||||
* void start(); <br/>
|
||||
* Graph createGraph(String name); <br>
|
||||
* void addCustomData(BukkitMetrics.Plotter plotter); <br>
|
||||
* void start(); <br>
|
||||
* </code>
|
||||
*/
|
||||
public class Metrics {
|
||||
@@ -121,6 +121,8 @@ public class Metrics {
|
||||
*/
|
||||
private volatile BukkitTask task = null;
|
||||
|
||||
private BukkitVersionHelper helper;
|
||||
|
||||
public Metrics(final Plugin plugin) throws IOException {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
@@ -146,6 +148,8 @@ public class Metrics {
|
||||
// Load the guid then
|
||||
guid = configuration.getString("guid");
|
||||
debug = configuration.getBoolean("debug", false);
|
||||
|
||||
helper = BukkitVersionHelper.getHelper();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -359,7 +363,7 @@ public class Metrics {
|
||||
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||
String pluginVersion = description.getVersion();
|
||||
String serverVersion = Bukkit.getVersion();
|
||||
int playersOnline = Bukkit.getServer().getOnlinePlayers().length;
|
||||
int playersOnline = helper.getOnlinePlayers().length;
|
||||
|
||||
// END server software specific section -- all code below does not use any code outside of this class / Java
|
||||
|
||||
|
||||
@@ -22,14 +22,12 @@ import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.MapIterator;
|
||||
import org.dynmap.utils.BlockStep;
|
||||
import org.dynmap.utils.VisibilityLimit;
|
||||
import org.getspout.spoutapi.block.SpoutChunk;
|
||||
|
||||
/**
|
||||
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
|
||||
*/
|
||||
public class NewMapChunkCache implements MapChunkCache {
|
||||
public class NewMapChunkCache extends MapChunkCache {
|
||||
private static boolean init = false;
|
||||
private static boolean use_spout = false;
|
||||
|
||||
private World w;
|
||||
private DynmapWorld dw;
|
||||
@@ -49,12 +47,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
private byte[][] sameneighborbiomecnt;
|
||||
private BiomeMap[][] biomemap;
|
||||
private boolean[][] isSectionNotEmpty; /* Indexed by snapshot index, then by section index */
|
||||
|
||||
private int chunks_read; /* Number of chunks actually loaded */
|
||||
private int chunks_attempted; /* Number of chunks attempted to load */
|
||||
private long total_loadtime; /* Total time loading chunks, in nanoseconds */
|
||||
|
||||
private long exceptions;
|
||||
private long[] inhabitedTicks; /* Index = (x-x_min) + ((z-z_min)*x_dim) */
|
||||
|
||||
private static BukkitVersionHelper helper = BukkitVersionHelper.getHelper();
|
||||
|
||||
@@ -210,7 +203,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
try {
|
||||
return biomemap[x - x_base][z - z_base];
|
||||
} catch (Exception ex) {
|
||||
exceptions++;
|
||||
return BiomeMap.NULL;
|
||||
}
|
||||
}
|
||||
@@ -240,7 +232,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
mult = ((raccum / 9) << 16) | ((gaccum / 9) << 8) | (baccum / 9);
|
||||
}
|
||||
} catch (Exception x) {
|
||||
exceptions++;
|
||||
mult = 0xFFFFFF;
|
||||
}
|
||||
return mult;
|
||||
@@ -271,7 +262,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
mult = ((raccum / 9) << 16) | ((gaccum / 9) << 8) | (baccum / 9);
|
||||
}
|
||||
} catch (Exception x) {
|
||||
exceptions++;
|
||||
mult = 0xFFFFFF;
|
||||
}
|
||||
return mult;
|
||||
@@ -313,7 +303,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
mult = ((raccum / 9) << 16) | ((gaccum / 9) << 8) | (baccum / 9);
|
||||
}
|
||||
} catch (Exception x) {
|
||||
exceptions++;
|
||||
mult = 0xFFFFFF;
|
||||
}
|
||||
return mult;
|
||||
@@ -341,7 +330,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
}
|
||||
return ((raccum / 9) << 16) | ((gaccum / 9) << 8) | (baccum / 9);
|
||||
} catch (Exception x) {
|
||||
exceptions++;
|
||||
return 0xFFFFFF;
|
||||
}
|
||||
}
|
||||
@@ -371,7 +359,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
mult = ((raccum / 9) << 16) | ((gaccum / 9) << 8) | (baccum / 9);
|
||||
}
|
||||
} catch (Exception x) {
|
||||
exceptions++;
|
||||
mult = 0xFFFFFF;
|
||||
}
|
||||
return mult;
|
||||
@@ -593,6 +580,14 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
int yoff, int zoff) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public long getInhabitedTicks() {
|
||||
try {
|
||||
return inhabitedTicks[chunkindex];
|
||||
} catch (Exception x) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class OurEndMapIterator extends OurMapIterator {
|
||||
@@ -740,8 +735,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
*/
|
||||
public NewMapChunkCache() {
|
||||
if(!init) {
|
||||
use_spout = DynmapPlugin.plugin.hasSpout();
|
||||
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
@@ -779,26 +772,15 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
|
||||
snapcnt = x_dim * (z_max-z_min+1);
|
||||
snaparray = new ChunkSnapshot[snapcnt];
|
||||
inhabitedTicks = new long[snapcnt];
|
||||
snaptile = new DynIntHashMap[snapcnt];
|
||||
isSectionNotEmpty = new boolean[snapcnt][];
|
||||
}
|
||||
|
||||
private ChunkSnapshot checkSpoutData(Chunk c, ChunkSnapshot ss) {
|
||||
if(c instanceof SpoutChunk) {
|
||||
SpoutChunk sc = (SpoutChunk)c;
|
||||
short[] custids = sc.getCustomBlockIds();
|
||||
if(custids != null) {
|
||||
return new SpoutChunkSnapshot(ss, custids, c.getWorld().getMaxHeight());
|
||||
}
|
||||
}
|
||||
return ss;
|
||||
}
|
||||
|
||||
public int loadChunks(int max_to_load) {
|
||||
if(dw.isLoaded() == false)
|
||||
return 0;
|
||||
long t0 = System.nanoTime();
|
||||
Object queue = helper.getUnloadQueue(helper.getNMSWorld(w));
|
||||
Object queue = helper.getUnloadQueue(w);
|
||||
|
||||
int cnt = 0;
|
||||
if(iterator == null)
|
||||
@@ -808,6 +790,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
//boolean isnormral = w.getEnvironment() == Environment.NORMAL;
|
||||
// Load the required chunks.
|
||||
while((cnt < max_to_load) && iterator.hasNext()) {
|
||||
long startTime = System.nanoTime();
|
||||
DynmapChunk chunk = iterator.next();
|
||||
boolean vis = true;
|
||||
if(visible_limits != null) {
|
||||
@@ -829,10 +812,12 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
}
|
||||
/* Check if cached chunk snapshot found */
|
||||
ChunkSnapshot ss = null;
|
||||
long inhabited_ticks = 0;
|
||||
DynIntHashMap tileData = null;
|
||||
SnapshotRec ssr = DynmapPlugin.plugin.sscache.getSnapshot(dw.getName(), chunk.x, chunk.z, blockdata, biome, biomeraw, highesty);
|
||||
if(ssr != null) {
|
||||
ss = ssr.ss;
|
||||
inhabited_ticks = ssr.inhabitedTicks;
|
||||
if(!vis) {
|
||||
if(hidestyle == HiddenChunkStyle.FILL_STONE_PLAIN)
|
||||
ss = STONE;
|
||||
@@ -844,10 +829,11 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
int idx = (chunk.x-x_min) + (chunk.z - z_min)*x_dim;
|
||||
snaparray[idx] = ss;
|
||||
snaptile[idx] = ssr.tileData;
|
||||
inhabitedTicks[idx] = inhabited_ticks;
|
||||
|
||||
endChunkLoad(startTime, ChunkStats.CACHED_SNAPSHOT_HIT);
|
||||
continue;
|
||||
}
|
||||
chunks_attempted++;
|
||||
boolean wasLoaded = w.isChunkLoaded(chunk.x, chunk.z);
|
||||
boolean didload = false;
|
||||
boolean isunloadpending = false;
|
||||
@@ -870,6 +856,8 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
tileData = new DynIntHashMap();
|
||||
|
||||
Chunk c = w.getChunkAt(chunk.x, chunk.z); /* Get the chunk */
|
||||
/* Get inhabited ticks count */
|
||||
inhabited_ticks = helper.getInhabitedTicks(c);
|
||||
if(!vis) {
|
||||
if(hidestyle == HiddenChunkStyle.FILL_STONE_PLAIN)
|
||||
ss = STONE;
|
||||
@@ -881,9 +869,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
else {
|
||||
if(blockdata || highesty) {
|
||||
ss = c.getChunkSnapshot(highesty, biome, biomeraw);
|
||||
if(use_spout) {
|
||||
ss = checkSpoutData(c, ss);
|
||||
}
|
||||
/* Get tile entity data */
|
||||
List<Object> vals = new ArrayList<Object>();
|
||||
Map<?,?> tileents = helper.getTileEntitiesForChunk(c);
|
||||
@@ -919,16 +904,18 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
if(ss != null) {
|
||||
ssr = new SnapshotRec();
|
||||
ssr.ss = ss;
|
||||
ssr.inhabitedTicks = inhabited_ticks;
|
||||
ssr.tileData = tileData;
|
||||
DynmapPlugin.plugin.sscache.putSnapshot(dw.getName(), chunk.x, chunk.z, ssr, blockdata, biome, biomeraw, highesty);
|
||||
}
|
||||
}
|
||||
snaparray[(chunk.x-x_min) + (chunk.z - z_min)*x_dim] = ss;
|
||||
snaptile[(chunk.x-x_min) + (chunk.z - z_min)*x_dim] = tileData;
|
||||
int chunkIndex = (chunk.x-x_min) + (chunk.z - z_min)*x_dim;
|
||||
snaparray[chunkIndex] = ss;
|
||||
snaptile[chunkIndex] = tileData;
|
||||
inhabitedTicks[chunkIndex] = inhabited_ticks;
|
||||
|
||||
/* If wasn't loaded before, we need to do unload */
|
||||
if (!wasLoaded) {
|
||||
chunks_read++;
|
||||
/* Since we only remember ones we loaded, and we're synchronous, no player has
|
||||
* moved, so it must be safe (also prevent chunk leak, which appears to happen
|
||||
* because isChunkInUse defined "in use" as being within 256 blocks of a player,
|
||||
@@ -936,10 +923,18 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
* by the MC base server is 21x21 (or about a 160 block radius).
|
||||
* Also, if we did generate it, need to save it */
|
||||
helper.unloadChunkNoSave(w, c, chunk.x, chunk.z);
|
||||
endChunkLoad(startTime, ChunkStats.UNLOADED_CHUNKS);
|
||||
}
|
||||
else if (isunloadpending) { /* Else, if loaded and unload is pending */
|
||||
w.unloadChunkRequest(chunk.x, chunk.z); /* Request new unload */
|
||||
endChunkLoad(startTime, ChunkStats.LOADED_CHUNKS);
|
||||
}
|
||||
else {
|
||||
endChunkLoad(startTime, ChunkStats.LOADED_CHUNKS);
|
||||
}
|
||||
}
|
||||
else {
|
||||
endChunkLoad(startTime, ChunkStats.UNGENERATED_CHUNKS);
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
@@ -955,7 +950,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
isempty = false;
|
||||
}
|
||||
}
|
||||
total_loadtime += System.nanoTime() - t0;
|
||||
|
||||
return cnt;
|
||||
}
|
||||
@@ -987,6 +981,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
snaparray[i] = null;
|
||||
}
|
||||
snaparray = null;
|
||||
inhabitedTicks = null;
|
||||
}
|
||||
}
|
||||
private void initSectionData(int idx) {
|
||||
@@ -1053,22 +1048,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
public DynmapWorld getWorld() {
|
||||
return dw;
|
||||
}
|
||||
@Override
|
||||
public int getChunksLoaded() {
|
||||
return chunks_read;
|
||||
}
|
||||
@Override
|
||||
public int getChunkLoadsAttempted() {
|
||||
return chunks_attempted;
|
||||
}
|
||||
@Override
|
||||
public long getTotalRuntimeNanos() {
|
||||
return total_loadtime;
|
||||
}
|
||||
@Override
|
||||
public long getExceptionCount() {
|
||||
return exceptions;
|
||||
}
|
||||
|
||||
static {
|
||||
Biome[] b = Biome.values();
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.dynmap.utils.DynIntHashMap;
|
||||
public class SnapshotCache {
|
||||
public static class SnapshotRec {
|
||||
public ChunkSnapshot ss;
|
||||
public long inhabitedTicks;
|
||||
public DynIntHashMap tileData;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,265 +0,0 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.Log;
|
||||
import org.getspout.spoutapi.block.design.BlockDesign;
|
||||
import org.getspout.spoutapi.block.design.GenericBlockDesign;
|
||||
import org.getspout.spoutapi.block.design.GenericCuboidBlockDesign;
|
||||
import org.getspout.spoutapi.block.design.Texture;
|
||||
import org.getspout.spoutapi.material.CustomBlock;
|
||||
import org.getspout.spoutapi.material.MaterialData;
|
||||
|
||||
/**
|
||||
* Handler for pulling spout-defined custom blocks into dynmap
|
||||
*
|
||||
* Generates and maintains custom render data file (renderdata/spout-texture.txt) and
|
||||
* directory of downloaded image files (texturepacks/standard/spout/plugin.blockid.png)
|
||||
*/
|
||||
public class SpoutPluginBlocks {
|
||||
private Field textXPosField; /* float[][] textXPos */
|
||||
private Field textYPosField; /* float[][] textYPos */
|
||||
private HashSet<String> plugins_pending = new HashSet<String>();
|
||||
|
||||
public SpoutPluginBlocks(Plugin plugin) {
|
||||
/* First, see if any spout plugins that need to be enabled */
|
||||
for(Plugin p : plugin.getServer().getPluginManager().getPlugins()) {
|
||||
List<String> dep = p.getDescription().getDepend();
|
||||
if((dep != null) && (dep.contains("Spout"))) {
|
||||
Log.info("Found Spout plugin: " + p.getName());
|
||||
if(p.isEnabled() == false) {
|
||||
plugins_pending.add(p.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
return plugins_pending.isEmpty();
|
||||
}
|
||||
|
||||
public void markPluginEnabled(Plugin p) {
|
||||
plugins_pending.remove(p.getName());
|
||||
}
|
||||
|
||||
private boolean initSpoutAccess() {
|
||||
boolean success = false;
|
||||
try {
|
||||
textXPosField = GenericBlockDesign.class.getDeclaredField("textXPos");
|
||||
textXPosField.setAccessible(true);
|
||||
textYPosField = GenericBlockDesign.class.getDeclaredField("textYPos");
|
||||
textYPosField.setAccessible(true);
|
||||
success = true;
|
||||
} catch (NoSuchFieldException nsfx) {
|
||||
Log.severe("Cannot access needed Spout custom block fields!");
|
||||
Log.severe(nsfx);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
private void addDefaultBlock(StringBuilder sb, CustomBlock blk) {
|
||||
if(blk.isOpaque())
|
||||
sb.append("block:id=" + blk.getCustomId() + ",data=*,allfaces=1\n");
|
||||
else
|
||||
sb.append("block:id=" + blk.getCustomId() + ",allfaces=12049,transparency=TRANSPARENT\n");
|
||||
}
|
||||
|
||||
private static String fixIDString(String id) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int len = id.length();
|
||||
sb.setLength(len);
|
||||
for(int i = 0; i < len; i++) {
|
||||
char c = id.charAt(i);
|
||||
if(Character.isJavaIdentifierStart(c)) {
|
||||
sb.setCharAt(i, c);
|
||||
}
|
||||
else {
|
||||
sb.setCharAt(i, '_');
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/* Process spout blocks - return true if something changed */
|
||||
public boolean processSpoutBlocks(DynmapPlugin plugin, DynmapCore core) {
|
||||
File datadir = core.getDataFolder();
|
||||
if(textYPosField == null) {
|
||||
if(initSpoutAccess() == false)
|
||||
return false;
|
||||
}
|
||||
HashMap<String, String> texturelist = new HashMap<String, String>();
|
||||
boolean use_existing_texture = core.configuration.getBoolean("spout/use-existing-textures", true);
|
||||
|
||||
int cnt = 0;
|
||||
File f = new File(datadir, "texturepacks/standard/spout");
|
||||
if(f.exists() == false)
|
||||
f.mkdirs();
|
||||
List<CustomBlock> blks = new ArrayList<CustomBlock>();
|
||||
CustomBlock[] cb = MaterialData.getCustomBlocks();
|
||||
/* Build new texture file as string */
|
||||
StringBuilder sb = new StringBuilder();
|
||||
/* Loop through blocks - try to freshen files, if needed */
|
||||
for(CustomBlock b : cb) {
|
||||
BlockDesign bd = b.getBlockDesign();
|
||||
if(bd == null) continue;
|
||||
String txtplug = bd.getTexturePlugin();
|
||||
if(txtplug == null) continue;
|
||||
String blkname = b.getName();
|
||||
if(blkname == null) continue;
|
||||
String blkid = txtplug + "." + fixIDString(blkname);
|
||||
/* If not GenericCubiodBlockDesign, we don't handle it */
|
||||
if((bd instanceof GenericCuboidBlockDesign) == false) {
|
||||
Log.info("Block " + blkid + " not suppored - only cubiod blocks");
|
||||
addDefaultBlock(sb, b);
|
||||
continue;
|
||||
}
|
||||
/* Get texture info */
|
||||
Texture txt = bd.getTexture();
|
||||
int w = txt.getWidth();
|
||||
int h = txt.getHeight();
|
||||
int sz = txt.getSpriteSize();
|
||||
GenericCuboidBlockDesign gbd = (GenericCuboidBlockDesign)bd;
|
||||
int[] txtidx = new int[6];
|
||||
/* Fetch quad fields - figure out which texture for which side */
|
||||
try {
|
||||
float[][] textXPos = (float[][])textXPosField.get(gbd);
|
||||
float[][] textYPos = (float[][])textYPosField.get(gbd);
|
||||
/* Quads on cuboid are bottom, west, south, east, north, top */
|
||||
for(int i = 0; i < 6; i++) {
|
||||
float minx = 1.0F;
|
||||
float miny = 1.0F;
|
||||
for(int j = 0; j < 4; j++) {
|
||||
minx = Math.min(minx, textXPos[i][j]);
|
||||
miny = Math.min(miny, textYPos[i][j]);
|
||||
}
|
||||
txtidx[i] = (int)((minx * w)/sz) + (w/sz)*(int)((miny * h)/sz);
|
||||
}
|
||||
} catch (Exception iax) {
|
||||
addDefaultBlock(sb, b);
|
||||
continue;
|
||||
}
|
||||
String txname = bd.getTexureURL();
|
||||
|
||||
String txtid = texturelist.get(txname); /* Get texture */
|
||||
if(txtid == null) { /* Not found yet */
|
||||
File imgfile = new File(f, blkid + ".png");
|
||||
|
||||
/* If not reusing loaded textures OR not previously loaded */
|
||||
if((!use_existing_texture) || (!imgfile.exists())) {
|
||||
BufferedImage img = null;
|
||||
boolean urlloaded = false;
|
||||
try {
|
||||
URL url = new URL(txname);
|
||||
img = ImageIO.read(url); /* Load skin for player */
|
||||
urlloaded = true;
|
||||
} catch (IOException iox) {
|
||||
if(txname.startsWith("http") == false) { /* Not URL - try file */
|
||||
File tf = new File(txname);
|
||||
if(tf.exists() == false) {
|
||||
/* Horrible hack - try to find temp file (some SpoutMaterials versions) */
|
||||
try {
|
||||
File tmpf = File.createTempFile("dynmap", "test");
|
||||
|
||||
tf = new File(tmpf.getParent(), txname);
|
||||
tmpf.delete();
|
||||
} catch (IOException iox2) {}
|
||||
}
|
||||
if(tf.exists()) {
|
||||
try {
|
||||
img = ImageIO.read(tf);
|
||||
urlloaded = true;
|
||||
} catch (IOException iox3) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(img == null) {
|
||||
Log.severe("Error loading texture for custom block '" + blkid + "' (" + b.getCustomId() + ") from " + txname + "(" + iox.getMessage() + ")");
|
||||
if(imgfile.exists()) {
|
||||
try {
|
||||
img = ImageIO.read(imgfile); /* Load existing */
|
||||
Log.info("Loaded cached texture file for " + blkid);
|
||||
} catch (IOException iox2) {
|
||||
Log.severe("Error loading cached texture file for " + blkid + " - " + iox2.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(img != null) {
|
||||
try {
|
||||
if(urlloaded)
|
||||
ImageIO.write(img, "png", imgfile);
|
||||
} catch (IOException iox) {
|
||||
Log.severe("Error writing " + blkid + ".png");
|
||||
} finally {
|
||||
img.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(imgfile.exists()) { /* If exists now, log it */
|
||||
String tfid = "txtid" + texturelist.size();
|
||||
sb.append("texturefile:id=" + tfid + ",filename=spout/" + blkid + ".png,xcount=" + w/sz + ",ycount=" + h/sz + "\n");
|
||||
texturelist.put(txname, tfid);
|
||||
}
|
||||
}
|
||||
String txfileid = texturelist.get(txname);
|
||||
if(txfileid != null) {
|
||||
blks.add(b);
|
||||
|
||||
sb.append("block:id=" + b.getCustomId() + ",data=*,bottom=" + txtidx[0] + ",west=" +txtidx[1] + ",south=" + txtidx[2] + ",east=" + txtidx[3] + ",north="+txtidx[4]+",top="+txtidx[5]);
|
||||
if(b.getBlockId() == Material.GLASS.getId())
|
||||
sb.append(",transparency=TRANSPARENT");
|
||||
sb.append(",txtid=" + txfileid + "\n");
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
String rslt = sb.toString();
|
||||
/* Now, generate spout texture file - see if changed */
|
||||
File st = new File(datadir, "renderdata/spout-texture.txt");
|
||||
if(st.exists()) {
|
||||
FileReader fr = null;
|
||||
StringBuilder sbold = new StringBuilder();
|
||||
try {
|
||||
fr = new FileReader(st);
|
||||
int len;
|
||||
char[] buf = new char[512];
|
||||
while((len = fr.read(buf)) > 0) {
|
||||
sbold.append(buf, 0, len);
|
||||
}
|
||||
} catch (IOException iox) {
|
||||
} finally {
|
||||
if(fr != null) { try { fr.close(); } catch (IOException iox) {} }
|
||||
}
|
||||
/* If same, no changes */
|
||||
if(sbold.equals(rslt)) {
|
||||
Log.info("Loaded " + cnt + " Spout custom blocks");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
FileWriter fw = null;
|
||||
try {
|
||||
fw = new FileWriter(st);
|
||||
fw.write(rslt);
|
||||
} catch (IOException iox) {
|
||||
Log.severe("Error opening spout texture file - " + st.getPath());
|
||||
return false;
|
||||
} finally {
|
||||
if(fw != null) { try { fw.close(); } catch (IOException iox) {} }
|
||||
}
|
||||
Log.info("Loaded " + cnt + " Spout custom blocks");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -35,15 +35,16 @@ public class GroupManagerPermissions implements PermissionProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(CommandSender sender, String permission) {
|
||||
public boolean has(CommandSender sender, String permission) {
|
||||
Player player = sender instanceof Player ? (Player) sender : null;
|
||||
return (player != null) ? wh.getWorldPermissions(player).has(player, name + "." + permission) : true;
|
||||
boolean rslt = (player != null) ? gm.getWorldsHolder().getDefaultWorld().getPermissionsHandler().permission(player, name + "." + permission) : true;
|
||||
return rslt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
|
||||
HashSet<String> hasperms = new HashSet<String>();
|
||||
AnjoPermissionsHandler apm = wh.getWorldPermissionsByPlayerName(player);
|
||||
AnjoPermissionsHandler apm = gm.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
if (apm != null) {
|
||||
for (String pp : perms) {
|
||||
if (apm.permission(player, name + "." + pp)) {
|
||||
@@ -55,10 +56,11 @@ public class GroupManagerPermissions implements PermissionProvider {
|
||||
}
|
||||
@Override
|
||||
public boolean hasOfflinePermission(String player, String perm) {
|
||||
AnjoPermissionsHandler apm = wh.getWorldPermissionsByPlayerName(player);
|
||||
AnjoPermissionsHandler apm = gm.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
boolean rslt = false;
|
||||
if(apm != null) {
|
||||
return apm.permission(player, name + "." + perm);
|
||||
rslt = apm.permission(player, name + "." + perm);
|
||||
}
|
||||
return false;
|
||||
return rslt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,9 @@ public class PEXPermissions implements PermissionProvider {
|
||||
server.getPluginManager().enablePlugin(permissionsPlugin);
|
||||
if(permissionsPlugin.isEnabled() == false)
|
||||
return null;
|
||||
if(PermissionsEx.isAvailable() == false)
|
||||
return null;
|
||||
//Broken in new dev builds, apparently
|
||||
//if(PermissionsEx.isAvailable() == false)
|
||||
// return null;
|
||||
Log.info("Using PermissionsEx " + permissionsPlugin.getDescription().getVersion() + " for access control");
|
||||
return new PEXPermissions(name);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,27 @@
|
||||
# The definitions of these templates are in normal-hi_boost_vhi.txt, nether-hi_boost_vhi.txt, and the_end-hi_boost_vhi.txt
|
||||
# To use the HDMap hi-res (16 ppb) map templates, with support for boosting resolution selectively to xhi-res (64 ppb), set value to hi_boost_xhi
|
||||
# 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: vlowres
|
||||
deftemplatesuffix: hires
|
||||
|
||||
# Map storage scheme: only uncommoent 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
|
||||
storage:
|
||||
# Filetree storage (standard tree of image files for maps)
|
||||
type: filetree
|
||||
# SQLite db for map storage (uses dbfile as storage location)
|
||||
#type: sqlite
|
||||
#dbfile: dynmap.db
|
||||
# MySQL DB for map storage (at 'hostname':'port' in database 'database' using user 'userid' password 'password' and table prefix 'prefix'
|
||||
#type: mysql
|
||||
#hostname: localhost
|
||||
#port: 3306
|
||||
#database: dynmap
|
||||
#userid: dynmap
|
||||
#password: dynmap
|
||||
#prefix: ""
|
||||
|
||||
components:
|
||||
- class: org.dynmap.ClientConfigurationComponent
|
||||
|
||||
@@ -86,6 +105,8 @@ components:
|
||||
type: markers
|
||||
showlabel: false
|
||||
enablesigns: false
|
||||
# Default marker set for sign markers
|
||||
default-sign-set: markers
|
||||
# (optional) add spawn point markers to standard marker layer
|
||||
showspawn: true
|
||||
spawnicon: world
|
||||
@@ -104,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
|
||||
@@ -193,6 +216,9 @@ usenormalthreadpriority: true
|
||||
# Save and restore pending tile renders - prevents their loss on server shutdown or /reload
|
||||
saverestorepending: true
|
||||
|
||||
# Save period for pending jobs (in seconds): periodic saving for crash recovery of jobs
|
||||
save-pending-period: 900
|
||||
|
||||
# Zoom-out tile update period - how often to scan for and process tile updates into zoom-out tiles (in seconds)
|
||||
zoomoutperiod: 30
|
||||
|
||||
@@ -216,6 +242,17 @@ enabletilehash: true
|
||||
# Optional - enable smooth lighting by default on all maps supporting it (can be set per map as lighting option)
|
||||
smooth-lighting: true
|
||||
|
||||
# Optional - use world provider lighting table (good for custom worlds with custom lighting curves, like nether)
|
||||
# false=classic Dynmap lighting curve
|
||||
use-brightness-table: true
|
||||
|
||||
# Optional - render specific block IDs using the texures and models of another block ID: can be used to hide/disguise specific
|
||||
# blocks (e.g. make ores look like stone, hide chests) or to provide simple support for rendering unsupported custom blocks
|
||||
block-id-alias:
|
||||
# "14": 1
|
||||
# "15": 1
|
||||
# "16": 1
|
||||
|
||||
# Default image format for HDMaps (png, jpg, jpg-q75, jpg-q80, jpg-q85, jpg-q90, jpg-q95, jpg-q100)
|
||||
# Has no effect on maps with explicit format settings
|
||||
image-format: png
|
||||
@@ -239,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)
|
||||
@@ -274,8 +311,12 @@ tilespath: web/tiles
|
||||
# The path where the web-files are located.
|
||||
webpath: web
|
||||
|
||||
# The path were the /dynmapexp command exports OBJ ZIP files
|
||||
exportpath: export
|
||||
|
||||
# The network-interface the webserver will bind to (0.0.0.0 for all interfaces, 127.0.0.1 for only local access).
|
||||
webserver-bindaddress: 0.0.0.0
|
||||
# If not set, uses same setting as server in server.properties (or 0.0.0.0 if not specified)
|
||||
#webserver-bindaddress: 0.0.0.0
|
||||
|
||||
# The TCP-port the webserver will listen on.
|
||||
webserver-port: 8123
|
||||
@@ -375,6 +416,9 @@ persist-ids-by-ip: true
|
||||
# If true, map text to cyrillic
|
||||
cyrillic-support: false
|
||||
|
||||
# If true, coordinates will be rounded
|
||||
round-coordinates: true
|
||||
|
||||
# Messages to customize
|
||||
msg:
|
||||
maptypes: "Map Types"
|
||||
@@ -430,3 +474,5 @@ verbose: false
|
||||
# Enables debugging.
|
||||
#debuggers:
|
||||
# - class: org.dynmap.debug.LogDebugger
|
||||
# Debug: dump blocks missing render data
|
||||
dump-missing-blocks: false
|
||||
|
||||
@@ -35,6 +35,7 @@ commands:
|
||||
/<command> purgeworld worldname - Delete all the files for world 'worldname'
|
||||
/<command> pause - Show render pause state
|
||||
/<command> pause <all|none|full|update> - Set render pause state
|
||||
/<command> quiet - Stop progress messages from active jobs
|
||||
/<command> ids-for-ip <ipaddress> - Show player IDs that have logged in from given IP address
|
||||
/<command> ips-for-id <playerid> - Show IP addresses that have been used for the given player ID
|
||||
/<command> add-id-for-ip <playerid> <ipaddress> - Add player ID to given IP address
|
||||
@@ -115,6 +116,10 @@ commands:
|
||||
/<command> mapset worldname:mapname attrib:value attrib:value - update given map on given world with given attributes
|
||||
/<command> worldreset worldname - reset given world to default template for world type
|
||||
/<command> worldreset worldname templatename - reset given world to given template
|
||||
dynmapexp:
|
||||
description: Map export commands
|
||||
usage: |
|
||||
/<command> shader <shadername> - Export material library for shader <shadername>
|
||||
|
||||
permissions:
|
||||
dynmap.*:
|
||||
@@ -136,6 +141,7 @@ permissions:
|
||||
dynmap.purgequeue: true
|
||||
dynmap.purgemap: true
|
||||
dynmap.purgeworld: true
|
||||
dynmap.quiet: true
|
||||
dynmap.ids-for-ip: true
|
||||
dynmap.ips-for-id: true
|
||||
dynmap.webregister: true
|
||||
@@ -230,6 +236,9 @@ permissions:
|
||||
dynmap.pause:
|
||||
description: Allows /dynmap pause
|
||||
default: op
|
||||
dynmap.quiet:
|
||||
description: Allows /dynmap quiet
|
||||
default: true
|
||||
dynmap.ids-for-ip:
|
||||
description: Allows /dynmap ids-for-ip
|
||||
default: op
|
||||
@@ -239,7 +248,7 @@ permissions:
|
||||
dynmap.webregister:
|
||||
description: Allows /dynmap webregister
|
||||
default: true
|
||||
dynmao,webregister.other:
|
||||
dynmap.webregister.other:
|
||||
description: Allows /dynmap webregister userid
|
||||
default: op
|
||||
dynmap.marker.add:
|
||||
|
||||
Reference in New Issue
Block a user