Compare commits

...

160 Commits

Author SHA1 Message Date
Mike Primm b13c26c0d6 Switch to submodules 2014-10-12 17:32:38 -05:00
Mike Primm 3fd4ac7373 Update to fix Glowstone support 2014-09-13 21:17:37 -05:00
Mike Primm ac0f756fae More Glowstone fixes 2014-09-06 22:25:56 -05:00
Mike Primm 551f35f3f9 Add initial support for Glowstone server 2014-09-06 19:19:20 -05:00
Mike Primm ec9ebf2dbb Add well known 1.7 biomes only when appropriate version 2014-08-22 23:48:12 -05:00
Mike Primm 3702918a6f Add well known 1.7.x biomes only when version is appropriate 2014-08-22 23:15:57 -05:00
Mike Primm 8085221087 Add prefix setting for MySQL table names 2014-08-22 01:50:47 -05:00
mikeprimm 7de967f1c2 Merge pull request #1603 from KovuTheHusky/roundcoords
Add option to round coordinates to nearest integer
2014-08-20 18:10:10 -05:00
mikeprimm f6e127b7f0 Merge pull request #1601 from KovuTheHusky/master
Fix javadoc errors for building with Java SE 8
2014-08-20 18:08:20 -05:00
Mike Primm 22d1923ad5 Add support for 1.7.10 2014-07-09 22:20:33 -05:00
Mike Primm d8d3061696 Add config defaults for MySQL map storage 2014-06-08 21:59:32 -05:00
Kevin Breslin 14da080d52 Add option to round coordinates to nearest integer 2014-05-27 01:34:11 -04:00
Kevin Breslin 10ce166b54 Fix javadoc errors for building with Java SE 8 2014-05-26 22:37:53 -04:00
Mike Primm cb9f964348 Update default suffix 2014-05-10 14:36:50 -05:00
Mike Primm 9850a03945 More comments on storage config 2014-05-10 13:47:14 -05:00
Mike Primm 8abfae3d79 Add storage/type settings to control file tree vs sqlite storage 2014-05-10 00:42:02 -05:00
Mike Primm f486ad75f1 Bump to 2.0.0-SNAPSHOT 2014-05-05 00:30:03 -05:00
Mike Primm 54b3fb429c Switch to SNAPSHOT 2014-04-20 11:47:57 -05:00
Mike Primm 86547f8d78 Bump to 1.9.5 2014-04-20 11:09:49 -05:00
Mike Primm 8ec80937e3 Add plugin versions for sources and javadoc plugins 2014-04-17 08:59:38 -05:00
Mike Primm 0e5e602a90 Add plugin versions for javadocs and sources 2014-04-16 23:02:35 -05:00
Mike Primm 3239d539c0 Add sources and javadoc generation to POM 2014-04-16 22:28:29 -05:00
Mike Primm 05bd2544fd Switch to groupID us.dynmap (owned domain) - sonatype central repo prep 2014-04-16 19:46:47 -05:00
Mike Primm 252da2a5c6 Add exportpath, default-sign-set settings 2014-03-12 00:10:17 -05:00
Mike Primm 5d83ebf8aa Add sign change API to help with marker sign support on MCPC+ 2014-03-11 23:58:01 -05:00
Mike Primm 026cc72233 Bump to 1.9.4 2014-03-08 02:31:06 -06:00
Mike Primm 0d2cceea4b Add /dynmapexp command (for OBJ exporter support) 2014-02-24 00:27:05 -06:00
Mike Primm a1dfae7f79 Bump to 1.9.2 2014-02-06 08:37:24 -06:00
Mike Primm d6eb822b26 Rework chunk loading timing stats - simpler, more useful 2014-02-04 07:05:24 -06:00
Mike Primm d4f161ca99 Remove unneeded synchronized() 2014-02-03 22:29:00 -06:00
Mike Primm 376ec447ed Revert "Add more metrics to chunk loading (for testing)"
This reverts commit 926d2a3dbc.
2014-02-03 22:27:04 -06:00
Mike Primm 926d2a3dbc Add more metrics to chunk loading (for testing) 2014-02-03 21:36:43 -06:00
Mike Primm eeffa4f98d Add stubs for block unique ID support 2014-02-01 01:16:15 -06:00
Mike Primm 8350727a73 Fix inhabitedTime field lookup 2014-01-17 23:05:54 -06:00
Mike Primm 3b79890166 Add getInhabitedTime() 2014-01-17 17:40:39 -06:00
Mike Primm 17174c177c Handle textures loading from other mods 2014-01-11 23:41:23 -06:00
Mike Primm 07e7d53a93 Add debug option for dumping IDs of blocks with no render data 2014-01-06 21:41:12 -06:00
Mike Primm 76863aeb71 Add use-brightness-table setting, and support for world-specific brightness tables 2014-01-04 21:16:29 -06:00
Mike Primm f7d2dac826 Add permissions and help for /dynmap quiet command 2013-12-30 01:46:29 -06:00
Mike Primm 3cb7ba342c Add setting for periodic save of pending jobs 2013-12-30 01:45:17 -06:00
Mike Primm d2ab466dc0 Update server interface for mod-supplied texture/model files 2013-12-28 23:56:22 -06:00
Mike Primm d03ed7a461 Bump to 1.9.2 2013-12-24 10:52:17 -06:00
Mike Primm c8469d7aba Strip version check 2013-12-05 00:11:40 -06:00
Mike Primm e7c92096b2 Turn off version check (dev.bukkit.org doesn't like it...) 2013-12-02 16:12:11 -06:00
Mike Primm 0c9d397144 Update to support CB 1.7.2-R0.1 2013-12-01 08:32:16 -06:00
Mike Primm b4a3b61c11 Start mod support API 2013-11-30 22:51:48 -06:00
Mike Primm 564c38b44a Back to 1.9.1 2013-11-16 23:27:35 -06:00
Mike Primm 664e7da659 Bump to 2.0 2013-10-21 19:33:37 -05:00
Mike Primm 9046212a47 Update for mod image loading support 2013-09-18 17:17:23 -05:00
Mike Primm b6ee68c9b0 Fix comment typo 2013-09-14 16:38:38 -05:00
Mike Primm 7854568d88 Fix typo in security flag for dynmap.webregister.other 2013-09-14 15:56:24 -05:00
Mike Primm f1c9417237 Add support for web server bindaddress to be set to match MC server-ip setting 2013-09-08 00:00:25 -05:00
Mike Primm 336f8302c4 Have spout code handle renderdata not being defined yet 2013-09-07 23:11:35 -05:00
Mike Primm d8ccc26109 Add mod version check code 2013-08-16 02:17:10 -05:00
Mike Primm d396046249 Add block-id-alias setting 2013-08-04 18:07:36 -05:00
Mike Primm 1793d910d4 Straighten out GroupManager offline permissions 2013-07-18 08:44:33 -05:00
Mike Primm f0f881d126 Bump to 1.9 2013-07-07 22:01:02 -05:00
Mike Primm 5482ddaa89 Add 2 tick delay to player join processing - allows nicknames to be set before we send message to web 2013-07-05 10:57:19 -05:00
Mike Primm 47455eb912 Add 'hidenames' option, and supporting messages 2013-07-05 09:31:32 -05:00
Mike Primm 32a1c20fd0 Bandaid for MrApple's CB 1.6.1 2013-07-01 19:31:59 -05:00
Mike Primm b85c38e3a7 Add softref option for chunk snapshot cache 2013-06-25 01:09:25 -05:00
Mike Primm 5bc4de6a8b Add zoomout-min-tps setting 2013-06-24 21:44:01 -05:00
Mike Primm 2d20fd11f7 Update dev version format 2013-06-24 20:24:05 -05:00
Mike Primm 6a4bb59d60 Add permission node for /dynmap purgeworld command 2013-06-23 15:11:32 -05:00
Mike Primm ab45edb82c Add settings for TPS limits and per-tick msec limits 2013-06-19 23:20:38 -05:00
Mike Primm 4f6bc05180 Add help for /dynmap purgequeue <world> 2013-06-15 18:10:50 -05:00
Mike Primm 076681e188 Add help and permission node for /dynmap purgemap 2013-06-15 18:07:45 -05:00
Mike Primm b7abfe7c06 Add settings for player-sort-permission-nodes support 2013-06-14 01:49:49 -05:00
Mike Primm 3a88ac66a6 Add use-name-colors setting to control option to use name color markup 2013-06-02 19:28:03 -05:00
Mike Primm d3b9367794 Add 'updateplayerlimit' setting default 2013-06-02 16:31:35 -05:00
Mike Primm 666840fc8b Add help and permissions for /dmarker importdesc, importlabel, getlabel 2013-05-27 09:09:49 -05:00
Mike Primm 62f4c12147 Bump bukkit dependency to 1.4.7 2013-05-27 08:33:49 -05:00
Mike Primm 4b3f2280b6 Add command help and permissions for /dmarker description commands 2013-05-26 14:03:46 -05:00
Mike Primm df55606023 Add method for discovering all chunks in world 2013-05-24 23:59:08 -05:00
Mike Primm 6fc5fddd44 Back to 1.8 2013-05-15 20:53:56 -05:00
Mike Primm dea285c160 Back to 1.7.1 for bug fix 2013-05-15 19:35:06 -05:00
Mike Primm 204641a4b0 Bump to 1.8 2013-05-14 22:06:00 -05:00
Mike Primm d4aaa1d1fd Revert chunk load change - but still make sure they don't unload under us 2013-05-10 17:36:27 -05:00
Mike Primm fe83a7d1cc Revert "Additional check on loaded chunks : avoid getChunkAt rare exception"
This reverts commit 3efe3c3d3d.
2013-05-10 17:00:52 -05:00
Mike Primm d4e24e9d26 Add GroupManager specific permissions support 2013-05-10 01:31:30 -05:00
Mike Primm 734937884a Repackage to single JAR, no ZIP - make other files self-extracting 2013-05-09 00:55:07 -05:00
Mike Primm 3efe3c3d3d Additional check on loaded chunks : avoid getChunkAt rare exception 2013-05-08 19:35:45 -05:00
Mike Primm 46ab344197 Switch to smooth lighting by default 2013-05-02 23:12:25 -05:00
Mike Primm 9270ce853d Update author contact info 2013-05-01 23:23:49 -05:00
Mike Primm 04a2019e9d Add comments for boost-enabled templates 2013-05-01 00:26:28 -05:00
Mike Primm 8daf95891d Add comment for disabling join/quit message 2013-04-29 15:07:54 -05:00
Mike Primm 5396d0b823 Add full support for CTM material connection method 2013-04-28 10:12:01 -05:00
Mike Primm a2ab8c4f2f Tune performance on map iterator 2013-04-26 21:44:29 -05:00
Mike Primm e7efbe193a Add Custom Colors support for texture packs 2013-04-22 23:03:07 -05:00
Mike Primm 99ea38d02a Avoid shutdown exception due to bukkit 'improvements' 2013-04-21 21:05:12 -05:00
Mike Primm 7c6e660cf0 Add supporting code to help with CTM support (block names, biome names) 2013-04-18 01:20:59 -05:00
Mike Primm bcd0acec33 Bump to 1.7 2013-04-07 21:34:37 -05:00
Mike Primm 7e07bff71f Remove MCPC-Plus support from Bukkit version - add notice to use Forge 2013-03-29 21:46:06 -05:00
Mike Primm 2d95548d25 Add default setting for initial zoomout validate option 2013-03-26 23:50:54 -05:00
Mike Primm 3ac67ce2c5 Update for new API listener 2013-03-20 23:59:50 -05:00
Mike Primm 0d25fd2edc Make sure chunk unload queue is processed quickly enough on MCPC 2013-03-18 20:30:13 -05:00
Mike Primm bee16ef331 Switch MCPC+ to using unloadChunkRequest - unloadChunk() seems to not clean up properly 2013-03-17 23:43:11 -05:00
Mike Primm bf16d18371 Bump to 1.6 2013-03-02 16:00:58 -06:00
Mike Primm e57634ebb3 Add BukkitForge handler - doesn't work right due to BukkitForge API bugs 2013-03-01 23:51:45 -06:00
Mike Primm 55a5aacfce Drop autogenerate option 2013-02-24 20:24:05 -06:00
mikeprimm e6fe29f0c5 Merge pull request #1148 from dejavecu/master
Added support of round visibility limits
2013-02-24 16:15:16 -08:00
Mike Primm 34712e27f0 Put in some protextion logic for apparently broken SpoutPlugin 2013-02-24 18:04:20 -06:00
dejavecu 6a5eebcc00 Added support of round visibility limits 2013-02-16 03:59:07 +04:00
Mike Primm c8b1f71949 Add settings for image update command exits 2013-02-03 17:11:35 -06:00
Mike Primm dc11ef3507 Bump to 1.5 2013-01-29 13:52:25 -06:00
Mike Primm d0bbb78e98 Add upgrade version check 2013-01-29 11:49:22 -06:00
Mike Primm 9144bff25b Add support for MCPC-Plus 2013-01-21 23:54:13 -06:00
Mike Primm 18325c2b33 Switch version check to core version 2013-01-15 11:33:51 -06:00
Mike Primm f1a686eaf8 Hack to work around broken jenkins 2013-01-15 08:45:49 -06:00
Mike Primm b3c32456ca Revert "Test to try to fix jenkins f-up"
This reverts commit 3483b19cef.
2013-01-15 08:23:31 -06:00
Mike Primm be16ac089f Revert "Revert - no help"
This reverts commit 9ad5a7e4f7.
2013-01-15 08:23:11 -06:00
Mike Primm 44a8bfa38d Revert "Try to workaround Jenkins/Maven packaging issue"
This reverts commit 443d64f7da.
2013-01-15 08:22:55 -06:00
Mike Primm 443d64f7da Try to workaround Jenkins/Maven packaging issue 2013-01-15 08:17:31 -06:00
Mike Primm 9ad5a7e4f7 Revert - no help 2013-01-15 03:31:33 -06:00
Mike Primm 3483b19cef Test to try to fix jenkins f-up 2013-01-15 03:26:03 -06:00
Mike Primm 44c5d51c4e Fix v1.2.5 support, broken by API change in metrics 2013-01-15 00:30:08 -06:00
Mike Primm 56d1bcf3eb Show details on execution exceptions - better info on cause 2013-01-11 15:59:55 -06:00
Mike Primm f43027f02f Add tileupdatedelay setting, compute more accurate bounding box for new chunks 2013-01-08 00:10:53 -06:00
Mike Primm bd12420edd Add option to hide players on map that have invisibility potion effects 2013-01-03 21:58:58 -06:00
Mike Primm 3c01aff411 Drop obsolete file 2013-01-02 21:25:17 -06:00
Mike Primm 4d664de250 Bump to 1.4 2012-12-31 15:58:32 -06:00
Mike Primm 278fa36f94 Add call needed for sign block checks 2012-12-31 12:29:28 -06:00
Mike Primm 1a2f63bcfb Switch weather display to be on by default 2012-12-30 11:23:21 -06:00
Mike Primm 344d9bf1c9 Add support for configuing which proxy addresses to trust X-Forwarded-For from 2012-12-30 11:03:28 -06:00
Mike Primm 70b27b8034 Remove debug message 2012-12-30 10:14:05 -06:00
Mike Primm abe7fc8405 Update metrics agent 2012-12-30 09:17:35 -06:00
Mike Primm 4fa62993f4 Scrub system dependencies - shifted to repository 2012-12-24 15:10:24 -06:00
Mike Primm 08a920694b Switch to new repo 2012-12-24 14:52:00 -06:00
Mike Primm 4bdb331eb0 Switch mod use to features graph - doesn't look like we get a 3rd one.. 2012-12-17 21:55:23 -06:00
Mike Primm cb7c9061e8 Update stats to collect mod usage data 2012-12-17 21:08:39 -06:00
Mike Primm 29cb155534 Revert "Fix to bukkit API 1.2.5 - avoid accidental breaks of backward compat"
This reverts commit ada85ed960.
2012-12-16 17:12:09 -06:00
Mike Primm ada85ed960 Fix to bukkit API 1.2.5 - avoid accidental breaks of backward compat 2012-12-16 15:02:19 -06:00
Mike Primm bfb12aa0f3 Bump to 1.3 2012-12-10 22:52:02 -06:00
Mike Primm 3342977a92 Add cyrillic setting back in to configuration.txt 2012-12-10 00:21:58 -06:00
Mike Primm 07cbd84d44 Combine support for pre 1.4.5 versions and new 1.4.x packaging crud 2012-12-09 22:28:21 -06:00
Mike Primm da5e2cf24a Add transparent-leaves setting : workaround for borked lighting in some SpoutPlugin versions 2012-12-09 13:04:44 -06:00
Mike Primm c6d345d8f1 Add tile entity data collection 2012-11-22 00:50:55 -06:00
Mike Primm 3a57261120 First pass of custom renderer support 2012-11-19 15:56:55 -06:00
Mike Primm a39f99cab8 Back to 1.2 2012-11-16 18:46:34 -06:00
Mike Primm f0885abea2 Back to 1.1 for patch 2012-11-16 18:39:44 -06:00
Mike Primm 2b17cb215b Bump to 1.2 2012-11-16 18:06:22 -06:00
Mike Primm 68f0c17f70 Support world loading/unloading - allow viewing while world unloaded 2012-11-10 23:47:40 -06:00
Mike Primm a20e55beab Add support for handling custom biomes (ExtraBiomes XL) 2012-11-09 21:01:11 -06:00
Mike Primm 413542fe61 Add permissions.jar to project - not on repo anymore 2012-11-08 14:25:32 -06:00
Mike Primm a250732d31 Bump to v1.1 2012-10-29 22:37:55 -05:00
Mike Primm 07f2496f2f Bump to 1.00 2012-10-21 12:32:58 -05:00
Mike Primm 2f6e52261c Cleanup unused methods, speed up world lookup 2012-10-17 19:42:37 -05:00
Mike Primm a117987840 Handle multiple mod names 2012-10-15 08:24:10 -05:00
Mike Primm cbb8cc061e Add support for automatic enabling of mod-specific blocks and textures 2012-10-15 01:19:18 -05:00
Mike Primm c03365d574 Correct setting for TubeStuff support 2012-10-14 21:02:37 -05:00
Mike Primm 827f18b8e0 Support delaying dynmap start to allow Spout blocks to be registered 2012-10-05 00:10:32 -05:00
Mike Primm 1603015631 Handle new CancellationExceptions being thrown by Bukkit Scheduler 2012-09-03 20:43:30 -05:00
Mike Primm c2d97ba3d5 Keep metrics from nagging if mcstats.org is offline 2012-08-27 21:03:55 -05:00
Mike Primm 418b175923 Bump to 0.90 2012-08-26 22:07:56 -05:00
Mike Primm fdc14b413d Add ee2-support setting for Equivalent Exchange 2 support 2012-08-25 22:55:48 -05:00
Mike Primm e6d509c3e6 Add some more feature metrics 2012-08-24 22:37:48 -05:00
Mike Primm b10ec3a331 Add support for ExtraBiomesXL Bunyan blocks 2012-08-24 01:28:46 -05:00
Mike Primm 9f8617d81d Add mcstats.org reporting 2012-08-24 00:07:06 -05:00
Mike Primm 265e037b74 Add setting for enabling ExtraBiomesXL rendering support 2012-08-20 00:17:00 -05:00
Mike Primm f50e73180c Back to 0.80 2012-08-19 19:34:45 -05:00
34 changed files with 4153 additions and 1276 deletions
+56
View File
@@ -0,0 +1,56 @@
<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>us.dynmap</groupId>
<artifactId>DynmapBukkitBase</artifactId>
<name>DynmapBukkitBase</name>
<url>http://github.com/webbukkit/dynmap/</url>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/webbukkit/dynmap/issues</url>
</issueManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</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>
<snapshots>
</snapshots>
<id>dynmap-repo</id>
<url>http://repo.mikeprimm.com/</url>
</repository>
</repositories>
<version>2.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>Bukkit</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>DynmapCore</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,142 @@
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.bukkit.entity.Player;
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) {
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. *");
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 if(Bukkit.getServer().getClass().getName().contains("GlowServer")) {
Log.info("Loading Glowstone support");
helper = new BukkitVersionHelperGlowstone();
}
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 unload queue for given NMS world
*/
public abstract Object getUnloadQueue(World world);
/**
* 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);
/**
* 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
*/
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();
/**
* Get list of online players
*/
public abstract Player[] getOnlinePlayers();
/**
* Get player health
*/
public abstract int getHealth(Player p);
}
@@ -0,0 +1,222 @@
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;
/**
* 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;
private Method blockbyidfunc; // 1.7+ method for getting block by id
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 = 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 = getPrivateField(nmsblock, new String[] { "material" }, nmsmaterial);
/* Set up biomebase fields */
biomebase = getNMSClass("net.minecraft.server.BiomeBase");
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
biomebaselist = getPrivateField(biomebase, new String[] { "biomes" }, biomebasearray);
biomebasetemp = getField(biomebase, new String[] { "temperature", "F" }, float.class);
biomebasehumi = getField(biomebase, new String[] { "humidity", "G" }, float.class);
biomebaseidstring = getField(biomebase, new String[] { "y", "af" }, 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);
nmsc_inhabitedticks = getFieldNoFail(nmschunk, new String[] { "s", "q" }, long.class);
if (nmsc_inhabitedticks == null) {
Log.info("inhabitedTicks field not found - inhabited shader not functional");
}
/** 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 = 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);
}
@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 {
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];
}
/**
* 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 {
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 {
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];
}
}
@@ -0,0 +1,429 @@
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;
/**
* 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;
protected Field nmsc_inhabitedticks;
/** 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;
/** Server */
protected Method server_getonlineplayers;
/** Player */
protected Method player_gethealth;
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]);
/** 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();
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 */
protected Object getNMSWorld(World w) {
return callMethod(w, cw_gethandle, nullargs, null);
}
/* Get unload queue for given NMS world */
public Object getUnloadQueue(World world) {
Object cps = getFieldValue(getNMSWorld(world), 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 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);
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;
}
/**
* 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
*/
public int 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 int getHealth(Player p) {
return (int) p.getHealth();
}
}
@@ -0,0 +1,237 @@
package org.dynmap.bukkit;
/**
* Bukkit specific implementation of DynmapWorld
*/
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
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.TileFlags;
public class BukkitWorld extends DynmapWorld {
private World world;
private World.Environment env;
private boolean skylight;
private DynmapLocation spawnloc = new DynmapLocation();
public BukkitWorld(World w) {
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);
// 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
* @param w - loaded world
*/
public void setWorldLoaded(World w) {
world = w;
env = world.getEnvironment();
skylight = (env == World.Environment.NORMAL);
}
/**
* Set world unloaded
*/
@Override
public void setWorldUnloaded() {
getSpawnLocation(); /* Remember spawn location before unload */
world = null;
}
/* Test if world is nether */
@Override
public boolean isNether() {
return env == World.Environment.NETHER;
}
/* Get world spawn location */
@Override
public DynmapLocation getSpawnLocation() {
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() {
if(world != null) {
return world.getTime();
}
else {
return -1;
}
}
/* World is storming */
@Override
public boolean hasStorm() {
if(world != null) {
return world.hasStorm();
}
else {
return false;
}
}
/* World is thundering */
@Override
public boolean isThundering() {
if(world != null) {
return world.isThundering();
}
else {
return false;
}
}
/* World is loaded */
@Override
public boolean isLoaded() {
return (world != null);
}
/* Get light level of block */
@Override
public int getLightLevel(int x, int y, int z) {
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) {
if(world != null) {
return world.getHighestBlockYAt(x, z);
}
else {
return -1;
}
}
/* Test if sky light level is requestable */
@Override
public boolean canGetSkyLightLevel() {
return skylight && (world != null);
}
/* Return sky light level */
@Override
public int getSkyLightLevel(int x, int y, int z) {
if(world != null) {
return world.getBlockAt(x, y, z).getLightFromSky();
}
else {
return -1;
}
}
/**
* Get world environment ID (lower case - normal, the_end, nether)
*/
@Override
public String getEnvironment() {
return env.name().toLowerCase();
}
/**
* Get map chunk cache for world
*/
@Override
public MapChunkCache getChunkCache(List<DynmapChunk> chunks) {
if(isLoaded()) {
LegacyMapChunkCache c = new LegacyMapChunkCache();
c.setChunks(this, chunks);
return c;
}
else {
return null;
}
}
public World getWorld() {
return world;
}
// Return false if unimplemented
@Override
public int getChunkMap(TileFlags map) {
map.clear();
if (world == null) return -1;
int cnt = 0;
// Mark loaded chunks
for(Chunk c : world.getLoadedChunks()) {
map.setFlag(c.getX(), c.getZ(), true);
cnt++;
}
File f = world.getWorldFolder();
File regiondir = new File(f, "region");
File[] lst = regiondir.listFiles();
if(lst != null) {
byte[] hdr = new byte[4096];
for(File rf : lst) {
if(!rf.getName().endsWith(".mca")) {
continue;
}
String[] parts = rf.getName().split("\\.");
if((!parts[0].equals("r")) && (parts.length != 4)) continue;
RandomAccessFile rfile = null;
int x = 0, z = 0;
try {
x = Integer.parseInt(parts[1]);
z = Integer.parseInt(parts[2]);
rfile = new RandomAccessFile(rf, "r");
rfile.read(hdr, 0, hdr.length);
} catch (IOException iox) {
Arrays.fill(hdr, (byte)0);
} catch (NumberFormatException nfx) {
Arrays.fill(hdr, (byte)0);
} finally {
if(rfile != null) {
try { rfile.close(); } catch (IOException iox) {}
}
}
for (int i = 0; i < 1024; i++) {
int v = hdr[4*i] | hdr[4*i + 1] | hdr[4*i + 2] | hdr[4*i + 3];
if (v == 0) continue;
int xx = (x << 5) | (i & 0x1F);
int zz = (z << 5) | ((i >> 5) & 0x1F);
if (!map.setFlag(xx, zz, true)) {
cnt++;
}
}
}
}
return cnt;
}
}
@@ -0,0 +1,225 @@
package org.dynmap.bukkit;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import org.bukkit.World;
import org.bukkit.Chunk;
import org.bukkit.block.Biome;
import org.bukkit.ChunkSnapshot;
import org.dynmap.DynmapChunk;
import org.dynmap.DynmapCore;
import org.dynmap.DynmapWorld;
import org.dynmap.Log;
import org.dynmap.bukkit.SnapshotCache.SnapshotRec;
import org.dynmap.common.BiomeMap;
import org.dynmap.hdmap.HDBlockModels;
import org.dynmap.renderer.RenderPatchFactory;
import org.dynmap.utils.DynIntHashMap;
import org.dynmap.utils.MapChunkCache;
import org.dynmap.utils.MapIterator;
import org.dynmap.utils.BlockStep;
import org.dynmap.utils.VisibilityLimit;
/**
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
*/
public class LegacyMapChunkCache extends BaseMapChunkCache {
@Override
public int loadChunks(int max_to_load) {
if(dw.isLoaded() == false)
return 0;
Object queue = helper.getUnloadQueue(w);
int cnt = 0;
if(iterator == null)
iterator = chunks.listIterator();
DynmapCore.setIgnoreChunkLoads(true);
//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) {
vis = false;
for(VisibilityLimit limit : visible_limits) {
if (limit.doIntersectChunk(chunk.x, chunk.z)) {
vis = true;
break;
}
}
}
if(vis && (hidden_limits != null)) {
for(VisibilityLimit limit : hidden_limits) {
if (limit.doIntersectChunk(chunk.x, chunk.z)) {
vis = false;
break;
}
}
}
/* Check if cached chunk snapshot found */
ChunkSnapshot ss = null;
long inhabited_ticks = 0;
DynIntHashMap tileData = null;
SnapshotRec ssr = SnapshotCache.cache.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;
else if(hidestyle == HiddenChunkStyle.FILL_OCEAN)
ss = OCEAN;
else
ss = EMPTY;
}
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;
}
boolean wasLoaded = w.isChunkLoaded(chunk.x, chunk.z);
boolean didload = false;
boolean isunloadpending = false;
if (queue != null) {
isunloadpending = helper.isInUnloadQueue(queue, chunk.x, chunk.z);
}
if (isunloadpending) { /* Workaround: can't be pending if not loaded */
wasLoaded = true;
}
try {
didload = w.loadChunk(chunk.x, chunk.z, false);
} catch (Throwable t) { /* Catch chunk error from Bukkit */
Log.warning("Bukkit error loading chunk " + chunk.x + "," + chunk.z + " on " + w.getName());
if(!wasLoaded) { /* If wasn't loaded, we loaded it if it now is */
didload = w.isChunkLoaded(chunk.x, chunk.z);
}
}
/* If it did load, make cache of it */
if(didload) {
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;
else if(hidestyle == HiddenChunkStyle.FILL_OCEAN)
ss = OCEAN;
else
ss = EMPTY;
}
else {
if(blockdata || highesty) {
ss = c.getChunkSnapshot(highesty, biome, biomeraw);
/* Get tile entity data */
List<Object> vals = new ArrayList<Object>();
Map<?,?> tileents = helper.getTileEntitiesForChunk(c);
for(Object t : tileents.values()) {
int te_x = helper.getTileEntityX(t);
int te_y = helper.getTileEntityY(t);
int te_z = helper.getTileEntityZ(t);
int cx = te_x & 0xF;
int cz = te_z & 0xF;
int blkid = ss.getBlockTypeId(cx, te_y, cz);
int blkdat = ss.getBlockData(cx, te_y, cz);
String[] te_fields = HDBlockModels.getTileEntityFieldsNeeded(blkid, blkdat);
if(te_fields != null) {
Object nbtcompound = helper.readTileEntityNBT(t);
vals.clear();
for(String id: te_fields) {
Object val = helper.getFieldValue(nbtcompound, id);
if(val != null) {
vals.add(id);
vals.add(val);
}
}
if(vals.size() > 0) {
Object[] vlist = vals.toArray(new Object[vals.size()]);
tileData.put(getIndexInChunk(cx,te_y,cz), vlist);
}
}
}
}
else
ss = w.getEmptyChunkSnapshot(chunk.x, chunk.z, biome, biomeraw);
if(ss != null) {
ssr = new SnapshotRec();
ssr.ss = ss;
ssr.inhabitedTicks = inhabited_ticks;
ssr.tileData = tileData;
SnapshotCache.cache.putSnapshot(dw.getName(), chunk.x, chunk.z, ssr, blockdata, biome, biomeraw, highesty);
}
}
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) {
/* 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,
* while the actual in-use chunk area for a player where the chunks are managed
* 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++;
}
DynmapCore.setIgnoreChunkLoads(false);
if(iterator.hasNext() == false) { /* If we're done */
isempty = true;
/* Fill missing chunks with empty dummy chunk */
for(int i = 0; i < snaparray.length; i++) {
if(snaparray[i] == null)
snaparray[i] = EMPTY;
else if(snaparray[i] != EMPTY)
isempty = false;
}
}
return cnt;
}
/**
* Test if done loading
*/
@Override
public boolean isDoneLoading() {
if(dw.isLoaded() == false) {
isempty = true;
unloadChunks();
return true;
}
if(iterator != null)
return !iterator.hasNext();
return false;
}
@Override
public int readChunks() {
return 0;
}
}
@@ -3,20 +3,30 @@ package org.dynmap.bukkit;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.lang.ref.SoftReference;
import java.util.IdentityHashMap;
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 long inhabitedTicks;
public DynIntHashMap tileData;
};
public static SnapshotCache cache;
private CacheHashMap snapcache;
private ReferenceQueue<ChunkSnapshot> refqueue;
private ReferenceQueue<SnapshotRec> refqueue;
private long cache_attempts;
private long cache_success;
private boolean softref;
private static class CacheRec {
WeakReference<ChunkSnapshot> ref;
Reference<SnapshotRec> ref;
boolean hasbiome;
boolean hasrawbiome;
boolean hasblockdata;
@@ -26,12 +36,12 @@ public class SnapshotCache {
@SuppressWarnings("serial")
public class CacheHashMap extends LinkedHashMap<String, CacheRec> {
private int limit;
private IdentityHashMap<WeakReference<ChunkSnapshot>, String> reverselookup;
private IdentityHashMap<Reference<SnapshotRec>, String> reverselookup;
public CacheHashMap(int lim) {
super(16, (float)0.75, true);
limit = lim;
reverselookup = new IdentityHashMap<WeakReference<ChunkSnapshot>, String>();
reverselookup = new IdentityHashMap<Reference<SnapshotRec>, String>();
}
protected boolean removeEldestEntry(Map.Entry<String, CacheRec> last) {
boolean remove = (size() >= limit);
@@ -45,9 +55,10 @@ public class SnapshotCache {
/**
* Create snapshot cache
*/
public SnapshotCache(int max_size) {
public SnapshotCache(int max_size, boolean softref) {
snapcache = new CacheHashMap(max_size);
refqueue = new ReferenceQueue<ChunkSnapshot>();
refqueue = new ReferenceQueue<SnapshotRec>();
this.softref = softref;
}
private String getKey(String w, int cx, int cz) {
return w + ":" + cx + ":" + cz;
@@ -83,11 +94,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 +123,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 +132,10 @@ public class SnapshotCache {
rec.hasbiome = biome;
rec.hasrawbiome = biomeraw;
rec.hashighesty = highesty;
rec.ref = new WeakReference<ChunkSnapshot>(ss, refqueue);
if (softref)
rec.ref = new SoftReference<SnapshotRec>(ss, refqueue);
else
rec.ref = new WeakReference<SnapshotRec>(ss, refqueue);
CacheRec prevrec = snapcache.put(key, rec);
if(prevrec != null) {
snapcache.reverselookup.remove(prevrec.ref);
@@ -132,7 +146,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) {
@@ -0,0 +1,5 @@
#Generated by Maven
#Fri Sep 19 23:52:48 CDT 2014
version=2.0.0-SNAPSHOT
groupId=us.dynmap
artifactId=DynmapBukkitBase
+53
View File
@@ -0,0 +1,53 @@
<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>us.dynmap</groupId>
<artifactId>DynmapBukkit_1_7_10</artifactId>
<name>DynmapBukkit_1_7_10</name>
<url>http://github.com/webbukkit/dynmap/</url>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/webbukkit/dynmap/issues</url>
</issueManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<releases>
</releases>
<snapshots>
</snapshots>
<id>dynmap-repo</id>
<url>http://repo.mikeprimm.com/</url>
</repository>
</repositories>
<version>2.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>Bukkit</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>DynmapCore</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>CraftBukkit</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,414 @@
package org.dynmap.bukkit;
import java.io.DataInputStream;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import net.minecraft.server.v1_7_R4.ChunkProviderServer;
import net.minecraft.server.v1_7_R4.ChunkRegionLoader;
import net.minecraft.server.v1_7_R4.IChunkLoader;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import org.bukkit.World;
import org.bukkit.Chunk;
import org.bukkit.block.Biome;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.ChunkSnapshot;
import org.dynmap.DynmapChunk;
import org.dynmap.DynmapCore;
import org.dynmap.DynmapWorld;
import org.dynmap.Log;
import org.dynmap.bukkit.BaseMapChunkCache;
import org.dynmap.bukkit.SnapshotCache;
import org.dynmap.bukkit.SnapshotCache.SnapshotRec;
import org.dynmap.common.BiomeMap;
import org.dynmap.hdmap.HDBlockModels;
import org.dynmap.renderer.RenderPatchFactory;
import org.dynmap.utils.DynIntHashMap;
import org.dynmap.utils.MapChunkCache;
import org.dynmap.utils.MapIterator;
import org.dynmap.utils.BlockStep;
import org.dynmap.utils.VisibilityLimit;
/**
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
*/
public class V1_7_10_MapChunkCache extends BaseMapChunkCache {
private boolean doneLoad = false;
private ChunkProviderServer cps;
private ChunkRegionLoader loader;
private static boolean didInit = false;
private static Field loaderField = null;
public V1_7_10_MapChunkCache() {
if (!didInit) {
try {
loaderField = ChunkProviderServer.class.getField("f");
} catch (NoSuchFieldException nsfx) {
Log.info("Error finding chunk loader");
loaderField = null;
}
didInit = true;
}
}
private boolean isVisibleChunk(DynmapChunk chunk) {
boolean vis = true;
if(visible_limits != null) {
vis = false;
for(VisibilityLimit limit : visible_limits) {
if (limit.doIntersectChunk(chunk.x, chunk.z)) {
vis = true;
break;
}
}
}
if(vis && (hidden_limits != null)) {
for(VisibilityLimit limit : hidden_limits) {
if (limit.doIntersectChunk(chunk.x, chunk.z)) {
vis = false;
break;
}
}
}
return vis;
}
private boolean isInCache(DynmapChunk chunk, int idx, boolean vis) {
SnapshotRec ssr = SnapshotCache.cache.getSnapshot(dw.getName(), chunk.x, chunk.z, blockdata, biome, biomeraw, highesty);
if(ssr != null) {
ChunkSnapshot ss = ssr.ss;
if(!vis) {
if(hidestyle == HiddenChunkStyle.FILL_STONE_PLAIN)
ss = STONE;
else if(hidestyle == HiddenChunkStyle.FILL_OCEAN)
ss = OCEAN;
else
ss = EMPTY;
}
snaparray[idx] = ss;
snaptile[idx] = ssr.tileData;
inhabitedTicks[idx] = ssr.inhabitedTicks;
}
return (ssr != null);
}
@Override
public int loadChunks(int max_to_load) {
if(dw.isLoaded() == false)
return 0;
Object queue = helper.getUnloadQueue(w);
int cnt = 0;
Iterator<DynmapChunk> iterator = chunks.listIterator();
//boolean isnormral = w.getEnvironment() == Environment.NORMAL;
// Load the required chunks.
while (iterator.hasNext()) {
long startTime = System.nanoTime();
DynmapChunk chunk = iterator.next();
int idx = (chunk.x - x_min) + ((chunk.z - z_min) * x_dim);
if (snaparray[idx] != null) {
continue;
}
boolean vis = isVisibleChunk(chunk);
/* Check if cached chunk snapshot found */
if (isInCache(chunk, idx, vis)) {
endChunkLoad(startTime, ChunkStats.CACHED_SNAPSHOT_HIT);
continue;
}
ChunkSnapshot ss = null;
long inhabited_ticks = 0;
DynIntHashMap tileData = null;
// See if chunk already loaded
boolean wasLoaded = w.isChunkLoaded(chunk.x, chunk.z);
boolean isunloadpending = false;
if (queue != null) {
isunloadpending = helper.isInUnloadQueue(queue, chunk.x, chunk.z);
}
// If loaded, and not being unloaded, read live chunk
if (wasLoaded && (!isunloadpending)) {
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;
else if(hidestyle == HiddenChunkStyle.FILL_OCEAN)
ss = OCEAN;
else
ss = EMPTY;
}
else {
if(blockdata || highesty) {
ss = c.getChunkSnapshot(highesty, biome, biomeraw);
/* Get tile entity data */
List<Object> vals = new ArrayList<Object>();
Map<?,?> tileents = helper.getTileEntitiesForChunk(c);
for(Object t : tileents.values()) {
int te_x = helper.getTileEntityX(t);
int te_y = helper.getTileEntityY(t);
int te_z = helper.getTileEntityZ(t);
int cx = te_x & 0xF;
int cz = te_z & 0xF;
int blkid = ss.getBlockTypeId(cx, te_y, cz);
int blkdat = ss.getBlockData(cx, te_y, cz);
String[] te_fields = HDBlockModels.getTileEntityFieldsNeeded(blkid, blkdat);
if(te_fields != null) {
Object nbtcompound = helper.readTileEntityNBT(t);
vals.clear();
for(String id: te_fields) {
Object val = helper.getFieldValue(nbtcompound, id);
if(val != null) {
vals.add(id);
vals.add(val);
}
}
if(vals.size() > 0) {
Object[] vlist = vals.toArray(new Object[vals.size()]);
tileData.put(getIndexInChunk(cx,te_y,cz), vlist);
}
}
}
}
else
ss = w.getEmptyChunkSnapshot(chunk.x, chunk.z, biome, biomeraw);
if(ss != null) {
SnapshotRec ssr = new SnapshotRec();
ssr.ss = ss;
ssr.inhabitedTicks = inhabited_ticks;
ssr.tileData = tileData;
SnapshotCache.cache.putSnapshot(dw.getName(), chunk.x, chunk.z, ssr, blockdata, biome, biomeraw, highesty);
}
}
int chunkIndex = (chunk.x-x_min) + (chunk.z - z_min)*x_dim;
snaparray[chunkIndex] = ss;
snaptile[chunkIndex] = tileData;
inhabitedTicks[chunkIndex] = inhabited_ticks;
endChunkLoad(startTime, ChunkStats.LOADED_CHUNKS);
}
else {
endChunkLoad(startTime, ChunkStats.UNGENERATED_CHUNKS);
}
cnt++;
}
doneLoad = true;
return cnt;
}
/**
* Test if done loading
*/
@Override
public boolean isDoneLoading() {
return doneLoad;
}
@Override
public int readChunks() {
if(dw.isLoaded() == false)
return 0;
Object queue = helper.getUnloadQueue(w);
cps = ((CraftWorld) w).getHandle().chunkProviderServer;
try {
IChunkLoader cloader = (IChunkLoader) loaderField.get(cps);
if (cloader instanceof ChunkRegionLoader) {
loader = (ChunkRegionLoader) cloader;
}
} catch (IllegalArgumentException iax) {
} catch (IllegalAccessException ixx) {
}
if (loader == null) {
Log.warning("Unable to find usable chunk loader");
return 0;
}
int cnt = 0;
Iterator<DynmapChunk> iterator = chunks.listIterator();
//boolean isnormral = w.getEnvironment() == Environment.NORMAL;
// Load the required chunks.
while (iterator.hasNext()) {
long startTime = System.nanoTime();
DynmapChunk chunk = iterator.next();
int idx = (chunk.x - x_min) + ((chunk.z - z_min) * x_dim);
if (snaparray[idx] != null) {
continue;
}
boolean vis = isVisibleChunk(chunk);
}
// Finish up any chunks that didn't get loaded or read
isempty = true;
/* Fill missing chunks with empty dummy chunk */
for(int i = 0; i < snaparray.length; i++) {
if(snaparray[i] == null)
snaparray[i] = EMPTY;
else if(snaparray[i] != EMPTY)
isempty = false;
}
return 0;
}
public NBTTagCompound readChunk(int x, int z) {
try {
List<?> chunkstoremove = null;
Set<?> pendingcoords = null;
LinkedHashMap<?,?> pendingsavesmcpc = null;
if (pendingAnvilChunksMCPC != null) {
pendingsavesmcpc = (LinkedHashMap<?,?>)pendingAnvilChunksMCPC.get(acl);
}
else {
chunkstoremove = (List<?>)chunksToRemove.get(acl);
pendingcoords = (Set<?>)pendingAnvilChunksCoordinates.get(acl);
}
Object synclock = syncLockObject.get(acl);
NBTTagCompound rslt = null;
ChunkCoordIntPair coord = new ChunkCoordIntPair(x, z);
synchronized (synclock) {
if (pendingAnvilChunksMCPC != null) {
Object rec = pendingsavesmcpc.get(coord);
if(rec != null) {
if (chunkCoord == null) {
Field[] f = rec.getClass().getDeclaredFields();
for(Field ff : f) {
if((chunkCoord == null) && (ff.getType().equals(ChunkCoordIntPair.class))) {
chunkCoord = ff;
}
else if((nbtTag == null) && (ff.getType().equals(NBTTagCompound.class))) {
nbtTag = ff;
}
}
}
rslt = (NBTTagCompound)nbtTag.get(rec);
}
}
else {
if (pendingcoords.contains(coord)) {
for (int i = 0; i < chunkstoremove.size(); i++) {
Object o = chunkstoremove.get(i);
if (chunkCoord == null) {
Field[] f = o.getClass().getDeclaredFields();
for(Field ff : f) {
if((chunkCoord == null) && (ff.getType().equals(ChunkCoordIntPair.class))) {
chunkCoord = ff;
}
else if((nbtTag == null) && (ff.getType().equals(NBTTagCompound.class))) {
nbtTag = ff;
}
}
}
ChunkCoordIntPair occ = (ChunkCoordIntPair)chunkCoord.get(o);
if (occ.equals(coord)) {
rslt = (NBTTagCompound)nbtTag.get(o);
break;
}
}
}
}
}
if (rslt == null) {
DataInputStream str = RegionFileCache.getChunkInputStream(acl.chunkSaveLocation, x, z);
if (str == null) {
return null;
}
rslt = CompressedStreamTools.read(str);
}
if(rslt != null)
rslt = rslt.getCompoundTag("Level");
return rslt;
} catch (Exception exc) {
return null;
}
}
private Object getNBTValue(NBTBase v) {
Object val = null;
switch(v.getId()) {
case 1: // Byte
val = Byte.valueOf(((NBTTagByte)v).func_150290_f());
break;
case 2: // Short
val = Short.valueOf(((NBTTagShort)v).func_150289_e());
break;
case 3: // Int
val = Integer.valueOf(((NBTTagInt)v).func_150287_d());
break;
case 4: // Long
val = Long.valueOf(((NBTTagLong)v).func_150291_c());
break;
case 5: // Float
val = Float.valueOf(((NBTTagFloat)v).func_150288_h());
break;
case 6: // Double
val = Double.valueOf(((NBTTagDouble)v).func_150286_g());
break;
case 7: // Byte[]
val = ((NBTTagByteArray)v).func_150292_c();
break;
case 8: // String
val = ((NBTTagString)v).func_150285_a_();
break;
case 9: // List
NBTTagList tl = (NBTTagList) v;
ArrayList<Object> vlist = new ArrayList<Object>();
int type = tl.func_150303_d();
for (int i = 0; i < tl.tagCount(); i++) {
switch (type) {
case 5:
float fv = tl.func_150308_e(i);
vlist.add(fv);
break;
case 6:
double dv = tl.func_150309_d(i);
vlist.add(dv);
break;
case 8:
String sv = tl.getStringTagAt(i);
vlist.add(sv);
break;
case 10:
NBTTagCompound tc = tl.getCompoundTagAt(i);
vlist.add(getNBTValue(tc));
break;
case 11:
int[] ia = tl.func_150306_c(i);
vlist.add(ia);
break;
}
}
val = vlist;
break;
case 10: // Map
NBTTagCompound tc = (NBTTagCompound) v;
HashMap<String, Object> vmap = new HashMap<String, Object>();
for (Object t : tc.func_150296_c()) {
String st = (String) t;
NBTBase tg = tc.getTag(st);
vmap.put(st, getNBTValue(tg));
}
val = vmap;
break;
case 11: // Int[]
val = ((NBTTagIntArray)v).func_150302_c();
break;
}
return val;
}
}
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+177
View File
@@ -0,0 +1,177 @@
<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>us.dynmap</groupId>
<artifactId>dynmap</artifactId>
<name>dynmap</name>
<properties>
<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>
<url>http://github.com/webbukkit/dynmap/</url>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/webbukkit/dynmap/issues</url>
</issueManagement>
<build>
<directory>../target</directory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>*.yml</include>
<include>*.txt</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>*.yml</exclude>
<exclude>*.txt</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>us.dynmap:dynmap-api:jar:*</include>
<include>us.dynmap:DynmapCore:jar:*</include>
<include>us.dynmap:DynmapBukkitBase: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>
<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>3.1.6</version>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>Bukkit</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>dynmap-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>DynmapCore</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.tehkode</groupId>
<artifactId>PermissionsEx</artifactId>
<version>1.19.1</version>
</dependency>
<dependency>
<groupId>de.bananaco</groupId>
<artifactId>bPermissions</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>com.platymuus.bukkit.permissions</groupId>
<artifactId>PermissionsBukkit</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.anjocaido</groupId>
<artifactId>EssentialsGroupManager</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>DynmapSpigot</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>DynmapBukkitBase</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>DynmapBukkit_1_7_10</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<version>2.0.0-SNAPSHOT</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>
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More