mirror of
https://github.com/encounter/dynmap.git
synced 2026-03-30 11:08:39 -07:00
Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d4aaa1d1fd | |||
| fe83a7d1cc | |||
| d4e24e9d26 | |||
| 734937884a | |||
| 3efe3c3d3d | |||
| 46ab344197 | |||
| 9270ce853d | |||
| 04a2019e9d | |||
| 8daf95891d | |||
| 5396d0b823 | |||
| a2ab8c4f2f | |||
| e7efbe193a | |||
| 99ea38d02a | |||
| 7c6e660cf0 | |||
| bcd0acec33 | |||
| 7e07bff71f | |||
| 2d95548d25 | |||
| 3ac67ce2c5 | |||
| 0d25fd2edc | |||
| bee16ef331 | |||
| bf16d18371 | |||
| e57634ebb3 | |||
| 55a5aacfce | |||
| e6fe29f0c5 | |||
| 34712e27f0 | |||
| 6a5eebcc00 | |||
| c8b1f71949 | |||
| dc11ef3507 | |||
| d0bbb78e98 | |||
| 9144bff25b | |||
| 18325c2b33 | |||
| f1a686eaf8 | |||
| b3c32456ca | |||
| be16ac089f | |||
| 44a8bfa38d | |||
| 443d64f7da | |||
| 9ad5a7e4f7 | |||
| 3483b19cef | |||
| 44c5d51c4e | |||
| 56d1bcf3eb | |||
| f43027f02f | |||
| bd12420edd | |||
| 3c01aff411 | |||
| 4d664de250 | |||
| 278fa36f94 | |||
| 1a2f63bcfb | |||
| 344d9bf1c9 | |||
| 70b27b8034 | |||
| abe7fc8405 | |||
| 4fa62993f4 | |||
| 08a920694b | |||
| 4bdb331eb0 | |||
| cb7c9061e8 | |||
| 29cb155534 | |||
| ada85ed960 | |||
| bfb12aa0f3 | |||
| 3342977a92 | |||
| 07cbd84d44 | |||
| da5e2cf24a | |||
| c6d345d8f1 | |||
| 3a57261120 | |||
| a39f99cab8 | |||
| f0885abea2 | |||
| 2b17cb215b | |||
| 68f0c17f70 | |||
| a20e55beab | |||
| 413542fe61 | |||
| a250732d31 | |||
| 07f2496f2f | |||
| 2f6e52261c | |||
| a117987840 | |||
| cbb8cc061e | |||
| c03365d574 | |||
| 827f18b8e0 | |||
| 1603015631 | |||
| c2d97ba3d5 | |||
| 418b175923 | |||
| fdc14b413d | |||
| e6d509c3e6 | |||
| b10ec3a331 | |||
| 9f8617d81d | |||
| 265e037b74 | |||
| f50e73180c |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
dynmap.render # Render current chunk
|
||||
dynmap.fullrender # Issue a full render
|
||||
dynmap.hide.self # Hide self from map
|
||||
dynmap.hide.others # Hide others from map
|
||||
dynmap.show.self # Reveal self on map
|
||||
dynmap.show.others # Reveal others on map
|
||||
@@ -2,11 +2,10 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<artifactId>dynmap</artifactId>
|
||||
<version>0.70.3</version>
|
||||
<name>dynmap</name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<BUILD_NUMBER>dev</BUILD_NUMBER>
|
||||
<BUILD_NUMBER>Dev</BUILD_NUMBER>
|
||||
</properties>
|
||||
<url>http://github.com/webbukkit/dynmap/</url>
|
||||
<issueManagement>
|
||||
@@ -42,31 +41,6 @@
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>unpack</id>
|
||||
<phase>package</phase>
|
||||
<goals><goal>unpack</goal></goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<artifactId>DynmapCore</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>bin</classifier>
|
||||
<type>zip</type>
|
||||
<outputDirectory>${project.build.directory}/core</outputDirectory>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -89,29 +63,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/package.xml</descriptor>
|
||||
</descriptors>
|
||||
<!-- Hack for bug in maven-assembly: http://jira.codehaus.org/browse/MASSEMBLY-449 -->
|
||||
<archiverConfig>
|
||||
<fileMode>420</fileMode> <!-- 420(dec) = 644(oct) -->
|
||||
<directoryMode>493</directoryMode> <!-- 493(dec) = 755(oct) -->
|
||||
<defaultDirectoryMode>493</defaultDirectoryMode>
|
||||
</archiverConfig>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
@@ -120,22 +71,28 @@
|
||||
</releases>
|
||||
<snapshots>
|
||||
</snapshots>
|
||||
<id>spout-repo</id>
|
||||
<url>http://repo.spout.org</url>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<releases>
|
||||
</releases>
|
||||
<snapshots>
|
||||
</snapshots>
|
||||
<id>dynmap-repo</id>
|
||||
<url>http://repo.mikeprimm.com/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.nijikokun.bukkit</groupId>
|
||||
<artifactId>Permissions</artifactId>
|
||||
<version>[2.5.4,)</version>
|
||||
<version>3.1.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>[1.2.5-R4.0,1.7)</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
<version>1.3.2-R3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dynmap</groupId>
|
||||
@@ -162,27 +119,22 @@
|
||||
<groupId>ru.tehkode</groupId>
|
||||
<artifactId>PermissionsEx</artifactId>
|
||||
<version>1.19.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/PermissionsEx.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.bananaco</groupId>
|
||||
<artifactId>bPermissions</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/bpermissions.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platymuus.bukkit.permissions</groupId>
|
||||
<artifactId>PermissionsBukkit</artifactId>
|
||||
<version>1.6</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/PermissionsBukkit.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.2.5-R5.1-SNAPSHOT</version>
|
||||
<groupId>org.anjocaido</groupId>
|
||||
<artifactId>EssentialsGroupManager</artifactId>
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<version>1.7</version>
|
||||
</project>
|
||||
|
||||
@@ -7,15 +7,7 @@
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.build.directory}/core</directory>
|
||||
<outputDirectory>/dynmap</outputDirectory>
|
||||
<excludes>
|
||||
<exclude>web/version.js</exclude></excludes></fileSet>
|
||||
<fileSet>
|
||||
<directory>${project.build.directory}/core/web</directory>
|
||||
<outputDirectory>/dynmap/web</outputDirectory>
|
||||
<includes>
|
||||
<include>version.js</include></includes>
|
||||
<filtered>true</filtered></fileSet>
|
||||
<outputDirectory>/dynmap</outputDirectory></fileSet>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}</directory>
|
||||
<outputDirectory>/dynmap</outputDirectory>
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
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.dynmap.Log;
|
||||
|
||||
/**
|
||||
* Helper for isolation of bukkit version specific issues
|
||||
*/
|
||||
public abstract class BukkitVersionHelper {
|
||||
|
||||
private static BukkitVersionHelper helper = null;
|
||||
|
||||
public static final BukkitVersionHelper getHelper() {
|
||||
if(helper == null) {
|
||||
if(Bukkit.getServer().getVersion().contains("MCPC")) {
|
||||
Log.severe("*********************************************************************************");
|
||||
Log.severe("* MCPC-Plus is no longer supported via the Bukkit version of Dynmap. *");
|
||||
Log.severe("* Install the appropriate Forge version of Dynmap. *");
|
||||
Log.severe("* Add the DynmapCBBridge plugin to enable support for Dynmap-compatible plugins *");
|
||||
Log.severe("*********************************************************************************");
|
||||
}
|
||||
else if(Bukkit.getServer().getVersion().contains("BukkitForge")) {
|
||||
Log.severe("*********************************************************************************");
|
||||
Log.severe("* BukkitForge is not supported via the Bukkit version of Dynmap. *");
|
||||
Log.severe("* Install the appropriate Forge version of Dynmap. *");
|
||||
Log.severe("* Add the DynmapCBBridge plugin to enable support for Dynmap-compatible plugins *");
|
||||
Log.severe("*********************************************************************************");
|
||||
}
|
||||
else {
|
||||
helper = new BukkitVersionHelperCB();
|
||||
}
|
||||
}
|
||||
return helper;
|
||||
}
|
||||
protected BukkitVersionHelper() {
|
||||
|
||||
}
|
||||
/**
|
||||
* Get list of defined biomebase objects
|
||||
*/
|
||||
public abstract Object[] getBiomeBaseList();
|
||||
/**
|
||||
* Get temperature from biomebase
|
||||
*/
|
||||
public abstract float getBiomeBaseTemperature(Object bb);
|
||||
/**
|
||||
* Get humidity from biomebase
|
||||
*/
|
||||
public abstract float getBiomeBaseHumidity(Object bb);
|
||||
/**
|
||||
* Get ID string from biomebase
|
||||
*/
|
||||
public abstract String getBiomeBaseIDString(Object bb);
|
||||
/**
|
||||
* 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);
|
||||
/**
|
||||
* For testing unload queue for presence of givne chunk
|
||||
*/
|
||||
public abstract boolean isInUnloadQueue(Object unloadqueue, int x, int z);
|
||||
/**
|
||||
* Read raw biome ID from snapshot
|
||||
*/
|
||||
public abstract Object[] getBiomeBaseFromSnapshot(ChunkSnapshot css);
|
||||
/**
|
||||
* Test if normal chunk snapshot
|
||||
*/
|
||||
public abstract boolean isCraftChunkSnapshot(ChunkSnapshot css);
|
||||
/**
|
||||
* Remove entities from given chunk
|
||||
*/
|
||||
public abstract void removeEntitiesFromChunk(Chunk c);
|
||||
/**
|
||||
* Get tile entities map from chunk
|
||||
*/
|
||||
public abstract Map getTileEntitiesForChunk(Chunk c);
|
||||
/**
|
||||
* Get X coordinate of tile entity
|
||||
*/
|
||||
public abstract int getTileEntityX(Object te);
|
||||
/**
|
||||
* Get Y coordinate of tile entity
|
||||
*/
|
||||
public abstract int getTileEntityY(Object te);
|
||||
/**
|
||||
* Get Z coordinate of tile entity
|
||||
*/
|
||||
public abstract int getTileEntityZ(Object te);
|
||||
/**
|
||||
* Read tile entity NBT
|
||||
*/
|
||||
public abstract Object readTileEntityNBT(Object te);
|
||||
/**
|
||||
* Get field value from NBT compound
|
||||
*/
|
||||
public abstract Object getFieldValue(Object nbt, String field);
|
||||
/**
|
||||
* Unload chunk no save needed
|
||||
*/
|
||||
public abstract void unloadChunkNoSave(World w, Chunk c, int cx, int cz);
|
||||
/**
|
||||
* Get block short name list
|
||||
*/
|
||||
public abstract String[] getBlockShortNames();
|
||||
/**
|
||||
* Get biome name list
|
||||
*/
|
||||
public abstract String[] getBiomeNames();
|
||||
/**
|
||||
* Get block material index list
|
||||
*/
|
||||
public abstract int[] getBlockMaterialMap();
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.common.BiomeMap;
|
||||
|
||||
/**
|
||||
* Helper for isolation of bukkit version specific issues
|
||||
*/
|
||||
public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
private Class<?> nmsblock;
|
||||
private Class<?> nmsblockarray;
|
||||
private Class<?> nmsmaterial;
|
||||
private Field blockbyid;
|
||||
private Field blockname;
|
||||
private Field material;
|
||||
|
||||
BukkitVersionHelperCB() {
|
||||
}
|
||||
@Override
|
||||
protected String getNMSPackage() {
|
||||
Server srv = Bukkit.getServer();
|
||||
/* Get getHandle() method */
|
||||
try {
|
||||
Method m = srv.getClass().getMethod("getHandle");
|
||||
Object scm = m.invoke(srv); /* And use it to get SCM (nms object) */
|
||||
return scm.getClass().getPackage().getName();
|
||||
} catch (Exception x) {
|
||||
Log.severe("Error finding net.minecraft.server packages");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void loadNMS() {
|
||||
// Get block fields
|
||||
nmsblock = getNMSClass("net.minecraft.server.Block");
|
||||
nmsblockarray = getNMSClass("[Lnet.minecraft.server.Block;");
|
||||
nmsmaterial = getNMSClass("net.minecraft.server.Material");
|
||||
blockbyid = getField(nmsblock, new String[] { "byId" }, nmsblockarray);
|
||||
blockname = getPrivateField(nmsblock, new String[] { "name" }, String.class);
|
||||
material = getField(nmsblock, new String[] { "material" }, nmsmaterial);
|
||||
|
||||
/* Set up biomebase fields */
|
||||
biomebase = getNMSClass("net.minecraft.server.BiomeBase");
|
||||
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
|
||||
biomebaselist = getField(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);
|
||||
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);
|
||||
|
||||
longhashset = getOBCClassNoFail("org.bukkit.craftbukkit.util.LongHashSet");
|
||||
if(longhashset != null) {
|
||||
lhs_containskey = getMethod(longhashset, new String[] { "contains" }, new Class[] { int.class, int.class });
|
||||
}
|
||||
else {
|
||||
longhashset = getOBCClass("org.bukkit.craftbukkit.util.LongHashset");
|
||||
lhs_containskey = getMethod(longhashset, new String[] { "containsKey" }, new Class[] { int.class, int.class });
|
||||
}
|
||||
|
||||
cps_unloadqueue = getFieldNoFail(chunkprovserver, new String[] { "unloadQueue" }, longhashset);
|
||||
if(cps_unloadqueue == null) {
|
||||
Log.info("Unload queue not found - default to unload all chunks");
|
||||
}
|
||||
/** 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);
|
||||
/** nbt classes */
|
||||
nbttagcompound = getNMSClass("net.minecraft.server.NBTTagCompound");
|
||||
nbttagbyte = getNMSClass("net.minecraft.server.NBTTagByte");
|
||||
nbttagshort = getNMSClass("net.minecraft.server.NBTTagShort");
|
||||
nbttagint = getNMSClass("net.minecraft.server.NBTTagInt");
|
||||
nbttaglong = getNMSClass("net.minecraft.server.NBTTagLong");
|
||||
nbttagfloat = getNMSClass("net.minecraft.server.NBTTagFloat");
|
||||
nbttagdouble = getNMSClass("net.minecraft.server.NBTTagDouble");
|
||||
nbttagbytearray = getNMSClass("net.minecraft.server.NBTTagByteArray");
|
||||
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);
|
||||
|
||||
/** 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);
|
||||
}
|
||||
@Override
|
||||
public void unloadChunkNoSave(World w, Chunk c, int cx, int cz) {
|
||||
this.removeEntitiesFromChunk(c);
|
||||
w.unloadChunk(cx, cz, false, false);
|
||||
}
|
||||
/**
|
||||
* Get block short name list
|
||||
*/
|
||||
@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]);
|
||||
}
|
||||
}
|
||||
return names;
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
/**
|
||||
* Get biome name list
|
||||
*/
|
||||
@Override
|
||||
public String[] getBiomeNames() {
|
||||
String[] names;
|
||||
/* Find array of biomes in biomebase */
|
||||
Object[] biomelist = getBiomeBaseList();
|
||||
names = new String[biomelist.length];
|
||||
/* Loop through list, starting afer well known biomes */
|
||||
for(int i = 0; i < biomelist.length; i++) {
|
||||
Object bb = biomelist[i];
|
||||
if(bb != null) {
|
||||
names[i] = getBiomeBaseIDString(bb);
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
/**
|
||||
* Get block material index list
|
||||
*/
|
||||
public int[] getBlockMaterialMap() {
|
||||
try {
|
||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||
int[] map = new int[byid.length];
|
||||
ArrayList<Object> mats = new ArrayList<Object>();
|
||||
for (int i = 0; i < map.length; i++) {
|
||||
if (byid[i] != null) {
|
||||
Object mat = (Object)material.get(byid[i]);
|
||||
if (mat != null) {
|
||||
map[i] = mats.indexOf(mat);
|
||||
if (map[i] < 0) {
|
||||
map[i] = mats.size();
|
||||
mats.add(mat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
map[i] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
return new int[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
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.dynmap.Log;
|
||||
|
||||
/**
|
||||
* Helper for isolation of bukkit version specific issues
|
||||
*/
|
||||
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];
|
||||
private static final Map nullmap = Collections.emptyMap();
|
||||
|
||||
/** CraftChunkSnapshot */
|
||||
private Class<?> craftchunksnapshot;
|
||||
private Field ccss_biome;
|
||||
/** CraftChunk */
|
||||
private Class<?> craftchunk;
|
||||
private Method cc_gethandle;
|
||||
/** CraftWorld */
|
||||
private Class<?> craftworld;
|
||||
private Method cw_gethandle;
|
||||
|
||||
/** BiomeBase related helpers */
|
||||
protected Class<?> biomebase;
|
||||
protected Class<?> biomebasearray;
|
||||
protected Field biomebaselist;
|
||||
protected Field biomebasetemp;
|
||||
protected Field biomebasehumi;
|
||||
protected Field biomebaseidstring;
|
||||
protected Field biomebaseid;
|
||||
/** n.m.s.World */
|
||||
protected Class<?> nmsworld;
|
||||
protected Class<?> chunkprovserver;
|
||||
protected Class<?> longhashset;
|
||||
protected Field nmsw_chunkproviderserver;
|
||||
protected Field cps_unloadqueue;
|
||||
protected Method lhs_containskey;
|
||||
/** n.m.s.Chunk */
|
||||
protected Class<?> nmschunk;
|
||||
protected Method nmsc_removeentities;
|
||||
protected Field nmsc_tileentities;
|
||||
/** nbt classes */
|
||||
protected Class<?> nbttagcompound;
|
||||
protected Class<?> nbttagbyte;
|
||||
protected Class<?> nbttagshort;
|
||||
protected Class<?> nbttagint;
|
||||
protected Class<?> nbttaglong;
|
||||
protected Class<?> nbttagfloat;
|
||||
protected Class<?> nbttagdouble;
|
||||
protected Class<?> nbttagbytearray;
|
||||
protected Class<?> nbttagstring;
|
||||
protected Class<?> nbttagintarray;
|
||||
protected Method compound_get;
|
||||
protected Field nbttagbyte_val;
|
||||
protected Field nbttagshort_val;
|
||||
protected Field nbttagint_val;
|
||||
protected Field nbttaglong_val;
|
||||
protected Field nbttagfloat_val;
|
||||
protected Field nbttagdouble_val;
|
||||
protected Field nbttagbytearray_val;
|
||||
protected Field nbttagstring_val;
|
||||
protected Field nbttagintarray_val;
|
||||
/** Tile entity */
|
||||
protected Class<?> nms_tileentity;
|
||||
protected Method nmst_readnbt;
|
||||
protected Field nmst_x;
|
||||
protected Field nmst_y;
|
||||
protected Field nmst_z;
|
||||
|
||||
BukkitVersionHelperGeneric() {
|
||||
failed = false;
|
||||
Server srv = Bukkit.getServer();
|
||||
/* Look up base classname for bukkit server - tells us OBC package */
|
||||
obc_package = Bukkit.getServer().getClass().getPackage().getName();
|
||||
/* Get NMS package */
|
||||
nms_package = getNMSPackage();
|
||||
if(nms_package == null) {
|
||||
failed = true;
|
||||
}
|
||||
/* Craftworld fields */
|
||||
craftworld = getOBCClass("org.bukkit.craftbukkit.CraftWorld");
|
||||
cw_gethandle = getMethod(craftworld, new String[] { "getHandle" }, new Class[0]);
|
||||
/* CraftChunkSnapshot */
|
||||
craftchunksnapshot = getOBCClass("org.bukkit.craftbukkit.CraftChunkSnapshot");
|
||||
ccss_biome = getPrivateField(craftchunksnapshot, new String[] { "biome" }, biomebasearray);
|
||||
/* CraftChunk */
|
||||
craftchunk = getOBCClass("org.bukkit.craftbukkit.CraftChunk");
|
||||
cc_gethandle = getMethod(craftchunk, new String[] { "getHandle" }, new Class[0]);
|
||||
/* Get NMS classes and fields */
|
||||
if(!failed)
|
||||
loadNMS();
|
||||
|
||||
if(failed)
|
||||
throw new IllegalArgumentException("Error initializing dynmap - bukkit version incompatible!");
|
||||
}
|
||||
|
||||
protected abstract void loadNMS();
|
||||
|
||||
protected abstract String getNMSPackage();
|
||||
|
||||
protected Class<?> getOBCClass(String classname) {
|
||||
return getClassByName(classname, "org.bukkit.craftbukkit", obc_package, false);
|
||||
}
|
||||
|
||||
protected Class<?> getOBCClassNoFail(String classname) {
|
||||
return getClassByName(classname, "org.bukkit.craftbukkit", obc_package, true);
|
||||
}
|
||||
|
||||
protected Class<?> getNMSClass(String classname) {
|
||||
return getClassByName(classname, "net.minecraft.server", nms_package, false);
|
||||
}
|
||||
|
||||
protected Class<?> getClassByName(String classname, String base, String mapping, boolean nofail) {
|
||||
String n = classname;
|
||||
int idx = classname.indexOf(base);
|
||||
if(idx >= 0) {
|
||||
n = classname.substring(0, idx) + mapping + classname.substring(idx + base.length());
|
||||
}
|
||||
try {
|
||||
return Class.forName(n);
|
||||
} catch (ClassNotFoundException cnfx) {
|
||||
try {
|
||||
return Class.forName(classname);
|
||||
} catch (ClassNotFoundException cnfx2) {
|
||||
if(!nofail) {
|
||||
Log.severe("Cannot find " + classname);
|
||||
failed = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get field
|
||||
*/
|
||||
protected Field getField(Class<?> cls, String[] ids, Class<?> type) {
|
||||
return getField(cls, ids, type, false);
|
||||
}
|
||||
protected Field getFieldNoFail(Class<?> cls, String[] ids, Class<?> type) {
|
||||
return getField(cls, ids, type, true);
|
||||
}
|
||||
/**
|
||||
* Get field
|
||||
*/
|
||||
private Field getField(Class<?> cls, String[] ids, Class<?> type, boolean nofail) {
|
||||
if((cls == null) || (type == null)) return null;
|
||||
for(String id : ids) {
|
||||
try {
|
||||
Field f = cls.getField(id);
|
||||
if(f.getType().isAssignableFrom(type)) {
|
||||
return f;
|
||||
}
|
||||
} catch (NoSuchFieldException nsfx) {
|
||||
}
|
||||
}
|
||||
if(!nofail) {
|
||||
Log.severe("Unable to find field " + ids[0] + " for " + cls.getName());
|
||||
failed = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Get private field
|
||||
*/
|
||||
protected Field getPrivateField(Class<?> cls, String[] ids, Class<?> type) {
|
||||
if((cls == null) || (type == null)) return null;
|
||||
for(String id : ids) {
|
||||
try {
|
||||
Field f = cls.getDeclaredField(id);
|
||||
if(f.getType().isAssignableFrom(type)) {
|
||||
f.setAccessible(true);
|
||||
return f;
|
||||
}
|
||||
} catch (NoSuchFieldException nsfx) {
|
||||
}
|
||||
}
|
||||
Log.severe("Unable to find field " + ids[0] + " for " + cls.getName());
|
||||
failed = true;
|
||||
return null;
|
||||
}
|
||||
protected Object getFieldValue(Object obj, Field field, Object def) {
|
||||
if((obj != null) && (field != null)) {
|
||||
try {
|
||||
return field.get(obj);
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
}
|
||||
return def;
|
||||
}
|
||||
/**
|
||||
* Get method
|
||||
*/
|
||||
protected Method getMethod(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) {
|
||||
}
|
||||
}
|
||||
Log.severe("Unable to find method " + ids[0] + " for " + cls.getName());
|
||||
failed = true;
|
||||
return null;
|
||||
}
|
||||
private Object callMethod(Object obj, Method meth, Object[] args, Object def) {
|
||||
if((obj == null) || (meth == null)) {
|
||||
return def;
|
||||
}
|
||||
try {
|
||||
return meth.invoke(obj, args);
|
||||
} catch (IllegalArgumentException iax) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get list of defined biomebase objects
|
||||
*/
|
||||
public Object[] getBiomeBaseList() {
|
||||
return (Object[]) getFieldValue(biomebase, biomebaselist, new Object[0]);
|
||||
}
|
||||
/** Get temperature from biomebase */
|
||||
public float getBiomeBaseTemperature(Object bb) {
|
||||
return (Float) getFieldValue(bb, biomebasetemp, 0.5F);
|
||||
}
|
||||
/** Get humidity from biomebase */
|
||||
public float getBiomeBaseHumidity(Object bb) {
|
||||
return (Float) getFieldValue(bb, biomebasehumi, 0.5F);
|
||||
}
|
||||
/** Get ID string from biomebase */
|
||||
public String getBiomeBaseIDString(Object bb) {
|
||||
return (String) getFieldValue(bb, biomebaseidstring, null);
|
||||
}
|
||||
/** Get ID from biomebase */
|
||||
public int getBiomeBaseID(Object bb) {
|
||||
return (Integer) getFieldValue(bb, biomebaseid, -1);
|
||||
}
|
||||
|
||||
/* Get net.minecraft.server.world for given world */
|
||||
public 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
|
||||
if(cps != null) {
|
||||
return getFieldValue(cps, cps_unloadqueue, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* For testing unload queue for presence of givne chunk */
|
||||
public boolean isInUnloadQueue(Object unloadqueue, int x, int z) {
|
||||
if(unloadqueue != null) {
|
||||
return (Boolean)callMethod(unloadqueue, lhs_containskey, new Object[] { x, z }, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
/** 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 tile entities map from chunk */
|
||||
public Map getTileEntitiesForChunk(Chunk c) {
|
||||
Object omsc = callMethod(c, cc_gethandle, nullargs, null);
|
||||
if(omsc != null) {
|
||||
return (Map)getFieldValue(omsc, nmsc_tileentities, nullmap);
|
||||
}
|
||||
return nullmap;
|
||||
}
|
||||
/**
|
||||
* Get X coordinate of tile entity
|
||||
*/
|
||||
public int getTileEntityX(Object te) {
|
||||
return (Integer)getFieldValue(te, nmst_x, 0);
|
||||
}
|
||||
/**
|
||||
* Get Y coordinate of tile entity
|
||||
*/
|
||||
public int getTileEntityY(Object te) {
|
||||
return (Integer)getFieldValue(te, nmst_y, 0);
|
||||
}
|
||||
/**
|
||||
* Get Z coordinate of tile entity
|
||||
*/
|
||||
public int getTileEntityZ(Object te) {
|
||||
return (Integer)getFieldValue(te, nmst_z, 0);
|
||||
}
|
||||
/**
|
||||
* Read tile entity NBT
|
||||
*/
|
||||
public Object readTileEntityNBT(Object te) {
|
||||
if(nbttagcompound == null) return null;
|
||||
Object nbt = null;
|
||||
try {
|
||||
nbt = nbttagcompound.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
if(nbt != null) {
|
||||
callMethod(te, nmst_readnbt, new Object[] { nbt }, null);
|
||||
}
|
||||
return nbt;
|
||||
}
|
||||
/**
|
||||
* Get field value from NBT compound
|
||||
*/
|
||||
public Object getFieldValue(Object nbt, String field) {
|
||||
Object val = callMethod(nbt, compound_get, new Object[] { field }, null);
|
||||
if(val == null) return null;
|
||||
Class<?> valcls = val.getClass();
|
||||
if(valcls.equals(nbttagbyte)) {
|
||||
return getFieldValue(val, nbttagbyte_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagshort)) {
|
||||
return getFieldValue(val, nbttagshort_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagint)) {
|
||||
return getFieldValue(val, nbttagint_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttaglong)) {
|
||||
return getFieldValue(val, nbttaglong_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagfloat)) {
|
||||
return getFieldValue(val, nbttagfloat_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagdouble)) {
|
||||
return getFieldValue(val, nbttagdouble_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagbytearray)) {
|
||||
return getFieldValue(val, nbttagbytearray_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagstring)) {
|
||||
return getFieldValue(val, nbttagstring_val, null);
|
||||
}
|
||||
else if(valcls.equals(nbttagintarray)) {
|
||||
return getFieldValue(val, nbttagintarray_val, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -17,13 +17,36 @@ public class BukkitWorld extends DynmapWorld {
|
||||
private World world;
|
||||
private World.Environment env;
|
||||
private boolean skylight;
|
||||
private DynmapLocation spawnloc = new DynmapLocation();
|
||||
|
||||
public BukkitWorld(World w) {
|
||||
super(w.getName(), w.getMaxHeight(), w.getSeaLevel());
|
||||
this(w.getName(), w.getMaxHeight(), w.getSeaLevel(), w.getEnvironment());
|
||||
setWorldLoaded(w);
|
||||
new Permission("dynmap.world." + getName(), "Dynmap access for world " + getName(), PermissionDefault.OP);
|
||||
}
|
||||
public BukkitWorld(String name, int height, int sealevel, World.Environment env) {
|
||||
super(name, height, sealevel);
|
||||
world = null;
|
||||
this.env = env;
|
||||
skylight = (env == World.Environment.NORMAL);
|
||||
new Permission("dynmap.world." + getName(), "Dynmap access for world " + getName(), PermissionDefault.OP);
|
||||
}
|
||||
/**
|
||||
* Set world online
|
||||
* @param w - loaded world
|
||||
*/
|
||||
public void setWorldLoaded(World w) {
|
||||
world = w;
|
||||
env = world.getEnvironment();
|
||||
skylight = (env == World.Environment.NORMAL);
|
||||
new Permission("dynmap.world." + getName(), "Dynmap access for world " + getName(), PermissionDefault.OP);
|
||||
}
|
||||
/**
|
||||
* Set world unloaded
|
||||
*/
|
||||
@Override
|
||||
public void setWorldUnloaded() {
|
||||
getSpawnLocation(); /* Remember spawn location before unload */
|
||||
world = null;
|
||||
}
|
||||
/* Test if world is nether */
|
||||
@Override
|
||||
@@ -33,26 +56,44 @@ public class BukkitWorld extends DynmapWorld {
|
||||
/* Get world spawn location */
|
||||
@Override
|
||||
public DynmapLocation getSpawnLocation() {
|
||||
DynmapLocation dloc = new DynmapLocation();
|
||||
Location sloc = world.getSpawnLocation();
|
||||
dloc.x = sloc.getBlockX(); dloc.y = sloc.getBlockY();
|
||||
dloc.z = sloc.getBlockZ(); dloc.world = normalizeWorldName(sloc.getWorld().getName());
|
||||
return dloc;
|
||||
if(world != null) {
|
||||
Location sloc = world.getSpawnLocation();
|
||||
spawnloc.x = sloc.getBlockX();
|
||||
spawnloc.y = sloc.getBlockY();
|
||||
spawnloc.z = sloc.getBlockZ();
|
||||
spawnloc.world = normalizeWorldName(sloc.getWorld().getName());
|
||||
}
|
||||
return spawnloc;
|
||||
}
|
||||
/* Get world time */
|
||||
@Override
|
||||
public long getTime() {
|
||||
return world.getTime();
|
||||
if(world != null) {
|
||||
return world.getTime();
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* World is storming */
|
||||
@Override
|
||||
public boolean hasStorm() {
|
||||
return world.hasStorm();
|
||||
if(world != null) {
|
||||
return world.hasStorm();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/* World is thundering */
|
||||
@Override
|
||||
public boolean isThundering() {
|
||||
return world.isThundering();
|
||||
if(world != null) {
|
||||
return world.isThundering();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/* World is loaded */
|
||||
@Override
|
||||
@@ -62,22 +103,37 @@ public class BukkitWorld extends DynmapWorld {
|
||||
/* Get light level of block */
|
||||
@Override
|
||||
public int getLightLevel(int x, int y, int z) {
|
||||
return world.getBlockAt(x, y, z).getLightLevel();
|
||||
if(world != null) {
|
||||
return world.getBlockAt(x, y, z).getLightLevel();
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* Get highest Y coord of given location */
|
||||
@Override
|
||||
public int getHighestBlockYAt(int x, int z) {
|
||||
return world.getHighestBlockYAt(x, z);
|
||||
if(world != null) {
|
||||
return world.getHighestBlockYAt(x, z);
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* Test if sky light level is requestable */
|
||||
@Override
|
||||
public boolean canGetSkyLightLevel() {
|
||||
return skylight;
|
||||
return skylight && (world != null);
|
||||
}
|
||||
/* Return sky light level */
|
||||
@Override
|
||||
public int getSkyLightLevel(int x, int y, int z) {
|
||||
return world.getBlockAt(x, y, z).getLightFromSky();
|
||||
if(world != null) {
|
||||
return world.getBlockAt(x, y, z).getLightFromSky();
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get world environment ID (lower case - normal, the_end, nether)
|
||||
@@ -91,9 +147,14 @@ public class BukkitWorld extends DynmapWorld {
|
||||
*/
|
||||
@Override
|
||||
public MapChunkCache getChunkCache(List<DynmapChunk> chunks) {
|
||||
NewMapChunkCache c = new NewMapChunkCache();
|
||||
c.setChunks(this, chunks);
|
||||
return c;
|
||||
if(isLoaded()) {
|
||||
NewMapChunkCache c = new NewMapChunkCache();
|
||||
c.setChunks(this, chunks);
|
||||
return c;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -8,15 +8,21 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.dynmap.utils.DynIntHashMap;
|
||||
|
||||
public class SnapshotCache {
|
||||
public static class SnapshotRec {
|
||||
public ChunkSnapshot ss;
|
||||
public DynIntHashMap tileData;
|
||||
};
|
||||
|
||||
private CacheHashMap snapcache;
|
||||
private ReferenceQueue<ChunkSnapshot> refqueue;
|
||||
private ReferenceQueue<SnapshotRec> refqueue;
|
||||
private long cache_attempts;
|
||||
private long cache_success;
|
||||
|
||||
private static class CacheRec {
|
||||
WeakReference<ChunkSnapshot> ref;
|
||||
WeakReference<SnapshotRec> ref;
|
||||
boolean hasbiome;
|
||||
boolean hasrawbiome;
|
||||
boolean hasblockdata;
|
||||
@@ -26,12 +32,12 @@ public class SnapshotCache {
|
||||
@SuppressWarnings("serial")
|
||||
public class CacheHashMap extends LinkedHashMap<String, CacheRec> {
|
||||
private int limit;
|
||||
private IdentityHashMap<WeakReference<ChunkSnapshot>, String> reverselookup;
|
||||
private IdentityHashMap<WeakReference<SnapshotRec>, String> reverselookup;
|
||||
|
||||
public CacheHashMap(int lim) {
|
||||
super(16, (float)0.75, true);
|
||||
limit = lim;
|
||||
reverselookup = new IdentityHashMap<WeakReference<ChunkSnapshot>, String>();
|
||||
reverselookup = new IdentityHashMap<WeakReference<SnapshotRec>, String>();
|
||||
}
|
||||
protected boolean removeEldestEntry(Map.Entry<String, CacheRec> last) {
|
||||
boolean remove = (size() >= limit);
|
||||
@@ -47,7 +53,7 @@ public class SnapshotCache {
|
||||
*/
|
||||
public SnapshotCache(int max_size) {
|
||||
snapcache = new CacheHashMap(max_size);
|
||||
refqueue = new ReferenceQueue<ChunkSnapshot>();
|
||||
refqueue = new ReferenceQueue<SnapshotRec>();
|
||||
}
|
||||
private String getKey(String w, int cx, int cz) {
|
||||
return w + ":" + cx + ":" + cz;
|
||||
@@ -83,11 +89,11 @@ public class SnapshotCache {
|
||||
/**
|
||||
* Look for chunk snapshot in cache
|
||||
*/
|
||||
public ChunkSnapshot getSnapshot(String w, int chunkx, int chunkz,
|
||||
public SnapshotRec getSnapshot(String w, int chunkx, int chunkz,
|
||||
boolean blockdata, boolean biome, boolean biomeraw, boolean highesty) {
|
||||
String key = getKey(w, chunkx, chunkz);
|
||||
processRefQueue();
|
||||
ChunkSnapshot ss = null;
|
||||
SnapshotRec ss = null;
|
||||
CacheRec rec = snapcache.get(key);
|
||||
if(rec != null) {
|
||||
ss = rec.ref.get();
|
||||
@@ -112,7 +118,7 @@ public class SnapshotCache {
|
||||
/**
|
||||
* Add chunk snapshot to cache
|
||||
*/
|
||||
public void putSnapshot(String w, int chunkx, int chunkz, ChunkSnapshot ss,
|
||||
public void putSnapshot(String w, int chunkx, int chunkz, SnapshotRec ss,
|
||||
boolean blockdata, boolean biome, boolean biomeraw, boolean highesty) {
|
||||
String key = getKey(w, chunkx, chunkz);
|
||||
processRefQueue();
|
||||
@@ -121,7 +127,7 @@ public class SnapshotCache {
|
||||
rec.hasbiome = biome;
|
||||
rec.hasrawbiome = biomeraw;
|
||||
rec.hashighesty = highesty;
|
||||
rec.ref = new WeakReference<ChunkSnapshot>(ss, refqueue);
|
||||
rec.ref = new WeakReference<SnapshotRec>(ss, refqueue);
|
||||
CacheRec prevrec = snapcache.put(key, rec);
|
||||
if(prevrec != null) {
|
||||
snapcache.reverselookup.remove(prevrec.ref);
|
||||
@@ -132,7 +138,7 @@ public class SnapshotCache {
|
||||
* Process reference queue
|
||||
*/
|
||||
private void processRefQueue() {
|
||||
Reference<? extends ChunkSnapshot> ref;
|
||||
Reference<? extends SnapshotRec> ref;
|
||||
while((ref = refqueue.poll()) != null) {
|
||||
String k = snapcache.reverselookup.remove(ref);
|
||||
if(k != null) {
|
||||
|
||||
@@ -9,6 +9,7 @@ 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;
|
||||
@@ -33,7 +34,29 @@ import org.getspout.spoutapi.material.MaterialData;
|
||||
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 {
|
||||
@@ -73,17 +96,6 @@ public class SpoutPluginBlocks {
|
||||
|
||||
/* Process spout blocks - return true if something changed */
|
||||
public boolean processSpoutBlocks(DynmapPlugin plugin, DynmapCore core) {
|
||||
/* 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) {
|
||||
plugin.getPluginLoader().enablePlugin(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File datadir = core.getDataFolder();
|
||||
if(textYPosField == null) {
|
||||
if(initSpoutAccess() == false)
|
||||
@@ -103,7 +115,12 @@ public class SpoutPluginBlocks {
|
||||
/* Loop through blocks - try to freshen files, if needed */
|
||||
for(CustomBlock b : cb) {
|
||||
BlockDesign bd = b.getBlockDesign();
|
||||
String blkid = bd.getTexturePlugin() + "." + fixIDString(b.getName());
|
||||
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");
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.dynmap.bukkit.permissions;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.dynmap.Log;
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
|
||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||
|
||||
public class GroupManagerPermissions implements PermissionProvider {
|
||||
String name;
|
||||
GroupManager gm;
|
||||
WorldsHolder wh;
|
||||
|
||||
public static GroupManagerPermissions create(Server server, String name) {
|
||||
Plugin permissionsPlugin = server.getPluginManager().getPlugin("GroupManager");
|
||||
if (permissionsPlugin == null)
|
||||
return null;
|
||||
server.getPluginManager().enablePlugin(permissionsPlugin);
|
||||
if(permissionsPlugin.isEnabled() == false)
|
||||
return null;
|
||||
Log.info("Using GroupManager " + permissionsPlugin.getDescription().getVersion() + " for access control");
|
||||
return new GroupManagerPermissions(name, permissionsPlugin);
|
||||
}
|
||||
|
||||
public GroupManagerPermissions(String name, Plugin permissionsPlugin) {
|
||||
this.name = name;
|
||||
gm = (GroupManager)permissionsPlugin;
|
||||
wh = gm.getWorldsHolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
|
||||
HashSet<String> hasperms = new HashSet<String>();
|
||||
AnjoPermissionsHandler apm = wh.getWorldPermissionsByPlayerName(player);
|
||||
if (apm != null) {
|
||||
for (String pp : perms) {
|
||||
if (apm.permission(player, name + "." + pp)) {
|
||||
hasperms.add(pp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return hasperms;
|
||||
}
|
||||
@Override
|
||||
public boolean hasOfflinePermission(String player, String perm) {
|
||||
AnjoPermissionsHandler apm = wh.getWorldPermissionsByPlayerName(player);
|
||||
if(apm != null) {
|
||||
return apm.permission(player, name + "." + perm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,18 @@
|
||||
# All paths in this configuration file are relative to Dynmap's data-folder: minecraft_server/plugins/dynmap/
|
||||
|
||||
# All map templates are defined in the templates directory
|
||||
# The 'classic' FlatMap and KzedMap templates are used, which can be found in normal.txt, nether.txt, and skylands.txt
|
||||
# To use these, do not set deftemplatesuffix (make sure deftemplatesuffix is commented, below)
|
||||
# To use the HDMap very-low-res map templates as world defaults (normal-vlowres, nether-vlowres and skylands-vlowres), set value to vlowres
|
||||
# The definitions of these templates are in normal-vlowres.txt, nether-vlowres.txt, and skylands-vlowres.txt
|
||||
# To use the HDMap low-res map templates as world defaults (normal-lowres, nether-lowres and skylands-lowres), set value to lowres
|
||||
# The definitions of these templates are in normal-lowres.txt, nether-lowres.txt, and skylands-lowres.txt
|
||||
# To use the HDMap hi-res map templates (these can take a VERY long time for initial fullrender), set value to hires
|
||||
# The definitions of these templates are in normal-hires.txt, nether-hires.txt, and skylands-hires.txt
|
||||
# To use the HDMap very-low-res (2 ppb) map templates as world defaults, set value to vlowres
|
||||
# The definitions of these templates are in normal-vlowres.txt, nether-vlowres.txt, and the_end-vlowres.txt
|
||||
# To use the HDMap low-res (4 ppb) map templates as world defaults, set value to lowres
|
||||
# The definitions of these templates are in normal-lowres.txt, nether-lowres.txt, and the_end-lowres.txt
|
||||
# To use the HDMap hi-res (16 ppb) map templates (these can take a VERY long time for initial fullrender), set value to hires
|
||||
# The definitions of these templates are in normal-hires.txt, nether-hires.txt, and the_end-hires.txt
|
||||
# To use the HDMap low-res (4 ppb) map templates, with support for boosting resolution selectively to hi-res (16 ppb), set value to low_boost_hi
|
||||
# The definitions of these templates are in normal-low_boost_hi.txt, nether-low_boost_hi.txt, and the_end-low_boost_hi.txt
|
||||
# To use the HDMap hi-res (16 ppb) map templates, with support for boosting resolution selectively to vhi-res (32 ppb), set value to hi_boost_vhi
|
||||
# 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
|
||||
|
||||
components:
|
||||
@@ -42,11 +46,13 @@ components:
|
||||
hideifsneaking: false
|
||||
# If true, player positions/status is protected (login with ID with dynmap.playermarkers.seeall permission required for info other than self)
|
||||
protected-player-info: false
|
||||
# If true, hide players with invisibility potion effects active
|
||||
hide-if-invisiblity-potion: true
|
||||
#- class: org.dynmap.JsonFileClientUpdateComponent
|
||||
# writeinterval: 1
|
||||
# sendhealth: true
|
||||
# sendposition: true
|
||||
# allowwebchat: false
|
||||
# allowwebchat: true
|
||||
# webchat-interval: 5
|
||||
# hidewebchatip: false
|
||||
# includehiddenplayers: false
|
||||
@@ -62,6 +68,7 @@ components:
|
||||
# webchat-permissions: false
|
||||
# # Limit length of single chat messages
|
||||
# chatlengthlimit: 256
|
||||
# hide-if-invisiblity-potion: true
|
||||
|
||||
- class: org.dynmap.SimpleWebChatComponent
|
||||
allowchat: true
|
||||
@@ -131,7 +138,7 @@ components:
|
||||
- class: org.dynmap.ClientComponent
|
||||
type: timeofdayclock
|
||||
showdigitalclock: true
|
||||
#showweather: true
|
||||
showweather: true
|
||||
# Mouse pointer world coordinate display
|
||||
- class: org.dynmap.ClientComponent
|
||||
type: coord
|
||||
@@ -183,6 +190,14 @@ saverestorepending: true
|
||||
# Zoom-out tile update period - how often to scan for and process tile updates into zoom-out tiles (in seconds)
|
||||
zoomoutperiod: 30
|
||||
|
||||
# Control whether zoom out tiles are validated on startup (can be needed if zoomout processing is interrupted, but can be expensive on large maps)
|
||||
initial-zoomout-validate: true
|
||||
|
||||
# Default delay on processing of updated tiles, in seconds. This can reduce potentially expensive re-rendering
|
||||
# of frequently updated tiles (such as due to machines, pistons, quarries or other automation). Values can
|
||||
# also be set on individual worlds and individual maps.
|
||||
tileupdatedelay: 30
|
||||
|
||||
# Tile hashing is used to minimize tile file updates when no changes have occurred - set to false to disable
|
||||
enabletilehash: true
|
||||
|
||||
@@ -193,7 +208,7 @@ enabletilehash: true
|
||||
#better-grass: true
|
||||
|
||||
# Optional - enable smooth lighting by default on all maps supporting it (can be set per map as lighting option)
|
||||
smooth-lighting: false
|
||||
smooth-lighting: true
|
||||
|
||||
# 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
|
||||
@@ -201,8 +216,15 @@ image-format: png
|
||||
|
||||
# use-generated-textures: if true, use generated textures (same as client); false is static water/lava textures
|
||||
# correct-water-lighting: if true, use corrected water lighting (same as client); false is legacy water (darker)
|
||||
# transparent-leaves: if true, leaves are transparent (lighting-wise): false is needed for some Spout versions that break lighting on leaf blocks
|
||||
use-generated-textures: true
|
||||
correct-water-lighting: true
|
||||
transparent-leaves: true
|
||||
|
||||
# ctm-support: if true, Connected Texture Mod (CTM) in texture packs is enabled (default)
|
||||
ctm-support: true
|
||||
# custom-colors-support: if true, Custom Colors in texture packs is enabled (default)
|
||||
custom-colors-support: true
|
||||
|
||||
# Control loading of player faces (if set to false, skins are never fetched)
|
||||
#fetchskins: false
|
||||
@@ -218,37 +240,6 @@ skin-url: "http://s3.amazonaws.com/MinecraftSkins/%player%.png"
|
||||
# 'newnorth' is used to rotate maps and rose (requires fullrender of any HDMap map - same as 'newrose' for FlatMap or KzedMap)
|
||||
compass-mode: newnorth
|
||||
|
||||
### Mod block support ###
|
||||
# Enable Industrial Craft 2 block rendering support (core, Advanced Machines, Charging Bench, Power Converters, Compact Solars, Nuclear Control)
|
||||
#ic2-support: true
|
||||
#ic2-advancesmachines-support: true
|
||||
#ic2-chargingbench-support: true
|
||||
#ic2-powerconverters-support: true
|
||||
#ic2-compactsolars-support: true
|
||||
#ic2-nuclearcontrol-support: true
|
||||
# Enable BuildCraft block rendering support
|
||||
#buildcraft-support: true
|
||||
# Enable RedPower2 block rendering support
|
||||
#redpower2-support: true
|
||||
# Enable NetherOres block rendering support
|
||||
#netherores-support: true
|
||||
# Enable RailCraft block rendering support
|
||||
#railcraft-support: true
|
||||
# Enable Kaevator's Superslopes block rendering support
|
||||
#superslopes-support: true
|
||||
# Enabled ComputerCraft block rendering support
|
||||
#computercraft-support: true
|
||||
# Enabled LC Trees++ block rendering support
|
||||
#lctrees-support: true
|
||||
# Enable Forestry block rending support
|
||||
#forestry-support: true
|
||||
# Enable IronCheck block rendering support
|
||||
#ironchest-support: true
|
||||
# Enable TubeCraft block rendering support
|
||||
#tubecraft-support: true
|
||||
# Enable Ender Storage block rendering support
|
||||
#enderstorage-support: true
|
||||
|
||||
render-triggers:
|
||||
#- playermove
|
||||
#- playerjoin
|
||||
@@ -330,8 +321,15 @@ grayplayerswhenhidden: true
|
||||
# Access-Control-Allow-Origin: "my-domain.com"
|
||||
# X-Custom-Header-Of-Mine: "MyHeaderValue"
|
||||
|
||||
# Trusted proxies for web server - which proxy addresses are trusted to supply valid X-Forwarded-For fields
|
||||
trusted-proxies:
|
||||
- "127.0.0.1"
|
||||
- "0:0:0:0:0:0:0:1"
|
||||
|
||||
# Join/quit message format for web chat: set to "" to disable notice on web UI
|
||||
joinmessage: "%playername% joined"
|
||||
quitmessage: "%playername% quit"
|
||||
|
||||
spammessage: "You may only chat once every %interval% seconds."
|
||||
# format for messages from web: %playername% substitutes sender ID (typically IP), %message% includes text
|
||||
webmsgformat: "&color;2[WEB] %playername%: &color;f%message%"
|
||||
@@ -353,6 +351,9 @@ defaultmap: flat
|
||||
# If true, make persistent record of IP addresses used by player logins, to support web IP to player matching
|
||||
persist-ids-by-ip: true
|
||||
|
||||
# If true, map text to cyrillic
|
||||
cyrillic-support: false
|
||||
|
||||
# Messages to customize
|
||||
msg:
|
||||
maptypes: "Map Types"
|
||||
@@ -386,6 +387,14 @@ spout:
|
||||
# to clean cached textures and force reload on next startup)
|
||||
use-existing-textures: true
|
||||
|
||||
# Customization commands - allows scripts to be run before/after certain events
|
||||
custom-commands:
|
||||
image-updates:
|
||||
# Command run just before any image file is written or updated: run with single parameter with fully qualified file name
|
||||
preupdatecommand: ""
|
||||
# Command run just after any image file is written or updated: run with single parameter with fully qualified file name
|
||||
postupdatecommand: ""
|
||||
|
||||
# Set to true to enable verbose startup messages - can help with debugging map configuration problems
|
||||
# Set to false for a much quieter startup log
|
||||
verbose: false
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
name: dynmap
|
||||
main: org.dynmap.bukkit.DynmapPlugin
|
||||
version: "${project.version}-${BUILD_NUMBER}"
|
||||
authors: [FrozenCow, mikeprimm]
|
||||
authors: [mikeprimm]
|
||||
website: "http://www.minecraftforum.net/topic/1543523-dynmap-dynamic-web-based-maps-for-minecraft/"
|
||||
softdepend: [ Permissions, PermissionEx, bPermissions, PermissionsBukkit ]
|
||||
commands:
|
||||
dynmap:
|
||||
|
||||
Reference in New Issue
Block a user