Compare commits

..

46 Commits

Author SHA1 Message Date
Mike Primm a493f85bcf Bump to 0.35 (API changes) 2012-03-13 10:55:34 -05:00
Mike Primm 1ab7a8ddbf Handle lighting checks above world top 2012-03-13 01:10:47 -05:00
Mike Primm bdb2620ca9 Fix typo 2012-03-12 18:46:12 -05:00
Mike Primm d8812ce575 Add 'visiblelines' setting for 'chatbox' - control visible space on scrollback 2012-03-12 01:32:58 -05:00
Mike Primm 6c618fa727 More cleanup 2012-03-11 19:56:54 -05:00
Mike Primm a9214502cf More config cleanup 2012-03-11 18:49:58 -05:00
Mike Primm ef0ad40496 Update to 1.2 biome shading model (1.1 maps will be 1.2-style shaded - sorry) 2012-03-11 16:17:32 -05:00
Mike Primm 2628559b55 Retire old beta render options (correct-biome-shading, smooth-biome-shading, waterbiomeshaded, swampshaded, fence-to-block-join) 2012-03-11 16:14:22 -05:00
Mike Primm 11021720c7 Add new commands and security settings for circle markers 2012-03-10 18:14:22 -06:00
Mike Primm de4fdb2b0c Fix handling of normalized world names 2012-03-10 15:07:13 -06:00
Mike Primm ecdb50920e Try fix for getHighestBlockY() not working as advertised 2012-03-09 14:33:51 -06:00
Mike Primm 50f7382b7a Bump to 0.34.1 2012-03-04 23:56:17 -06:00
Mike Primm 56875a05d4 Fix nether render in 1.1 and 1.2 2012-03-04 20:21:01 -06:00
Mike Primm f392eb1344 Drop listeners for disabled triggers (overhead on very big servers) 2012-03-03 23:20:04 -06:00
Mike Primm a41e052f51 Big performance boost - exploit empty section data, max block y in ray trace 2012-03-03 09:33:07 -06:00
Mike Primm 0e97fedd6b Add support for 'blockgrow' trigger (for growing crops) 2012-02-28 23:40:52 -06:00
Mike Primm 9d97f86b7f Add config setting for ComputerCraft rendering 2012-02-28 22:23:58 -06:00
Mike Primm 516125e87b Support world names with '/' characters (substitute internally with '-') 2012-02-27 22:14:48 -06:00
Mike Primm e52234336e Bump to 0.34 2012-02-26 21:11:20 -06:00
Mike Primm af10e942a9 Update bukkit library to 1.1-R5 2012-02-24 21:13:31 -06:00
Mike Primm 1e52061b27 Update Jetty to 8.1.1 2012-02-24 16:44:55 -06:00
Mike Primm b0ca796213 Add disable API for chat-to-web processing (for mods to replace it) 2012-02-22 23:10:13 -06:00
Mike Primm cac8527d76 Add sealevel and world height for client info 2012-02-22 21:12:29 -06:00
Mike Primm 35cf3ed8fa More improvement on blockphysics and blockfromto chatter 2012-02-22 21:00:13 -06:00
Mike Primm 888051d497 Try to reduce excessive firing of blockfromto and blockphysics triggers 2012-02-22 08:07:13 -06:00
Mike Primm 559bc0ef55 Add optional send message pushbutton on web ui (chatbox component) 2012-02-22 00:51:13 -06:00
Mike Primm b85bd1dce7 Make player-join processing monitor priority - give VNP a chance to hide it 2012-02-22 00:26:03 -06:00
Mike Primm 87bbd3023e Fix more 1.1-R5 breaks... 2012-02-21 23:34:00 -06:00
Mike Primm fa80af8e81 Remove HeroChat code - HeroChat 4 API doesn't work as of 1.1-R5 2012-02-19 15:18:17 -06:00
Mike Primm 0c9057949d Add global image-format setting - default for all HD maps 2012-02-19 14:56:45 -06:00
Mike Primm f95a832cae Fix section size 2012-02-17 00:13:33 -06:00
Mike Primm 2e2fbec8f9 Add section empty methods 2012-02-16 22:45:34 -06:00
Mike Primm 63a638f96e Fix dependency on bukkit-bleeding level bukkit 2012-02-16 07:53:15 -06:00
Mike Primm bcf679b078 Chunk section prep 2012-02-15 22:34:45 -06:00
Mike Primm 5ad4ba285b Strip out obsolete pre 1.1 bukkit workarounds, fixes 2012-02-14 20:54:36 -06:00
Mike Primm 71185b06d6 Bump to 0.33 2012-02-13 21:30:12 -06:00
Mike Primm f1782fd9f4 Add 'structuregrow' trigger event - update on tree grow, giant mushroom grow 2012-02-13 20:06:37 -06:00
Mike Primm f0907ce954 Add assetPlayerVisbility() API 2012-02-12 23:59:29 -06:00
Mike Primm 7ce55a3fd3 Add offline player methods 2012-02-12 23:10:18 -06:00
Mike Primm d0e477b3e7 Add new command descriptions, security settings for poly-lines 2012-02-12 01:25:45 -06:00
Mike Primm 0053d89d2b Add some extra array bounds protection 2012-02-11 23:28:44 -06:00
Mike Primm 1ef9bdd861 Migrate to 1.1 event system (breaks 1.0 compatibility) 2012-02-11 23:02:23 -06:00
Mike Primm 9be7c4d7ef Add maxofflinetime setting - age out for offline player markers 2012-02-11 19:21:15 -06:00
Mike Primm c7b709fd75 Make smooth swamp biome shading smoother 2012-02-10 21:54:32 -06:00
Mike Primm 57a69bf9ad Add smooth-lighting global setting (switch on smooth lighting on all) 2012-02-10 00:44:04 -06:00
Mike Primm ddf3b71592 Bump to 0.32 2012-02-08 20:17:11 -06:00
10 changed files with 778 additions and 1334 deletions
+2 -17
View File
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.dynmap</groupId>
<artifactId>dynmap</artifactId>
<version>0.31</version>
<version>0.35</version>
<name>dynmap</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -133,7 +133,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>[1.1-R1-SNAPSHOT,)</version>
<version>[1.1-R5-SNAPSHOT,1.7)</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
@@ -144,21 +144,6 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>8.0.1.v20110908</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>8.0.1.v20110908</version>
</dependency>
<dependency>
<groupId>org.dynmap</groupId>
@@ -1,80 +0,0 @@
package org.dynmap.bukkit;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.bukkit.block.Block;
import org.dynmap.Log;
/**
* Wrapper for accessing raw light levels for given block
*/
public class BlockLightLevel {
private Method gethandle;
private Method getrawlight;
private Object enum_sky;
private Object enum_block;
private boolean ready;
@SuppressWarnings({ "unchecked", "rawtypes" })
public BlockLightLevel() {
/* Get CraftChunk.getChunkSnapshot(boolean,boolean,boolean) and CraftChunk.getHandle() */
try {
Class c = Class.forName("org.bukkit.craftbukkit.CraftChunk");
gethandle = c.getDeclaredMethod("getHandle", new Class[0]);
Class enumskyblock = Class.forName("net.minecraft.server.EnumSkyBlock");
Object[] enumvals = enumskyblock.getEnumConstants();
for(int i = 0; i < enumvals.length; i++) {
String ev = enumvals[i].toString();
if(ev.equals("Sky")) {
enum_sky = enumvals[i];
}
else if(ev.equals("Block")) {
enum_block = enumvals[i];
}
}
Class cc = Class.forName("net.minecraft.server.Chunk");
getrawlight = cc.getDeclaredMethod("a", new Class[] { enumskyblock, int.class, int.class, int.class });
} catch (ClassNotFoundException cnfx) {
} catch (NoSuchMethodException nsmx) {
}
if((gethandle != null) && (enum_sky != null) && (enum_block != null) && (getrawlight != null)) {
ready = true;
}
else {
Log.warning("Block raw light level API not available");
}
}
public boolean isReady() {
return ready;
}
public int getSkyLightLevel(Block b) {
try {
Object hand = gethandle.invoke(b.getChunk());
if(hand != null) {
Integer v = (Integer)getrawlight.invoke(hand, enum_sky, b.getX() & 0xF, b.getY() & 0x7F, b.getZ() & 0xF);
return v;
}
} catch (InvocationTargetException itx) {
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
}
return -1;
}
public int getBlockLightLevel(Block b) {
try {
Object hand = gethandle.invoke(b.getChunk());
if(hand != null) {
Integer v = (Integer)getrawlight.invoke(hand, enum_block, b.getX() & 0xF, b.getY() & 0x7F, b.getZ() & 0xF);
return v;
}
} catch (InvocationTargetException itx) {
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
}
return -1;
}
}
@@ -1,449 +0,0 @@
package org.dynmap.bukkit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.event.CustomEventListener;
import org.bukkit.event.Event;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.player.PlayerBedLeaveEvent;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkPopulateEvent;
import org.bukkit.event.world.SpawnChangeEvent;
import org.bukkit.event.world.WorldListener;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.dynmap.Log;
public class BukkitEventProcessor {
private Plugin plugin;
private PluginManager pm;
private HashMap<Event.Type, List<Listener>> event_handlers = new HashMap<Event.Type, List<Listener>>();
public BukkitEventProcessor(Plugin plugin) {
this.plugin = plugin;
this.pm = plugin.getServer().getPluginManager();
}
public void cleanup() {
/* Clean up all registered handlers */
for(Event.Type t : event_handlers.keySet()) {
List<Listener> ll = event_handlers.get(t);
ll.clear(); /* Empty list - we use presence of list to remember that we've registered with Bukkit */
}
if(plugin.getServer().getVersion().contains("(MC: 1.0") == false) {
event_handlers.clear();
}
}
private BlockListener ourBlockEventHandler = new BlockListener() {
@Override
public void onBlockPlace(BlockPlaceEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((BlockListener)l).onBlockPlace(event);
}
}
}
@Override
public void onBlockBreak(BlockBreakEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((BlockListener)l).onBlockBreak(event);
}
}
}
@Override
public void onLeavesDecay(LeavesDecayEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((BlockListener)l).onLeavesDecay(event);
}
}
}
@Override
public void onBlockBurn(BlockBurnEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((BlockListener)l).onBlockBurn(event);
}
}
}
@Override
public void onBlockForm(BlockFormEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((BlockListener)l).onBlockForm(event);
}
}
}
@Override
public void onBlockFade(BlockFadeEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((BlockListener)l).onBlockFade(event);
}
}
}
@Override
public void onBlockSpread(BlockSpreadEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((BlockListener)l).onBlockSpread(event);
}
}
}
@Override
public void onBlockFromTo(BlockFromToEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((BlockListener)l).onBlockFromTo(event);
}
}
}
@Override
public void onBlockPhysics(BlockPhysicsEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((BlockListener)l).onBlockPhysics(event);
}
}
}
@Override
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((BlockListener)l).onBlockPistonRetract(event);
}
}
}
@Override
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((BlockListener)l).onBlockPistonExtend(event);
}
}
}
@Override
public void onSignChange(SignChangeEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((BlockListener)l).onSignChange(event);
}
}
}
};
private PlayerListener ourPlayerEventHandler = new PlayerListener() {
@Override
public void onPlayerJoin(PlayerJoinEvent event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((PlayerListener)l).onPlayerJoin(event);
}
}
}
@Override
public void onPlayerLogin(PlayerLoginEvent event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((PlayerListener)l).onPlayerLogin(event);
}
}
}
@Override
public void onPlayerMove(PlayerMoveEvent event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((PlayerListener)l).onPlayerMove(event);
}
}
}
@Override
public void onPlayerQuit(PlayerQuitEvent event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((PlayerListener)l).onPlayerQuit(event);
}
}
}
@Override
public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((PlayerListener)l).onPlayerBedLeave(event);
}
}
}
@Override
public void onPlayerChat(PlayerChatEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((PlayerListener)l).onPlayerChat(event);
}
}
}
};
private WorldListener ourWorldEventHandler = new WorldListener() {
@Override
public void onWorldLoad(WorldLoadEvent event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((WorldListener)l).onWorldLoad(event);
}
}
}
@Override
public void onWorldUnload(WorldUnloadEvent event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((WorldListener)l).onWorldUnload(event);
}
}
}
@Override
public void onChunkLoad(ChunkLoadEvent event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((WorldListener)l).onChunkLoad(event);
}
}
}
@Override
public void onChunkPopulate(ChunkPopulateEvent event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((WorldListener)l).onChunkPopulate(event);
}
}
}
@Override
public void onSpawnChange(SpawnChangeEvent event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((WorldListener)l).onSpawnChange(event);
}
}
}
};
private CustomEventListener ourCustomEventHandler = new CustomEventListener() {
@Override
public void onCustomEvent(Event event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((CustomEventListener)l).onCustomEvent(event);
}
}
}
};
private EntityListener ourEntityEventHandler = new EntityListener() {
@Override
public void onEntityExplode(EntityExplodeEvent event) {
if(event.isCancelled())
return;
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((EntityListener)l).onEntityExplode(event);
}
}
}
};
private ServerListener ourServerEventHandler = new ServerListener() {
@Override
public void onPluginEnable(PluginEnableEvent event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((ServerListener)l).onPluginEnable(event);
}
}
}
@Override
public void onPluginDisable(PluginDisableEvent event) {
/* Call listeners */
List<Listener> ll = event_handlers.get(event.getType());
if(ll != null) {
for(Listener l : ll) {
((ServerListener)l).onPluginDisable(event);
}
}
}
};
/**
* Register event listener - this will be cleaned up properly on a /dynmap reload, unlike
* registering with Bukkit directly
*/
public void registerEvent(Event.Type type, Listener listener) {
List<Listener> ll = event_handlers.get(type);
if(ll == null) {
switch(type) { /* See if it is a type we're brokering */
case PLAYER_LOGIN:
case PLAYER_CHAT:
case PLAYER_JOIN:
case PLAYER_QUIT:
case PLAYER_MOVE:
case PLAYER_BED_LEAVE:
pm.registerEvent(type, ourPlayerEventHandler, Event.Priority.Monitor, plugin);
break;
case BLOCK_PLACE:
case BLOCK_BREAK:
case LEAVES_DECAY:
case BLOCK_BURN:
case BLOCK_FORM:
case BLOCK_FADE:
case BLOCK_SPREAD:
case BLOCK_FROMTO:
case BLOCK_PHYSICS:
case BLOCK_PISTON_EXTEND:
case BLOCK_PISTON_RETRACT:
pm.registerEvent(type, ourBlockEventHandler, Event.Priority.Monitor, plugin);
break;
case SIGN_CHANGE:
pm.registerEvent(type, ourBlockEventHandler, Event.Priority.Low, plugin);
break;
case WORLD_LOAD:
case WORLD_UNLOAD:
case CHUNK_LOAD:
case CHUNK_POPULATED:
case SPAWN_CHANGE:
pm.registerEvent(type, ourWorldEventHandler, Event.Priority.Monitor, plugin);
break;
case CUSTOM_EVENT:
pm.registerEvent(type, ourCustomEventHandler, Event.Priority.Monitor, plugin);
break;
case ENTITY_EXPLODE:
pm.registerEvent(type, ourEntityEventHandler, Event.Priority.Monitor, plugin);
break;
case PLUGIN_ENABLE:
case PLUGIN_DISABLE:
pm.registerEvent(type, ourServerEventHandler, Event.Priority.Monitor, plugin);
break;
default:
Log.severe("registerEvent() in DynmapPlugin does not handle " + type);
return;
}
ll = new ArrayList<Listener>();
event_handlers.put(type, ll); /* Add list for this event */
}
ll.add(listener);
}
}
@@ -13,10 +13,9 @@ import org.dynmap.utils.MapChunkCache;
public class BukkitWorld extends DynmapWorld {
private World world;
private static BlockLightLevel bll = new BlockLightLevel();
public BukkitWorld(World w) {
super(w.getName(), w.getMaxHeight());
super(w.getName(), w.getMaxHeight(), w.getSeaLevel());
world = w;
}
@@ -31,7 +30,7 @@ public class BukkitWorld extends DynmapWorld {
DynmapLocation dloc = new DynmapLocation();
Location sloc = world.getSpawnLocation();
dloc.x = sloc.getBlockX(); dloc.y = sloc.getBlockY();
dloc.z = sloc.getBlockZ(); dloc.world = sloc.getWorld().getName();
dloc.z = sloc.getBlockZ(); dloc.world = normalizeWorldName(sloc.getWorld().getName());
return dloc;
}
/* Get world time */
@@ -67,12 +66,12 @@ public class BukkitWorld extends DynmapWorld {
/* Test if sky light level is requestable */
@Override
public boolean canGetSkyLightLevel() {
return bll.isReady();
return true;
}
/* Return sky light level */
@Override
public int getSkyLightLevel(int x, int y, int z) {
return bll.getSkyLightLevel(world.getBlockAt(x, y, z));
return world.getBlockAt(x, y, z).getLightFromSky();
}
/**
* Get world environment ID (lower case - normal, the_end, nether)
File diff suppressed because it is too large Load Diff
@@ -1,24 +1,21 @@
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.Arrays;
import java.util.List;
import java.util.ListIterator;
import java.util.TreeSet;
import org.bukkit.World;
import org.bukkit.Chunk;
import org.bukkit.block.Biome;
import org.bukkit.entity.Entity;
import org.bukkit.ChunkSnapshot;
import org.dynmap.DynmapAPI;
import org.dynmap.DynmapChunk;
import org.dynmap.DynmapCore;
import org.dynmap.DynmapWorld;
import org.dynmap.Log;
import org.dynmap.MapManager;
import org.dynmap.common.BiomeMap;
import org.dynmap.utils.MapChunkCache;
import org.dynmap.utils.MapIterator;
@@ -34,17 +31,13 @@ public class NewMapChunkCache implements MapChunkCache {
private static Method gethandle = null;
private static Method removeentities = null;
private static Method getworldhandle = null;
private static Field chunkbiome = null;
private static Field ticklist = null;
private static Method processticklist = null;
private static boolean use_spout = false;
private static final int MAX_PROCESSTICKS = 20;
private static final int MAX_TICKLIST = 20000;
private static boolean use_sections = false;
private World w;
private DynmapWorld dw;
private Object craftworld;
private int nsect;
private List<DynmapChunk> chunks;
private ListIterator<DynmapChunk> iterator;
private int x_min, x_max, z_min, z_max;
@@ -57,7 +50,9 @@ public class NewMapChunkCache implements MapChunkCache {
private boolean do_save = false;
private boolean isempty = true;
private ChunkSnapshot[] snaparray; /* Index = (x-x_min) + ((z-z_min)*x_dim) */
private TreeSet<?> ourticklist;
private byte[][] sameneighborbiomecnt;
private BiomeMap[][] biomemap;
private boolean[][] isSectionNotEmpty; /* Indexed by snapshot index, then by section index */
private int chunks_read; /* Number of chunks actually loaded */
private int chunks_attempted; /* Number of chunks attempted to load */
@@ -79,12 +74,15 @@ public class NewMapChunkCache implements MapChunkCache {
private BlockStep laststep;
private int typeid = -1;
private int blkdata = -1;
private int lastbiome_x = Integer.MIN_VALUE, lastbiome_z = Integer.MIN_VALUE;
private BiomeMap lastbiome;
private int lastcountswamp_x = Integer.MIN_VALUE, lastcountswamp_z = Integer.MIN_VALUE, lastcountswamp;
private final int worldheight;
private final int x_base;
private final int z_base;
OurMapIterator(int x0, int y0, int z0) {
x_base = x_min << 4;
z_base = z_min << 4;
if(biome)
biomePrep();
initialize(x0, y0, z0);
worldheight = w.getMaxHeight();
}
@@ -116,58 +114,163 @@ public class NewMapChunkCache implements MapChunkCache {
return blkdata;
}
public int getBlockSkyLight() {
return snap.getBlockSkyLight(bx, y, bz);
try {
return snap.getBlockSkyLight(bx, y, bz);
} catch (ArrayIndexOutOfBoundsException aioobx) {
return 15;
}
}
public final int getBlockEmittedLight() {
return snap.getBlockEmittedLight(bx, y, bz);
}
public final BiomeMap getBiome() {
if((x == lastbiome_x) && (z == lastbiome_z)) {
return lastbiome;
try {
return snap.getBlockEmittedLight(bx, y, bz);
} catch (ArrayIndexOutOfBoundsException aioobx) {
return 0;
}
BiomeMap bio;
Biome bb = snap.getBiome(bx, bz);
if(bb != null)
bio = biome_to_bmap[bb.ordinal()];
else
bio = BiomeMap.NULL;
lastbiome_x = x;
lastbiome_z = z;
lastbiome = bio;
return bio;
}
public final int countSmoothedSwampBiomes() {
if((lastcountswamp_x == x) && (lastcountswamp_z == z))
return lastcountswamp;
int cnt = 0;
BlockStep s_bak = laststep;
if(getBiome() == BiomeMap.SWAMPLAND) cnt++;
stepPosition(BlockStep.X_MINUS);
if(getBiome() == BiomeMap.SWAMPLAND) cnt++;
stepPosition(BlockStep.Z_MINUS);
if(getBiome() == BiomeMap.SWAMPLAND) cnt++;
stepPosition(BlockStep.X_PLUS);
if(getBiome() == BiomeMap.SWAMPLAND) cnt++;
stepPosition(BlockStep.X_PLUS);
if(getBiome() == BiomeMap.SWAMPLAND) cnt++;
stepPosition(BlockStep.Z_PLUS);
if(getBiome() == BiomeMap.SWAMPLAND) cnt++;
stepPosition(BlockStep.Z_PLUS);
if(getBiome() == BiomeMap.SWAMPLAND) cnt++;
stepPosition(BlockStep.X_MINUS);
if(getBiome() == BiomeMap.SWAMPLAND) cnt++;
stepPosition(BlockStep.X_MINUS);
if(getBiome() == BiomeMap.SWAMPLAND) cnt++;
stepPosition(BlockStep.X_PLUS);
stepPosition(BlockStep.Z_MINUS);
laststep = s_bak;
lastcountswamp_x = x;
lastcountswamp_z = z;
lastcountswamp = cnt;
return cnt;
private void biomePrep() {
if(sameneighborbiomecnt != null)
return;
int x_size = x_dim << 4;
int z_size = (z_max - z_min + 1) << 4;
sameneighborbiomecnt = new byte[x_size][];
biomemap = new BiomeMap[x_size][];
for(int i = 0; i < x_size; i++) {
sameneighborbiomecnt[i] = new byte[z_size];
biomemap[i] = new BiomeMap[z_size];
}
for(int i = 0; i < x_size; i++) {
initialize(i + x_base, 64, z_base);
for(int j = 0; j < z_size; j++) {
Biome bb = snap.getBiome(bx, bz);
BiomeMap bm;
if(bb == null)
bm = BiomeMap.NULL;
else
bm = biome_to_bmap[bb.ordinal()];
biomemap[i][j] = bm;
int cnt = 0;
if(i > 0) {
if(bm == biomemap[i-1][j]) { /* Same as one to left */
cnt++;
sameneighborbiomecnt[i-1][j]++;
}
if((j > 0) && (bm == biomemap[i-1][j-1])) {
cnt++;
sameneighborbiomecnt[i-1][j-1]++;
}
if((j < (z_size-1)) && (bm == biomemap[i-1][j+1])) {
cnt++;
sameneighborbiomecnt[i-1][j+1]++;
}
}
if((j > 0) && (biomemap[i][j] == biomemap[i][j-1])) { /* Same as one to above */
cnt++;
sameneighborbiomecnt[i][j-1]++;
}
sameneighborbiomecnt[i][j] = (byte)cnt;
stepPosition(BlockStep.Z_PLUS);
}
}
}
public final BiomeMap getBiome() {
try {
return biomemap[x - x_base][z - z_base];
} catch (Exception ex) {
exceptions++;
return BiomeMap.NULL;
}
}
public final int getSmoothGrassColorMultiplier(int[] colormap, int width) {
int mult = 0xFFFFFF;
try {
int rx = x - x_base;
int rz = z - z_base;
BiomeMap bm = biomemap[rx][rz];
if(sameneighborbiomecnt[rx][rz] >= (byte)8) { /* All neighbors same? */
mult = bm.getModifiedGrassMultiplier(colormap[bm.biomeLookup(width)]);
}
else {
int raccum = 0;
int gaccum = 0;
int baccum = 0;
for(int xoff = -1; xoff < 2; xoff++) {
for(int zoff = -1; zoff < 2; zoff++) {
bm = biomemap[rx+xoff][rz+zoff];
int rmult = bm.getModifiedGrassMultiplier(colormap[bm.biomeLookup(width)]);
raccum += (rmult >> 16) & 0xFF;
gaccum += (rmult >> 8) & 0xFF;
baccum += rmult & 0xFF;
}
}
mult = ((raccum / 9) << 16) | ((gaccum / 9) << 8) | (baccum / 9);
}
} catch (Exception x) {
exceptions++;
mult = 0xFFFFFF;
}
return mult;
}
public final int getSmoothFoliageColorMultiplier(int[] colormap, int width) {
int mult = 0xFFFFFF;
try {
int rx = x - x_base;
int rz = z - z_base;
BiomeMap bm = biomemap[rx][rz];
if(sameneighborbiomecnt[rx][rz] >= (byte)8) { /* All neighbors same? */
mult = bm.getModifiedFoliageMultiplier(colormap[bm.biomeLookup(width)]);
}
else {
int raccum = 0;
int gaccum = 0;
int baccum = 0;
for(int xoff = -1; xoff < 2; xoff++) {
for(int zoff = -1; zoff < 2; zoff++) {
bm = biomemap[rx+xoff][rz+zoff];
int rmult = bm.getModifiedFoliageMultiplier(colormap[bm.biomeLookup(width)]);
raccum += (rmult >> 16) & 0xFF;
gaccum += (rmult >> 8) & 0xFF;
baccum += rmult & 0xFF;
}
}
mult = ((raccum / 9) << 16) | ((gaccum / 9) << 8) | (baccum / 9);
}
} catch (Exception x) {
exceptions++;
mult = 0xFFFFFF;
}
return mult;
}
public final int getSmoothWaterColorMultiplier() {
try {
int rx = x - x_base;
int rz = z - z_base;
BiomeMap bm = biomemap[rx][rz];
if(sameneighborbiomecnt[rx][rz] >= (byte)8) { /* All neighbors same? */
return bm.getWaterColorMult();
}
int raccum = 0;
int gaccum = 0;
int baccum = 0;
for(int xoff = -1; xoff < 2; xoff++) {
for(int zoff = -1; zoff < 2; zoff++) {
bm = biomemap[rx+xoff][rz+zoff];
int mult = bm.getWaterColorMult();
raccum += (mult >> 16) & 0xFF;
gaccum += (mult >> 8) & 0xFF;
baccum += mult & 0xFF;
}
}
return ((raccum / 9) << 16) | ((gaccum / 9) << 8) | (baccum / 9);
} catch (Exception x) {
exceptions++;
return 0xFFFFFF;
}
}
public final double getRawBiomeTemperature() {
return snap.getRawBiomeTemperature(bx, bz);
}
@@ -312,6 +415,16 @@ public class NewMapChunkCache implements MapChunkCache {
public int getWorldHeight() {
return worldheight;
}
@Override
public long getBlockKey() {
return (((chunkindex * worldheight) + y) << 8) | (bx << 4) | bz;
}
@Override
public final boolean isEmptySection() {
if(isSectionNotEmpty[chunkindex] == null)
initSectionData(chunkindex);
return !isSectionNotEmpty[chunkindex][y >> 4];
}
}
private class OurEndMapIterator extends OurMapIterator {
@@ -357,6 +470,9 @@ public class NewMapChunkCache implements MapChunkCache {
public double getRawBiomeRainfall(int x, int z) {
return 0.0;
}
public boolean isSectionEmpty(int sy) {
return true;
}
}
/**
@@ -392,6 +508,12 @@ public class NewMapChunkCache implements MapChunkCache {
public final int getHighestBlockYAt(int x, int z) {
return 64;
}
public boolean isSectionEmpty(int sy) {
return (sy < 4);
}
public int getTopNonEmptySection() {
return 3;
}
}
private static class SpoutChunkSnapshot implements ChunkSnapshot {
@@ -428,6 +550,9 @@ public class NewMapChunkCache implements MapChunkCache {
public final int getHighestBlockYAt(int x, int z) {
return chunk.getHighestBlockYAt(x, z);
}
public boolean isSectionEmpty(int sy) {
return chunk.isSectionEmpty(sy);
}
}
private static final EmptyChunk EMPTY = new EmptyChunk();
@@ -463,31 +588,13 @@ public class NewMapChunkCache implements MapChunkCache {
} catch (ClassNotFoundException cnfx) {
} catch (NoSuchMethodException nsmx) {
}
/* Get CraftChunkSnapshot.biome field */
/* Check for ChunkSnapshot.isSectionEmpty(int) method */
try {
Class c = Class.forName("org.bukkit.craftbukkit.CraftChunkSnapshot");
chunkbiome = c.getDeclaredField("biome");
chunkbiome.setAccessible(true);
} catch (ClassNotFoundException cnfx) {
} catch (NoSuchFieldException nsmx) {
}
/* ticklist for World */
try {
Class c = Class.forName("net.minecraft.server.World");
try {
ticklist = c.getDeclaredField("K"); /* 1.0.0 */
} catch (NoSuchFieldException nsfx) {
ticklist = c.getDeclaredField("N"); /* 1.8.1 */
}
ticklist.setAccessible(true);
if(ticklist.getType().isAssignableFrom(TreeSet.class) == false)
ticklist = null;
processticklist = c.getDeclaredMethod("a", new Class[] { boolean.class } );
} catch (ClassNotFoundException cnfx) {
} catch (NoSuchFieldException nsmx) {
ChunkSnapshot.class.getDeclaredMethod("isSectionEmpty", new Class[] { int.class });
use_sections = true;
} catch (NoSuchMethodException nsmx) {
}
use_spout = DynmapPlugin.plugin.hasSpout();
init = true;
@@ -496,11 +603,10 @@ public class NewMapChunkCache implements MapChunkCache {
public void setChunks(BukkitWorld dw, List<DynmapChunk> chunks) {
this.dw = dw;
this.w = dw.getWorld();
nsect = dw.worldheight >> 4;
if((getworldhandle != null) && (craftworld == null)) {
try {
craftworld = getworldhandle.invoke(w); /* World.getHandle() */
if(ticklist != null)
ourticklist = (TreeSet<?>)ticklist.get(craftworld);
} catch (Exception x) {
}
}
@@ -530,6 +636,7 @@ public class NewMapChunkCache implements MapChunkCache {
}
snaparray = new ChunkSnapshot[x_dim * (z_max-z_min+1)];
isSectionNotEmpty = new boolean[x_dim * (z_max-z_min+1)][];
}
private ChunkSnapshot checkSpoutData(Chunk c, ChunkSnapshot ss) {
@@ -549,8 +656,6 @@ public class NewMapChunkCache implements MapChunkCache {
if(iterator == null)
iterator = chunks.listIterator();
checkTickList();
DynmapCore.setIgnoreChunkLoads(true);
//boolean isnormral = w.getEnvironment() == Environment.NORMAL;
// Load the required chunks.
@@ -575,7 +680,7 @@ public class NewMapChunkCache implements MapChunkCache {
}
}
/* Check if cached chunk snapshot found */
ChunkSnapshot ss = DynmapPlugin.plugin.sscache.getSnapshot(w.getName(), chunk.x, chunk.z, blockdata, biome, biomeraw, highesty);
ChunkSnapshot ss = DynmapPlugin.plugin.sscache.getSnapshot(dw.getName(), chunk.x, chunk.z, blockdata, biome, biomeraw, highesty);
if(ss != null) {
if(!vis) {
if(hidestyle == HiddenChunkStyle.FILL_STONE_PLAIN)
@@ -616,7 +721,7 @@ public class NewMapChunkCache implements MapChunkCache {
else
ss = w.getEmptyChunkSnapshot(chunk.x, chunk.z, biome, biomeraw);
if(ss != null) {
DynmapPlugin.plugin.sscache.putSnapshot(w.getName(), chunk.x, chunk.z, ss, blockdata, biome, biomeraw, highesty);
DynmapPlugin.plugin.sscache.putSnapshot(dw.getName(), chunk.x, chunk.z, ss, blockdata, biome, biomeraw, highesty);
}
}
snaparray[(chunk.x-x_min) + (chunk.z - z_min)*x_dim] = ss;
@@ -744,6 +849,29 @@ public class NewMapChunkCache implements MapChunkCache {
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
return ss.getRawBiomeRainfall(x & 0xF, z & 0xF);
}
private void initSectionData(int idx) {
isSectionNotEmpty[idx] = new boolean[nsect + 1];
int maxy = 0;
if(snaparray[idx] != EMPTY) {
if(!use_sections) {
Arrays.fill(isSectionNotEmpty[idx], true);
}
else {
for(int i = 0; i < nsect; i++) {
if(snaparray[idx].isSectionEmpty(i) == false) {
isSectionNotEmpty[idx][i] = true;
}
}
}
}
}
public boolean isEmptySection(int sx, int sy, int sz) {
int idx = (sx - x_min) + (sz - z_min) * x_dim;
if(isSectionNotEmpty[idx] == null) {
initSectionData(idx);
}
return !isSectionNotEmpty[idx][sy];
}
/**
* Get cache iterator
@@ -845,27 +973,6 @@ public class NewMapChunkCache implements MapChunkCache {
return exceptions;
}
private boolean checkTickList() {
boolean isok = true;
if((ourticklist != null) && (processticklist != null)) {
int cnt = 0;
int ticksize = ourticklist.size();
while((cnt < MAX_PROCESSTICKS) && (ticksize > MAX_TICKLIST) && (ourticklist.size() > MAX_TICKLIST)) {
try {
processticklist.invoke(craftworld, true);
} catch (Exception x) {
}
ticksize -= 1000;
cnt++;
MapManager.mapman.incExtraTickList();
}
if(cnt >= MAX_PROCESSTICKS) { /* If still behind, delay processing */
isok = false;
}
}
return isok;
}
static {
Biome[] b = Biome.values();
BiomeMap[] bm = BiomeMap.values();
@@ -1,302 +0,0 @@
package org.dynmap.herochat;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;
import org.bukkit.event.CustomEventListener;
import org.bukkit.event.Event;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.dynmap.Client;
import org.dynmap.ConfigurationNode;
import org.dynmap.DynmapCore;
import org.dynmap.Log;
import org.dynmap.bukkit.DynmapPlugin;
/**
* Bukkit specific module - alternate chat handler for interfacing with HeroChat
*/
public class HeroChatHandler {
private static final String DEF_CHANNEL = "Global";
private static final List<String> DEF_CHANNELS = Collections
.singletonList(DEF_CHANNEL);
private List<String> hcchannels;
private String hcwebinputchannel;
private DynmapCore core;
private HeroChatChannel hcwebinputchan;
private class OurPluginListener extends ServerListener {
@Override
public void onPluginEnable(PluginEnableEvent event) {
Plugin plugin = event.getPlugin();
String name = plugin.getDescription().getName();
if (name.equals("HeroChat")) {
activateHeroChat(plugin);
}
}
}
/* Reflection-based access wrapper for ChannelChatEvent from HeroChat */
private static class HeroChatChannelChatEvent {
@SuppressWarnings("rawtypes")
private static Class channelchatevent;
private static Method getsource;
private static Method getmessage;
private static Method issentbyplayer;
private static boolean isgood = false;
private Event evt;
@SuppressWarnings("unchecked")
public static boolean initialize() {
try {
channelchatevent = Class
.forName("com.herocraftonline.dthielke.herochat.event.ChannelChatEvent");
getsource = channelchatevent.getMethod("getSource", new Class[0]);
getmessage = channelchatevent.getMethod("getMessage", new Class[0]);
issentbyplayer = channelchatevent.getMethod("isSentByPlayer", new Class[0]);
isgood = true;
} catch (ClassNotFoundException cnfx) {
} catch (NoSuchMethodException nsmx) {
}
return isgood;
}
public HeroChatChannelChatEvent(Event evt) {
this.evt = evt;
}
public static boolean isInstance(Event evt) {
return channelchatevent.isInstance(evt);
}
public String getSource() {
try {
return (String) getsource.invoke(evt);
} catch (Exception x) {
return null;
}
}
public String getMessage() {
try {
return (String) getmessage.invoke(evt);
} catch (Exception x) {
return null;
}
}
public boolean isSentByPlayer() {
try {
return (Boolean) issentbyplayer.invoke(evt);
} catch (Exception x) {
return true;
}
}
}
/* Reflection-based access wrapper for ChannelEvent from HeroChat */
private static class HeroChatChannelEvent {
@SuppressWarnings("rawtypes")
private static Class channelevent;
private static Method getchannel;
private static Method iscancelled;
private static boolean isgood = false;
private Event evt;
@SuppressWarnings("unchecked")
public static boolean initialize() {
try {
channelevent = Class
.forName("com.herocraftonline.dthielke.herochat.event.ChannelEvent");
getchannel = channelevent.getMethod("getChannel", new Class[0]);
iscancelled = channelevent.getMethod("isCancelled", new Class[0]);
isgood = true;
} catch (ClassNotFoundException cnfx) {
} catch (NoSuchMethodException nsmx) {
}
return isgood;
}
public HeroChatChannelEvent(Event evt) {
this.evt = evt;
}
public static boolean isInstance(Event evt) {
return channelevent.isInstance(evt);
}
public HeroChatChannel getChannel() {
try {
Object o;
o = getchannel.invoke(evt);
if (o != null) {
return new HeroChatChannel(o);
}
} catch (Exception x) {
}
return null;
}
public boolean isCancelled() {
try {
return (Boolean) iscancelled.invoke(evt);
} catch (Exception x) {
return true;
}
}
}
/* Reflection-based access wrapper for Channel from HeroChat */
private static class HeroChatChannel {
@SuppressWarnings("rawtypes")
private static Class channel;
private static Method getname;
private static Method getnick;
private static Method sendmessage;
private static boolean isgood = false;
private Object chan;
@SuppressWarnings("unchecked")
public static boolean initialize() {
try {
channel = Class
.forName("com.herocraftonline.dthielke.herochat.channels.Channel");
getname = channel.getMethod("getName");
getnick = channel.getMethod("getNick", new Class[0]);
sendmessage = channel.getMethod("sendMessage", new Class[] {
String.class, String.class, String.class, boolean.class } );
isgood = true;
} catch (ClassNotFoundException cnfx) {
} catch (NoSuchMethodException nsmx) {
Log.severe(nsmx);
}
return isgood;
}
public HeroChatChannel(Object chan) {
this.chan = chan;
}
public String getName() {
try {
return (String) getname.invoke(chan);
} catch (Exception x) {
return null;
}
}
public String getNick() {
try {
return (String) getnick.invoke(chan);
} catch (Exception x) {
return null;
}
}
public void sendMessage(String source, String msg, String format, boolean sentByPlayer) {
try {
sendmessage.invoke(chan, source, msg, format, sentByPlayer);
} catch (Exception x) {
}
}
}
private class OurEventListener extends CustomEventListener {
/**
* Handle custom events
*/
@Override
public void onCustomEvent(Event event) {
if (HeroChatChannelEvent.isInstance(event)) {
HeroChatChannelEvent ce = new HeroChatChannelEvent(event);
/* Snoop for our web channel - we'll need it, and we'll see it before it matters,
* since anyone that joins the channel will give us an event (and reflection on
* the plugin class to get the manager didn't work, due to a dependency on the IRC
* plugin that may not be present....)
*/
HeroChatChannel c = ce.getChannel();
if (ce.isCancelled())
return;
if((hcwebinputchannel != null) && ((hcwebinputchannel.equals(c.getName())) ||
(hcwebinputchannel.equals(c.getNick())))) {
hcwebinputchan = c;
}
if (HeroChatChannelChatEvent.isInstance(event)) {
HeroChatChannelChatEvent cce = new HeroChatChannelChatEvent(
event);
/* Match on name or nickname of channel */
if (hcchannels.contains(c.getName()) ||
hcchannels.contains(c.getNick())) {
if(cce.isSentByPlayer()) { /* Player message? */
org.bukkit.entity.Player p = DynmapPlugin.plugin.getServer().getPlayer(cce.getSource());
if((p != null) && (core.mapManager != null)) {
core.mapManager.pushUpdate(new Client.ChatMessage("player",
c.getNick(),
p.getDisplayName(),
cce.getMessage(),
p.getName()));
}
}
}
}
}
}
}
public HeroChatHandler(ConfigurationNode cfg, DynmapCore core) {
/* If we're enabling hero chat support */
Log.verboseinfo("HeroChat support configured");
this.core = core;
/* Now, get the monitored channel list */
hcchannels = cfg.getStrings("herochatchannels", DEF_CHANNELS);
/* And get channel to send web messages */
hcwebinputchannel = cfg.getString("herochatwebchannel", DEF_CHANNEL);
Plugin hc = DynmapPlugin.plugin.getServer().getPluginManager().getPlugin("HeroChat");
if(hc != null) {
activateHeroChat(hc);
}
else {
/* Set up to hear when HeroChat is enabled */
DynmapPlugin.plugin.bep.registerEvent(Event.Type.PLUGIN_ENABLE, new OurPluginListener());
}
}
private void activateHeroChat(Plugin herochat) {
if (HeroChatChannelChatEvent.initialize() == false) {
Log.severe("Cannot load HeroChat chat event class!");
return;
}
if (HeroChatChannel.initialize() == false) {
Log.severe("Cannot load HeroChat channel class!");
return;
}
if (HeroChatChannelEvent.initialize() == false) {
Log.severe("Cannot load HeroChat channel event class!");
return;
}
/* Register event handler */
DynmapPlugin.plugin.bep.registerEvent(Event.Type.CUSTOM_EVENT, new OurEventListener());
Log.verboseinfo("HeroChat integration active");
}
/**
* Send message from web to appropriate HeroChat channel
* @param sender - sender ID
* @param message - message
* @return true if herochat is handling this, false if not
*/
public boolean sendWebMessageToHeroChat(String sender, String message) {
if(hcwebinputchannel != null) { /* Are we handling them? */
if(hcwebinputchan != null) { /* Have we seen it yet? Maybe no if nobody has logged on or
* joined it, but then who would see it anyway?
*/
hcwebinputchan.sendMessage(sender, message, "{default}", false);
}
return true;
}
return false;
}
}
@@ -1,68 +0,0 @@
package org.dynmap.herochat;
import static org.dynmap.JSONUtils.s;
import org.dynmap.ChatEvent;
import org.dynmap.Client;
import org.dynmap.Component;
import org.dynmap.ConfigurationNode;
import org.dynmap.DynmapCore;
import org.dynmap.Event;
import org.dynmap.common.DynmapListenerManager;
import org.dynmap.common.DynmapListenerManager.EventType;
import org.dynmap.common.DynmapPlayer;
import org.json.simple.JSONObject;
public class HeroWebChatComponent extends Component {
HeroChatHandler handler;
public HeroWebChatComponent(final DynmapCore plugin, ConfigurationNode configuration) {
super(plugin, configuration);
handler = new HeroChatHandler(configuration, plugin);
plugin.events.addListener("webchat", new Event.Listener<ChatEvent>() {
@Override
public void triggered(ChatEvent t) {
if(plugin.getServer().sendWebChatEvent(t.source, t.name, t.message)) {
/* Let HeroChat take a look - only broadcast to players if it doesn't handle it */
if (!handler.sendWebMessageToHeroChat(t.name, t.message)) {
String msg;
String msgfmt = plugin.configuration.getString("webmsgformat", null);
if(msgfmt != null) {
msgfmt = unescapeString(msgfmt);
msg = msgfmt.replace("%playername%", t.name).replace("%message%", t.message);
}
else {
msg = unescapeString(plugin.configuration.getString("webprefix", "\u00A72[WEB] ")) + t.name + ": " + unescapeString(plugin.configuration.getString("websuffix", "\u00A7f")) + t.message;
}
plugin.getServer().broadcastMessage(msg);
}
}
}
});
plugin.events.addListener("buildclientconfiguration", new Event.Listener<JSONObject>() {
@Override
public void triggered(JSONObject t) {
s(t, "allowchat", true);
}
});
// Also make HeroChat announce joins and quits.
core.listenerManager.addListener(EventType.PLAYER_JOIN, new DynmapListenerManager.PlayerEventListener() {
@Override
public void playerEvent(DynmapPlayer p) {
if((core.mapManager != null) && (core.playerList != null) && (core.playerList.isVisiblePlayer(p.getName()))) {
core.mapManager.pushUpdate(new Client.PlayerJoinMessage(p.getDisplayName(), p.getName()));
}
}
});
core.listenerManager.addListener(EventType.PLAYER_QUIT, new DynmapListenerManager.PlayerEventListener() {
@Override
public void playerEvent(DynmapPlayer p) {
if((core.mapManager != null) && (core.playerList != null) && (core.playerList.isVisiblePlayer(p.getName()))) {
core.mapManager.pushUpdate(new Client.PlayerQuitMessage(p.getDisplayName(), p.getName()));
}
}
});
}
}
+22 -26
View File
@@ -53,14 +53,6 @@ components:
allowchat: true
# If true, web UI users can supply name for chat using 'playername' URL parameter. 'trustclientname' must also be set true.
allowurlname: false
#- class: org.dynmap.herochat.HeroWebChatComponent
# # Control which HeroChat channel messages from web are directed to
# herochatwebchannel: Global
# # Control which channels are monitored and reported to the web
# herochatchannels:
# - Global
# #- Trade
# #- Haggle
# Note: this component is needed for the dmarker commands, and for the Marker API to be available to other plugins
- class: org.dynmap.MarkersComponent
@@ -71,12 +63,13 @@ components:
showspawn: true
spawnicon: world
spawnlabel: "Spawn"
# (optional) layer for showing offline player's positions
# (optional) layer for showing offline player's positions (for 'maxofflinetime' minutes after logoff)
showofflineplayers: false
offlinelabel: "Offline"
offlineicon: offlineuser
offlinehidebydefault: true
offlineminzoom: 0
maxofflinetime: 30
# (optional) layer for showing player's spawn beds
showspawnbeds: false
spawnbedlabel: "Spawn Beds"
@@ -97,6 +90,10 @@ components:
messagettl: 5
# Optional: set number of lines in scrollable message history: if set, messagettl is not used to age out messages
#scrollback: 100
# Optiona; set maximum number of lines visible for chatbox
#visiblelines: 10
# Optional: send push button
sendbutton: false
- class: org.dynmap.ClientComponent
type: playermarkers
showplayerfaces: true
@@ -172,29 +169,23 @@ zoomoutperiod: 30
# Tile hashing is used to minimize tile file updates when no changes have occurred - set to false to disable
enabletilehash: true
# Optional - control darkening of biome-shaded colors in swamp biomes (1.9+) - default is true for 1.9+, false for 1.8.x
#swampshaded: false
# Optional - control biome shading of water (1.9+) - default is true for 1.9+, false for 1.8.x
#waterbiomeshaded: false
# Optional - hide ores: render as normal stone (so that they aren't revealed by maps)
#hideores: true
# Optional - control rendering of fences (joining to blocks, as in 1.9+) - default is true for 1.9+, false for 1.8.x
#fence-to-block-join: true
# Optional - enabled BetterGrass style rendering of grass and snow block sides
#better-grass: true
# Pre 0.29 render options - set all three to false if you want same results as 0.28 (i.e. you have existing maps and don't want to render)
# use-generated-textures: if true, use generated textures (same as client); false is static, pre 0.29 textures
# correct-water-lighting: if true, use corrected water lighting (same as client); false is legacy, pre 0.29 water (darker)
# correct-biome-shading: if true, use fixed color mappings for birch, pine, lily, and proper water shading (same as client); false is pre 0.29
# Optional - enable smooth lighting by default on all maps supporting it (can be set per map as lighting option)
smooth-lighting: false
# Default image format for HDMaps (png, jpg, jpg-q75, jpg-q80, jpg-q85, jpg-q90, jpg-q95, jpg-q100)
# Has no effect on maps with explicit format settings
image-format: png
# 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)
use-generated-textures: true
correct-water-lighting: true
correct-biome-shading: true
# To enable smooth biome shading (as done in MC 1.1.0+), set this to true (this does increase render processing about 10%)
smooth-biome-shading: true
# Control loading of player faces (if set to false, skins are never fetched)
#fetchskins: false
@@ -202,8 +193,8 @@ smooth-biome-shading: true
# Control updating of player faces, once loaded (if faces are being managed by other apps or manually)
#refreshskins: false
# Control behavior for new (1.9+) compass orientation (sunrise moved 90 degrees: east is now what used to be south)
# default is 'pre19' for 1.8 server (existing orientation), 'newrose' for 1.9+ (preserve maps, rotate rose)
# Control behavior for new (1.0+) compass orientation (sunrise moved 90 degrees: east is now what used to be south)
# default is 'newrose' (preserve pre-1.0 maps, rotate rose)
# 'newnorth' is used to rotate maps and rose (requires fullrender of any HDMap map - same as 'newrose' for FlatMap or KzedMap)
compass-mode: newnorth
@@ -228,6 +219,9 @@ compass-mode: newnorth
# Enable Kaevator's Superslopes block rendering support
#superslopes-support: true
# Enabled ComputerCraft block rendering support
#computercraft-support: true
render-triggers:
#- playermove
#- playerjoin
@@ -243,6 +237,8 @@ render-triggers:
- explosion
- blockfromto
- blockphysics
- structuregrow
- blockgrow
# Title for the web page - if not specified, defaults to the server's name (unless it is the default of 'Unknown Server')
#webpage-title: "My Awesome Server Map"
+45 -1
View File
@@ -64,7 +64,7 @@ commands:
/<command> deleteicon id:<id> - remove icon
/<command> deleteicon <label> - remove icon
/<command> addcorner - add corner to corner list using current location
/<command> addcorner <x> <z> <world> - add corner with given x and z coordinate on given world to corner list
/<command> addcorner <x> <y> <z> <world> - add corner with given x, y and z coordinate on given world to corner list
/<command> clearcorners - clear corner list
/<command> addarea <label> - add new area with given label using corner list
/<command> addarea id:<id> <label> - add new area with given ID using corner list
@@ -73,6 +73,22 @@ commands:
/<command> listareas - list details of all areas
/<command> updatearea <label> <arg>:<value> ... - update attributes of area with given label
/<command> updatearea id:<id> <arg>:<value> ... - update attributes of area with given ID
/<command> addline <label> - add new poly-line with given label using corner list
/<command> addline id:<id> <label> - add new poly-line with given ID using corner list
/<command> deleteline <label> - delete poly-line with given label
/<command> deleteline id:<id> <label> - delete poly-line with given ID
/<command> listlines - list details of all poly-lines
/<command> updateline <label> <arg>:<value> ... - update attributes of poly-line with given label
/<command> updateline id:<id> <arg>:<value> ... - update attributes of poly-line with given ID
/<command> addcircle <label> radius:<rad> - add new circle centered at current location with given radius and label
/<command> addcircle id:<id> <label> radius:<rad> - add new circle centered at current location with given radius and ID
/<command> addcircle <label> radius:<rad> x:<x> y:<y> z:<z> world:<world> - add new circle centered at given coordinates with given radius and label
/<command> deletecircle <label> - delete circle with given label
/<command> deletecircle id:<id> <label> - delete circle with given ID
/<command> listcircles - list details of all circles
/<command> updatecircle <label> <arg>:<value> ... - update attributes of circle with given label
/<command> updatecircle id:<id> <arg>:<value> ... - update attributes of circle with given ID
dmap:
description: List and modify dynmap configuration
usage: |
@@ -126,6 +142,10 @@ permissions:
dynmap.marker.updatearea: true
dynmap.marker.listareas: true
dynmap.marker.deletearea: true
dynmap.marker.addcircle: true
dynmap.marker.updatecircle: true
dynmap.marker.listcircles: true
dynmap.marker.deletecircle: true
dynmap.dmap.worldlist: true
dynmap.dmap.worldset: true
dynmap.dmap.worldreset: true
@@ -240,6 +260,30 @@ permissions:
dynmap.marker.deletearea:
description: Allows /dmarker deletearea
default: op
dynmap.marker.addline:
description: Allows /dmarker addline
default: op
dynmap.marker.updateline:
description: Allows /dmarker updateline
default: op
dynmap.marker.listlines:
description: Allows /dmarker listlines
default: op
dynmap.marker.deleteline:
description: Allows /dmarker deleteline
default: op
dynmap.marker.addcircle:
description: Allows /dmarker addcircle
default: op
dynmap.marker.updatecircle:
description: Allows /dmarker updatecircle
default: op
dynmap.marker.listcircles:
description: Allows /dmarker listcircles
default: op
dynmap.marker.deletecircle:
description: Allows /dmarker deletecircle
default: op
dynmap.dmap.worldlist:
description: Allows /dmap worldlist
default: op