mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 11:15:21 +01:00
Checkpoint on split between bukkit-specific and common code core
This commit is contained in:
parent
9c49054c89
commit
b64094795e
@ -11,7 +11,7 @@ import org.json.simple.JSONObject;
|
||||
public class ClientComponent extends Component {
|
||||
private boolean disabled;
|
||||
|
||||
public ClientComponent(final DynmapPlugin plugin, final ConfigurationNode configuration) {
|
||||
public ClientComponent(final DynmapCore plugin, final ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
plugin.events.addListener("buildclientconfiguration", new Event.Listener<JSONObject>() {
|
||||
@Override
|
||||
|
@ -3,18 +3,17 @@ package org.dynmap;
|
||||
import static org.dynmap.JSONUtils.a;
|
||||
import static org.dynmap.JSONUtils.s;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.dynmap.Event.Listener;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class ClientConfigurationComponent extends Component {
|
||||
public ClientConfigurationComponent(final DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
plugin.events.<JSONObject>addListener("buildclientconfiguration", new Listener<JSONObject>() {
|
||||
public ClientConfigurationComponent(final DynmapCore core, ConfigurationNode configuration) {
|
||||
super(core, configuration);
|
||||
core.events.<JSONObject>addListener("buildclientconfiguration", new Listener<JSONObject>() {
|
||||
@Override
|
||||
public void triggered(JSONObject t) {
|
||||
ConfigurationNode c = plugin.configuration;
|
||||
s(t, "confighash", plugin.getConfigHashcode());
|
||||
ConfigurationNode c = core.configuration;
|
||||
s(t, "confighash", core.getConfigHashcode());
|
||||
s(t, "updaterate", c.getFloat("updaterate", 1.0f));
|
||||
s(t, "showplayerfacesinmenu", c.getBoolean("showplayerfacesinmenu", true));
|
||||
s(t, "joinmessage", c.getString("joinmessage", "%playername% joined"));
|
||||
@ -23,11 +22,11 @@ public class ClientConfigurationComponent extends Component {
|
||||
s(t, "webprefix", unescapeString(c.getString("webprefix", "[WEB] ")));
|
||||
s(t, "defaultzoom", c.getInteger("defaultzoom", 0));
|
||||
s(t, "sidebaropened", c.getString("sidebaropened", "false"));
|
||||
s(t, "dynmapversion", plugin.getDescription().getVersion());
|
||||
s(t, "dynmapversion", core.getDynmapCoreVersion());
|
||||
s(t, "cyrillic", c.getBoolean("cyrillic-support", false));
|
||||
s(t, "showlayercontrol", c.getString("showlayercontrol", "true"));
|
||||
s(t, "grayplayerswhenhidden", c.getBoolean("grayplayerswhenhidden", true));
|
||||
String sn = plugin.getServer().getServerName();
|
||||
String sn = core.getServer().getServerName();
|
||||
if(sn.equals("Unknown Server"))
|
||||
sn = "Minecraft Dynamic Map";
|
||||
s(t, "title", c.getString("webpage-title", sn));
|
||||
@ -36,7 +35,7 @@ public class ClientConfigurationComponent extends Component {
|
||||
|
||||
DynmapWorld defaultWorld = null;
|
||||
String defmap = null;
|
||||
for(DynmapWorld world : plugin.mapManager.getWorlds()) {
|
||||
for(DynmapWorld world : core.mapManager.getWorlds()) {
|
||||
if (defaultWorld == null) defaultWorld = world;
|
||||
ConfigurationNode wn = world.configuration;
|
||||
JSONObject wo = new JSONObject();
|
||||
|
@ -3,19 +3,14 @@ package org.dynmap;
|
||||
import static org.dynmap.JSONUtils.a;
|
||||
import static org.dynmap.JSONUtils.s;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.dynmap.utils.BlockLightLevel;
|
||||
import java.util.List;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class ClientUpdateComponent extends Component {
|
||||
private BlockLightLevel bll = new BlockLightLevel();
|
||||
|
||||
public ClientUpdateComponent(final DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||
public ClientUpdateComponent(final DynmapCore plugin, ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
plugin.events.addListener("buildclientupdate", new Event.Listener<ClientUpdateEvent>() {
|
||||
@Override
|
||||
@ -34,17 +29,19 @@ public class ClientUpdateComponent extends Component {
|
||||
int hideifunder = configuration.getInteger("hideifundercover", 15);
|
||||
boolean hideifsneaking = configuration.getBoolean("hideifsneaking", false);
|
||||
|
||||
s(u, "confighash", plugin.getConfigHashcode());
|
||||
s(u, "confighash", core.getConfigHashcode());
|
||||
|
||||
s(u, "servertime", world.getTime() % 24000);
|
||||
s(u, "hasStorm", world.hasStorm());
|
||||
s(u, "isThundering", world.isThundering());
|
||||
|
||||
s(u, "players", new JSONArray());
|
||||
Player[] players = plugin.playerList.getVisiblePlayers();
|
||||
for(int i=0;i<players.length;i++) {
|
||||
Player p = players[i];
|
||||
Location pl = p.getLocation();
|
||||
List<DynmapPlayer> players = core.playerList.getVisiblePlayers();
|
||||
for(DynmapPlayer p : players) {
|
||||
DynmapLocation pl = p.getLocation();
|
||||
DynmapWorld pw = core.getWorld(pl.world);
|
||||
if(pw == null)
|
||||
continue;
|
||||
JSONObject jp = new JSONObject();
|
||||
boolean hide = false;
|
||||
|
||||
@ -52,16 +49,16 @@ public class ClientUpdateComponent extends Component {
|
||||
s(jp, "name", Client.stripColor(p.getDisplayName()));
|
||||
s(jp, "account", p.getName());
|
||||
if(hideifshadow < 15) {
|
||||
if(pl.getBlock().getLightLevel() <= hideifshadow)
|
||||
if(pw.getLightLevel((int)pl.x, (int)pl.y, (int)pl.z) <= hideifshadow)
|
||||
hide = true;
|
||||
}
|
||||
if(hideifunder < 15) {
|
||||
if(bll.isReady()) { /* If we can get real sky level */
|
||||
if(bll.getSkyLightLevel(pl.getBlock()) <= hideifunder)
|
||||
if(pw.canGetSkyLightLevel()) { /* If we can get real sky level */
|
||||
if(pw.getSkyLightLevel((int)pl.x, (int)pl.y, (int)pl.z) <= hideifunder)
|
||||
hide = true;
|
||||
}
|
||||
else {
|
||||
if(pl.getWorld().getHighestBlockYAt(pl) > pl.getBlockY())
|
||||
if(pw.getHighestBlockYAt((int)pl.x, (int)pl.z) > pl.y)
|
||||
hide = true;
|
||||
}
|
||||
}
|
||||
@ -69,14 +66,14 @@ public class ClientUpdateComponent extends Component {
|
||||
hide = true;
|
||||
|
||||
/* Don't leak player location for world not visible on maps, or if sendposition disbaled */
|
||||
DynmapWorld pworld = MapManager.mapman.worldsLookup.get(p.getWorld().getName());
|
||||
DynmapWorld pworld = MapManager.mapman.worldsLookup.get(pl.world);
|
||||
/* Fix typo on 'sendpositon' to 'sendposition', keep bad one in case someone used it */
|
||||
if(configuration.getBoolean("sendposition", true) && configuration.getBoolean("sendpositon", true) &&
|
||||
(pworld != null) && pworld.sendposition && (!hide)) {
|
||||
s(jp, "world", p.getWorld().getName());
|
||||
s(jp, "x", pl.getX());
|
||||
s(jp, "y", pl.getY());
|
||||
s(jp, "z", pl.getZ());
|
||||
s(jp, "world", pl.world);
|
||||
s(jp, "x", pl.x);
|
||||
s(jp, "y", pl.y);
|
||||
s(jp, "z", pl.z);
|
||||
}
|
||||
else {
|
||||
s(jp, "world", "-some-other-bogus-world-");
|
||||
@ -87,7 +84,7 @@ public class ClientUpdateComponent extends Component {
|
||||
/* Only send health if enabled AND we're on visible world */
|
||||
if (configuration.getBoolean("sendhealth", false) && (pworld != null) && pworld.sendhealth && (!hide)) {
|
||||
s(jp, "health", p.getHealth());
|
||||
s(jp, "armor", Armor.getArmorPoints(p));
|
||||
s(jp, "armor", p.getArmorPoints());
|
||||
}
|
||||
else {
|
||||
s(jp, "health", 0);
|
||||
@ -96,8 +93,8 @@ public class ClientUpdateComponent extends Component {
|
||||
a(u, "players", jp);
|
||||
}
|
||||
if(configuration.getBoolean("includehiddenplayers", false)) {
|
||||
Set<Player> hidden = plugin.playerList.getHiddenPlayers();
|
||||
for(Player p : hidden) {
|
||||
List<DynmapPlayer> hidden = core.playerList.getHiddenPlayers();
|
||||
for(DynmapPlayer p : hidden) {
|
||||
JSONObject jp = new JSONObject();
|
||||
s(jp, "type", "player");
|
||||
s(jp, "name", Client.stripColor(p.getDisplayName()));
|
||||
@ -113,7 +110,7 @@ public class ClientUpdateComponent extends Component {
|
||||
}
|
||||
|
||||
s(u, "updates", new JSONArray());
|
||||
for(Object update : plugin.mapManager.getWorldUpdates(worldName, since)) {
|
||||
for(Object update : core.mapManager.getWorldUpdates(worldName, since)) {
|
||||
a(u, "updates", (Client.Update)update);
|
||||
}
|
||||
}
|
||||
|
@ -39,23 +39,23 @@ public class ColorScheme {
|
||||
}
|
||||
}
|
||||
|
||||
private static File getColorSchemeDirectory() {
|
||||
return new File(DynmapPlugin.dataDirectory, "colorschemes");
|
||||
private static File getColorSchemeDirectory(DynmapCore core) {
|
||||
return new File(core.getDataFolder(), "colorschemes");
|
||||
}
|
||||
|
||||
public static ColorScheme getScheme(String name) {
|
||||
public static ColorScheme getScheme(DynmapCore core, String name) {
|
||||
if (name == null)
|
||||
name = "default";
|
||||
ColorScheme scheme = cache.get(name);
|
||||
if (scheme == null) {
|
||||
scheme = loadScheme(name);
|
||||
scheme = loadScheme(core, name);
|
||||
cache.put(name, scheme);
|
||||
}
|
||||
return scheme;
|
||||
}
|
||||
|
||||
public static ColorScheme loadScheme(String name) {
|
||||
File colorSchemeFile = new File(getColorSchemeDirectory(), name + ".txt");
|
||||
public static ColorScheme loadScheme(DynmapCore core, String name) {
|
||||
File colorSchemeFile = new File(getColorSchemeDirectory(core), name + ".txt");
|
||||
Color[][] colors = new Color[256][];
|
||||
Color[][][] datacolors = new Color[256][][];
|
||||
Color[][] biomecolors = new Color[Biome.values().length][];
|
||||
|
@ -1,10 +1,10 @@
|
||||
package org.dynmap;
|
||||
|
||||
public abstract class Component {
|
||||
protected DynmapPlugin plugin;
|
||||
protected DynmapCore core;
|
||||
protected ConfigurationNode configuration;
|
||||
public Component(DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||
this.plugin = plugin;
|
||||
public Component(DynmapCore core, ConfigurationNode configuration) {
|
||||
this.core = core;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,9 +6,9 @@ import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class DynmapPlayerChatListener extends PlayerListener {
|
||||
DynmapPlugin plugin;
|
||||
DynmapCore plugin;
|
||||
|
||||
public DynmapPlayerChatListener(DynmapPlugin plugin) {
|
||||
public DynmapPlayerChatListener(DynmapCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,9 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.Location;
|
||||
import org.dynmap.bukkit.NewMapChunkCache;
|
||||
import org.dynmap.debug.Debug;
|
||||
import org.dynmap.utils.BlockLightLevel;
|
||||
import org.dynmap.utils.DynmapBufferedImage;
|
||||
import org.dynmap.utils.FileLockManager;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
@ -22,13 +24,13 @@ import java.util.HashSet;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class DynmapWorld {
|
||||
public abstract class DynmapWorld {
|
||||
|
||||
public enum AutoGenerateOption {
|
||||
NONE,
|
||||
FORMAPONLY,
|
||||
PERMANENT
|
||||
}
|
||||
private World world;
|
||||
public List<MapType> maps = new ArrayList<MapType>();
|
||||
public UpdateQueue updates = new UpdateQueue();
|
||||
public ConfigurationNode configuration;
|
||||
@ -50,9 +52,8 @@ public class DynmapWorld {
|
||||
private boolean cancelled;
|
||||
private String wname;
|
||||
|
||||
public DynmapWorld(World w) {
|
||||
world = w;
|
||||
wname = w.getName();
|
||||
protected DynmapWorld(String wname) {
|
||||
this.wname = wname;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setExtraZoomOutLevels(int lvl) {
|
||||
@ -170,7 +171,7 @@ public class DynmapWorld {
|
||||
|
||||
public boolean freshenZoomOutFilesByLevel(int zoomlevel) {
|
||||
int cnt = 0;
|
||||
Debug.debug("freshenZoomOutFiles(" + world.getName() + "," + zoomlevel + ")");
|
||||
Debug.debug("freshenZoomOutFiles(" + wname + "," + zoomlevel + ")");
|
||||
if(worldtilepath.exists() == false) /* Quit if not found */
|
||||
return true;
|
||||
HashMap<String, PrefixData> maptab = buildPrefixData(zoomlevel);
|
||||
@ -195,7 +196,7 @@ public class DynmapWorld {
|
||||
cnt += processZoomDirectory(worldtilepath, maptab.get(pfx));
|
||||
}
|
||||
}
|
||||
Debug.debug("freshenZoomOutFiles(" + world.getName() + "," + zoomlevel + ") - done (" + cnt + " updated files)");
|
||||
Debug.debug("freshenZoomOutFiles(" + wname + "," + zoomlevel + ") - done (" + cnt + " updated files)");
|
||||
}
|
||||
else { /* Else, only process updates */
|
||||
String[] paths = peekQueuedUpdates(zoomlevel); /* Get pending updates */
|
||||
@ -461,7 +462,7 @@ public class DynmapWorld {
|
||||
long crc = hashman.calculateTileHash(kzIm.argb_buf); /* Get hash of tile */
|
||||
int tilex = ztx/step/2;
|
||||
int tiley = zty/step/2;
|
||||
String key = world.getName()+".z"+pd.zoomprefix+pd.baseprefix;
|
||||
String key = wname+".z"+pd.zoomprefix+pd.baseprefix;
|
||||
if(blank) {
|
||||
if(zf.exists()) {
|
||||
zf.delete();
|
||||
@ -490,43 +491,41 @@ public class DynmapWorld {
|
||||
DynmapBufferedImage.freeBufferedImage(kzIm);
|
||||
}
|
||||
}
|
||||
/* Test if world is nether */
|
||||
public boolean isNether() {
|
||||
return world.getEnvironment() == World.Environment.NETHER;
|
||||
}
|
||||
/* Get world name */
|
||||
public String getName() {
|
||||
return wname;
|
||||
}
|
||||
/* Test if world is nether */
|
||||
public abstract boolean isNether();
|
||||
/* Get world spawn location */
|
||||
public DynmapLocation getSpawnLocation() {
|
||||
DynmapLocation dloc = new DynmapLocation();
|
||||
Location sloc = world.getSpawnLocation();
|
||||
dloc.x = sloc.getBlockX(); dloc.y = sloc.getBlockY();
|
||||
dloc.z = sloc.getBlockZ(); dloc.world = sloc.getWorld().getName();
|
||||
return dloc;
|
||||
}
|
||||
public abstract DynmapLocation getSpawnLocation();
|
||||
|
||||
public int hashCode() {
|
||||
return wname.hashCode();
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return world.getTime();
|
||||
}
|
||||
/* Get world time */
|
||||
public abstract long getTime();
|
||||
/* World is storming */
|
||||
public abstract boolean hasStorm();
|
||||
/* World is thundering */
|
||||
public abstract boolean isThundering();
|
||||
/* World is loaded */
|
||||
public abstract boolean isLoaded();
|
||||
/* Get light level of block */
|
||||
public abstract int getLightLevel(int x, int y, int z);
|
||||
/* Get highest Y coord of given location */
|
||||
public abstract int getHighestBlockYAt(int x, int z);
|
||||
/* Test if sky light level is requestable */
|
||||
public abstract boolean canGetSkyLightLevel();
|
||||
/* Return sky light level */
|
||||
public abstract int getSkyLightLevel(int x, int y, int z);
|
||||
/**
|
||||
* Get world environment ID (lower case - normal, the_end, nether)
|
||||
*/
|
||||
public abstract String getEnvironment();
|
||||
/**
|
||||
* Get map chunk cache for world
|
||||
*/
|
||||
public abstract MapChunkCache getChunkCache(List<DynmapChunk> chunks);
|
||||
|
||||
public boolean hasStorm() {
|
||||
return world.hasStorm();
|
||||
}
|
||||
|
||||
public boolean isThundering() {
|
||||
return world.isThundering();
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
public boolean isLoaded() {
|
||||
return (world != null);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import static org.dynmap.JSONUtils.*;
|
||||
|
||||
public class InternalClientUpdateComponent extends ClientUpdateComponent {
|
||||
|
||||
public InternalClientUpdateComponent(final DynmapPlugin plugin, final ConfigurationNode configuration) {
|
||||
public InternalClientUpdateComponent(final DynmapCore plugin, final ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
plugin.addServlet("/up/world/*", new ClientUpdateServlet(plugin));
|
||||
|
||||
@ -43,12 +43,12 @@ public class InternalClientUpdateComponent extends ClientUpdateComponent {
|
||||
}
|
||||
|
||||
protected void webChat(String name, String message) {
|
||||
if(plugin.mapManager == null)
|
||||
if(core.mapManager == null)
|
||||
return;
|
||||
// TODO: Change null to something meaningful.
|
||||
plugin.mapManager.pushUpdate(new Client.ChatMessage("web", null, name, message, null));
|
||||
Log.info(unescapeString(plugin.configuration.getString("webprefix", "\u00A72[WEB] ")) + name + ": " + unescapeString(plugin.configuration.getString("websuffix", "\u00A7f")) + message);
|
||||
core.mapManager.pushUpdate(new Client.ChatMessage("web", null, name, message, null));
|
||||
Log.info(unescapeString(core.configuration.getString("webprefix", "\u00A72[WEB] ")) + name + ": " + unescapeString(core.configuration.getString("websuffix", "\u00A7f")) + message);
|
||||
ChatEvent event = new ChatEvent("web", name, message);
|
||||
plugin.events.trigger("webchat", event);
|
||||
core.events.trigger("webchat", event);
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.web.Json;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
@ -36,7 +34,7 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
|
||||
private long last_confighash;
|
||||
|
||||
private Charset cs_utf8 = Charset.forName("UTF-8");
|
||||
public JsonFileClientUpdateComponent(final DynmapPlugin plugin, final ConfigurationNode configuration) {
|
||||
public JsonFileClientUpdateComponent(final DynmapCore plugin, final ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
final boolean allowwebchat = configuration.getBoolean("allowwebchat", false);
|
||||
jsonInterval = (long)(configuration.getFloat("writeinterval", 1) * 1000);
|
||||
@ -85,11 +83,11 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
|
||||
}
|
||||
|
||||
protected File getStandaloneFile(String filename) {
|
||||
File webpath = new File(plugin.configuration.getString("webpath", "web"), "standalone/" + filename);
|
||||
File webpath = new File(core.configuration.getString("webpath", "web"), "standalone/" + filename);
|
||||
if (webpath.isAbsolute())
|
||||
return webpath;
|
||||
else
|
||||
return new File(plugin.getDataFolder(), webpath.toString());
|
||||
return new File(core.getDataFolder(), webpath.toString());
|
||||
}
|
||||
|
||||
private static final int RETRY_LIMIT = 5;
|
||||
@ -97,10 +95,10 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
|
||||
File outputFile;
|
||||
File outputTempFile;
|
||||
JSONObject clientConfiguration = new JSONObject();
|
||||
plugin.events.trigger("buildclientconfiguration", clientConfiguration);
|
||||
core.events.trigger("buildclientconfiguration", clientConfiguration);
|
||||
outputFile = getStandaloneFile("dynmap_config.json");
|
||||
outputTempFile = getStandaloneFile("dynmap_config.json.new");
|
||||
last_confighash = plugin.getConfigHashcode();
|
||||
last_confighash = core.getConfigHashcode();
|
||||
|
||||
int retrycnt = 0;
|
||||
boolean done = false;
|
||||
@ -139,13 +137,13 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
|
||||
protected void writeUpdates() {
|
||||
File outputFile;
|
||||
File outputTempFile;
|
||||
if(plugin.mapManager == null) return;
|
||||
if(core.mapManager == null) return;
|
||||
//Handles Updates
|
||||
for (DynmapWorld dynmapWorld : plugin.mapManager.getWorlds()) {
|
||||
for (DynmapWorld dynmapWorld : core.mapManager.getWorlds()) {
|
||||
JSONObject update = new JSONObject();
|
||||
update.put("timestamp", currentTimestamp);
|
||||
ClientUpdateEvent clientUpdate = new ClientUpdateEvent(currentTimestamp - 30000, dynmapWorld, update);
|
||||
plugin.events.trigger("buildclientupdate", clientUpdate);
|
||||
core.events.trigger("buildclientupdate", clientUpdate);
|
||||
|
||||
outputFile = getStandaloneFile("dynmap_" + dynmapWorld.getName() + ".json");
|
||||
outputTempFile = getStandaloneFile("dynmap_" + dynmapWorld.getName() + ".json.new");
|
||||
@ -180,10 +178,10 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.events.<ClientUpdateEvent>trigger("clientupdatewritten", clientUpdate);
|
||||
core.events.<ClientUpdateEvent>trigger("clientupdatewritten", clientUpdate);
|
||||
}
|
||||
|
||||
plugin.events.<Object>trigger("clientupdateswritten", null);
|
||||
core.events.<Object>trigger("clientupdateswritten", null);
|
||||
}
|
||||
|
||||
protected void handleWebChat() {
|
||||
@ -224,13 +222,12 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
|
||||
name = ip;
|
||||
}
|
||||
if(useplayerloginip) { /* Try to match using IPs of player logins */
|
||||
List<String> ids = plugin.getIDsForIP(name);
|
||||
List<String> ids = core.getIDsForIP(name);
|
||||
if(ids != null) {
|
||||
name = ids.get(0);
|
||||
isip = false;
|
||||
if(checkuserban) {
|
||||
OfflinePlayer p = plugin.getServer().getOfflinePlayer(name);
|
||||
if((p != null) && p.isBanned()) {
|
||||
if(core.getServer().isPlayerBanned(name)) {
|
||||
Log.info("Ignore message from '" + ip + "' - banned player (" + name + ")");
|
||||
return;
|
||||
}
|
||||
@ -259,12 +256,12 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
|
||||
}
|
||||
|
||||
protected void webChat(String name, String message) {
|
||||
if(plugin.mapManager == null) return;
|
||||
if(core.mapManager == null) return;
|
||||
// TODO: Change null to something meaningful.
|
||||
plugin.mapManager.pushUpdate(new Client.ChatMessage("web", null, name, message, null));
|
||||
Log.info(unescapeString(plugin.configuration.getString("webprefix", "\u00A2[WEB] ")) + name + ": " + unescapeString(plugin.configuration.getString("websuffix", "\u00A7f")) + message);
|
||||
core.mapManager.pushUpdate(new Client.ChatMessage("web", null, name, message, null));
|
||||
Log.info(unescapeString(core.configuration.getString("webprefix", "\u00A2[WEB] ")) + name + ": " + unescapeString(core.configuration.getString("websuffix", "\u00A7f")) + message);
|
||||
ChatEvent event = new ChatEvent("web", name, message);
|
||||
plugin.events.trigger("webchat", event);
|
||||
core.events.trigger("webchat", event);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,16 +22,13 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.dynmap.DynmapPlugin.CompassMode;
|
||||
import org.dynmap.DynmapCore.CompassMode;
|
||||
import org.dynmap.DynmapWorld.AutoGenerateOption;
|
||||
import org.dynmap.common.DynmapCommandSender;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.debug.Debug;
|
||||
import org.dynmap.hdmap.HDMapManager;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.NewMapChunkCache;
|
||||
import org.dynmap.utils.SnapshotCache;
|
||||
import org.dynmap.utils.TileFlags;
|
||||
|
||||
@ -42,8 +39,7 @@ public class MapManager {
|
||||
private static final int DEFAULT_ZOOMOUT_PERIOD = 60;
|
||||
public List<DynmapWorld> worlds = new ArrayList<DynmapWorld>();
|
||||
public Map<String, DynmapWorld> worldsLookup = new HashMap<String, DynmapWorld>();
|
||||
private BukkitScheduler scheduler;
|
||||
private DynmapPlugin plug_in;
|
||||
private DynmapCore core;
|
||||
private long timeslice_int = 0; /* In milliseconds */
|
||||
private int max_chunk_loads_per_tick = DEFAULT_CHUNKS_PER_TICK;
|
||||
private int parallelrendercnt = 0;
|
||||
@ -221,7 +217,7 @@ public class MapManager {
|
||||
LinkedList<MapTile> renderQueue = null;
|
||||
MapTile tile0 = null;
|
||||
int rendercnt = 0;
|
||||
CommandSender sender;
|
||||
DynmapCommandSender sender;
|
||||
String player;
|
||||
long timeaccum;
|
||||
HashSet<MapType> renderedmaps = new HashSet<MapType>();
|
||||
@ -237,7 +233,7 @@ public class MapManager {
|
||||
AtomicInteger rendercalls = new AtomicInteger(0);
|
||||
|
||||
/* Full world, all maps render */
|
||||
FullWorldRenderState(DynmapWorld dworld, DynmapLocation l, CommandSender sender, String mapname, boolean updaterender) {
|
||||
FullWorldRenderState(DynmapWorld dworld, DynmapLocation l, DynmapCommandSender sender, String mapname, boolean updaterender) {
|
||||
this(dworld, l, sender, mapname, -1);
|
||||
if(updaterender) {
|
||||
rendertype = RENDERTYPE_UPDATERENDER;
|
||||
@ -248,15 +244,15 @@ public class MapManager {
|
||||
}
|
||||
|
||||
/* Full world, all maps render, with optional render radius */
|
||||
FullWorldRenderState(DynmapWorld dworld, DynmapLocation l, CommandSender sender, String mapname, int radius) {
|
||||
FullWorldRenderState(DynmapWorld dworld, DynmapLocation l, DynmapCommandSender sender, String mapname, int radius) {
|
||||
world = dworld;
|
||||
loc = l;
|
||||
found = new TileFlags();
|
||||
rendered = new TileFlags();
|
||||
renderQueue = new LinkedList<MapTile>();
|
||||
this.sender = sender;
|
||||
if(sender instanceof Player)
|
||||
this.player = ((Player)sender).getName();
|
||||
if(sender instanceof DynmapPlayer)
|
||||
this.player = ((DynmapPlayer)sender).getName();
|
||||
else
|
||||
this.player = "";
|
||||
if(radius < 0) {
|
||||
@ -343,7 +339,7 @@ public class MapManager {
|
||||
updaterender = rendertype.equals(RENDERTYPE_UPDATERENDER);
|
||||
sender = null;
|
||||
if(player.length() > 0) {
|
||||
sender = plug_in.getServer().getPlayerExact(player);
|
||||
sender = core.getServer().getPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -681,7 +677,7 @@ public class MapManager {
|
||||
|
||||
private class CheckWorldTimes implements Runnable {
|
||||
public void run() {
|
||||
Future<Integer> f = scheduler.callSyncMethod(plug_in, new Callable<Integer>() {
|
||||
Future<Integer> f = core.getServer().callSyncMethod(new Callable<Integer>() {
|
||||
public Integer call() throws Exception {
|
||||
for(DynmapWorld w : worlds) {
|
||||
int new_servertime = (int)(w.getTime() % 24000);
|
||||
@ -724,8 +720,8 @@ public class MapManager {
|
||||
}
|
||||
}
|
||||
|
||||
public MapManager(DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||
plug_in = plugin;
|
||||
public MapManager(DynmapCore core, ConfigurationNode configuration) {
|
||||
this.core = core;
|
||||
mapman = this;
|
||||
|
||||
/* Get block hiding data, if any */
|
||||
@ -739,9 +735,9 @@ public class MapManager {
|
||||
|
||||
/* Initialize HD map manager */
|
||||
hdmapman = new HDMapManager();
|
||||
hdmapman.loadHDShaders(plugin);
|
||||
hdmapman.loadHDPerspectives(plugin);
|
||||
hdmapman.loadHDLightings(plugin);
|
||||
hdmapman.loadHDShaders(core);
|
||||
hdmapman.loadHDPerspectives(core);
|
||||
hdmapman.loadHDLightings(core);
|
||||
sscache = new SnapshotCache(configuration.getInteger("snapshotcachesize", 500));
|
||||
parallelrendercnt = configuration.getInteger("parallelrendercnt", 0);
|
||||
progressinterval = configuration.getInteger("progressloginterval", 100);
|
||||
@ -771,18 +767,12 @@ public class MapManager {
|
||||
zoomout_period = configuration.getInteger("zoomoutperiod", DEFAULT_ZOOMOUT_PERIOD);
|
||||
if(zoomout_period < 5) zoomout_period = 5;
|
||||
|
||||
scheduler = plugin.getServer().getScheduler();
|
||||
|
||||
hashman = new TileHashManager(DynmapPlugin.tilesDirectory, configuration.getBoolean("enabletilehash", true));
|
||||
hashman = new TileHashManager(core.getTilesFolder(), configuration.getBoolean("enabletilehash", true));
|
||||
|
||||
tileQueue.start();
|
||||
|
||||
for (World world : plug_in.getServer().getWorlds()) {
|
||||
activateWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
void renderFullWorld(DynmapLocation l, CommandSender sender, String mapname, boolean update) {
|
||||
void renderFullWorld(DynmapLocation l, DynmapCommandSender sender, String mapname, boolean update) {
|
||||
DynmapWorld world = getWorld(l.world);
|
||||
if (world == null) {
|
||||
sender.sendMessage("Could not render: world '" + l.world + "' not defined in configuration.");
|
||||
@ -808,7 +798,7 @@ public class MapManager {
|
||||
sender.sendMessage("Full render starting on world '" + wname + "'...");
|
||||
}
|
||||
|
||||
void renderWorldRadius(DynmapLocation l, CommandSender sender, String mapname, int radius) {
|
||||
void renderWorldRadius(DynmapLocation l, DynmapCommandSender sender, String mapname, int radius) {
|
||||
DynmapWorld world = getWorld(l.world);
|
||||
if (world == null) {
|
||||
sender.sendMessage("Could not render: world '" + l.world + "' not defined in configuration.");
|
||||
@ -830,15 +820,15 @@ public class MapManager {
|
||||
sender.sendMessage("Render of " + radius + " block radius starting on world '" + wname + "'...");
|
||||
}
|
||||
|
||||
void cancelRender(World w, CommandSender sender) {
|
||||
void cancelRender(String w, DynmapCommandSender sender) {
|
||||
synchronized(lock) {
|
||||
if(w != null) {
|
||||
FullWorldRenderState rndr;
|
||||
rndr = active_renders.get(w.getName());
|
||||
rndr = active_renders.get(w);
|
||||
if(rndr != null) {
|
||||
rndr.cancelRender(); /* Cancel render */
|
||||
if(sender != null) {
|
||||
sender.sendMessage("Cancelled render for '" + w.getName() + "'");
|
||||
sender.sendMessage("Cancelled render for '" + w + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -854,7 +844,7 @@ public class MapManager {
|
||||
}
|
||||
}
|
||||
|
||||
void purgeQueue(CommandSender sender) {
|
||||
void purgeQueue(DynmapCommandSender sender) {
|
||||
if(tileQueue != null) {
|
||||
int cnt = 0;
|
||||
List<MapTile> popped = tileQueue.popAll();
|
||||
@ -866,18 +856,17 @@ public class MapManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void activateWorld(World w) {
|
||||
ConfigurationNode worldConfiguration = plug_in.getWorldConfiguration(w);
|
||||
public boolean activateWorld(DynmapWorld dynmapWorld) {
|
||||
ConfigurationNode worldConfiguration = core.getWorldConfiguration(dynmapWorld);
|
||||
if (!worldConfiguration.getBoolean("enabled", false)) {
|
||||
Log.info("World '" + w.getName() + "' disabled");
|
||||
return;
|
||||
Log.info("World '" + dynmapWorld.getName() + "' disabled");
|
||||
return false;
|
||||
}
|
||||
String worldName = w.getName();
|
||||
String worldName = dynmapWorld.getName();
|
||||
|
||||
DynmapWorld dynmapWorld = new DynmapWorld(w);
|
||||
dynmapWorld.configuration = worldConfiguration;
|
||||
Log.verboseinfo("Loading maps of world '" + worldName + "'...");
|
||||
for(MapType map : worldConfiguration.<MapType>createInstances("maps", new Class<?>[0], new Object[0])) {
|
||||
for(MapType map : worldConfiguration.<MapType>createInstances("maps", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||
if(map.getName() != null)
|
||||
dynmapWorld.maps.add(map);
|
||||
}
|
||||
@ -885,15 +874,15 @@ public class MapManager {
|
||||
|
||||
List<ConfigurationNode> loclist = worldConfiguration.getNodes("fullrenderlocations");
|
||||
dynmapWorld.seedloc = new ArrayList<DynmapLocation>();
|
||||
dynmapWorld.servertime = (int)(w.getTime() % 24000);
|
||||
dynmapWorld.servertime = (int)(dynmapWorld.getTime() % 24000);
|
||||
dynmapWorld.sendposition = worldConfiguration.getBoolean("sendposition", true);
|
||||
dynmapWorld.sendhealth = worldConfiguration.getBoolean("sendhealth", true);
|
||||
dynmapWorld.bigworld = worldConfiguration.getBoolean("bigworld", false);
|
||||
dynmapWorld.setExtraZoomOutLevels(worldConfiguration.getInteger("extrazoomout", 0));
|
||||
dynmapWorld.worldtilepath = new File(DynmapPlugin.tilesDirectory, w.getName());
|
||||
dynmapWorld.worldtilepath = new File(core.getTilesFolder(), worldName);
|
||||
if(loclist != null) {
|
||||
for(ConfigurationNode loc : loclist) {
|
||||
DynmapLocation lx = new DynmapLocation(w.getName(), loc.getInteger("x", 0), loc.getInteger("y", 64), loc.getInteger("z", 0));
|
||||
DynmapLocation lx = new DynmapLocation(worldName, loc.getInteger("x", 0), loc.getInteger("y", 64), loc.getInteger("z", 0));
|
||||
dynmapWorld.seedloc.add(lx);
|
||||
}
|
||||
}
|
||||
@ -909,7 +898,7 @@ public class MapManager {
|
||||
lim.z1 = vis.getInteger("z1", 0);
|
||||
dynmapWorld.visibility_limits.add(lim);
|
||||
/* Also, add a seed location for the middle of each visible area */
|
||||
dynmapWorld.seedloc.add(new DynmapLocation(w.getName(), (lim.x0+lim.x1)/2, 64, (lim.z0+lim.z1)/2));
|
||||
dynmapWorld.seedloc.add(new DynmapLocation(worldName, (lim.x0+lim.x1)/2, 64, (lim.z0+lim.z1)/2));
|
||||
}
|
||||
}
|
||||
/* Load hidden limits, if any are defined */
|
||||
@ -951,7 +940,7 @@ public class MapManager {
|
||||
// TODO: Make this less... weird...
|
||||
// Insert the world on the same spot as in the configuration.
|
||||
HashMap<String, Integer> indexLookup = new HashMap<String, Integer>();
|
||||
List<ConfigurationNode> nodes = plug_in.configuration.getNodes("worlds");
|
||||
List<ConfigurationNode> nodes = core.configuration.getNodes("worlds");
|
||||
for (int i = 0; i < nodes.size(); i++) {
|
||||
ConfigurationNode node = nodes.get(i);
|
||||
indexLookup.put(node.getString("name"), i);
|
||||
@ -970,11 +959,12 @@ public class MapManager {
|
||||
}
|
||||
worlds.add(insertIndex, dynmapWorld);
|
||||
}
|
||||
worldsLookup.put(w.getName(), dynmapWorld);
|
||||
plug_in.events.trigger("worldactivated", dynmapWorld);
|
||||
worldsLookup.put(worldName, dynmapWorld);
|
||||
core.events.trigger("worldactivated", dynmapWorld);
|
||||
/* Now, restore any pending renders for this world */
|
||||
if(saverestorepending)
|
||||
loadPending(dynmapWorld);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void deactivateWorld(String wname) {
|
||||
@ -983,7 +973,7 @@ public class MapManager {
|
||||
|
||||
private void loadPending(DynmapWorld w) {
|
||||
String wname = w.getName();
|
||||
File f = new File(plug_in.getDataFolder(), wname + ".pending");
|
||||
File f = new File(core.getDataFolder(), wname + ".pending");
|
||||
if(f.exists()) {
|
||||
org.bukkit.util.config.Configuration saved = new org.bukkit.util.config.Configuration(f);
|
||||
saved.load();
|
||||
@ -1021,7 +1011,7 @@ public class MapManager {
|
||||
List<MapTile> mt = tileQueue.popAll();
|
||||
for(DynmapWorld w : worlds) {
|
||||
boolean dosave = false;
|
||||
File f = new File(plug_in.getDataFolder(), w.getName() + ".pending");
|
||||
File f = new File(core.getDataFolder(), w.getName() + ".pending");
|
||||
org.bukkit.util.config.Configuration saved = new org.bukkit.util.config.Configuration(f);
|
||||
ArrayList<ConfigurationNode> savedtiles = new ArrayList<ConfigurationNode>();
|
||||
for(MapTile tile : mt) {
|
||||
@ -1159,9 +1149,9 @@ public class MapManager {
|
||||
/**
|
||||
* Render processor helper - used by code running on render threads to request chunk snapshot cache from server/sync thread
|
||||
*/
|
||||
public MapChunkCache createMapChunkCache(DynmapWorld w, List<DynmapChunk> chunks,
|
||||
public MapChunkCache createMapChunkCache(DynmapWorld w, List<DynmapChunk> chunks,
|
||||
boolean blockdata, boolean highesty, boolean biome, boolean rawbiome) {
|
||||
MapChunkCache c = new NewMapChunkCache();
|
||||
MapChunkCache c = w.getChunkCache(chunks);
|
||||
if(w.visibility_limits != null) {
|
||||
for(MapChunkCache.VisibilityLimit limit: w.visibility_limits) {
|
||||
c.setVisibleRange(limit);
|
||||
@ -1175,8 +1165,6 @@ public class MapManager {
|
||||
}
|
||||
c.setHiddenFillStyle(w.hiddenchunkstyle);
|
||||
}
|
||||
|
||||
c.setChunks(w.getWorld(), chunks);
|
||||
if(c.setChunkDataTypes(blockdata, biome, highesty, rawbiome) == false)
|
||||
Log.severe("CraftBukkit build does not support biome APIs");
|
||||
if(chunks.size() == 0) { /* No chunks to get? */
|
||||
@ -1194,7 +1182,7 @@ public class MapManager {
|
||||
cur_tick = now/50;
|
||||
}
|
||||
}
|
||||
Future<Boolean> f = scheduler.callSyncMethod(plug_in, new Callable<Boolean>() {
|
||||
Future<Boolean> f = core.getServer().callSyncMethod(new Callable<Boolean>() {
|
||||
public Boolean call() throws Exception {
|
||||
boolean exhausted;
|
||||
synchronized(loadlock) {
|
||||
@ -1240,7 +1228,7 @@ public class MapManager {
|
||||
/**
|
||||
* Print statistics command
|
||||
*/
|
||||
public void printStats(CommandSender sender, String prefix) {
|
||||
public void printStats(DynmapCommandSender sender, String prefix) {
|
||||
sender.sendMessage("Tile Render Statistics:");
|
||||
MapStats tot = new MapStats();
|
||||
synchronized(lock) {
|
||||
@ -1283,7 +1271,7 @@ public class MapManager {
|
||||
/**
|
||||
* Print trigger statistics command
|
||||
*/
|
||||
public void printTriggerStats(CommandSender sender) {
|
||||
public void printTriggerStats(DynmapCommandSender sender) {
|
||||
sender.sendMessage("Render Trigger Statistics:");
|
||||
synchronized(lock) {
|
||||
for(String k: new TreeSet<String>(trigstats.keySet())) {
|
||||
@ -1296,7 +1284,7 @@ public class MapManager {
|
||||
/**
|
||||
* Reset statistics
|
||||
*/
|
||||
public void resetStats(CommandSender sender, String prefix) {
|
||||
public void resetStats(DynmapCommandSender sender, String prefix) {
|
||||
synchronized(lock) {
|
||||
for(String k : mapstats.keySet()) {
|
||||
if((prefix != null) && !k.startsWith(prefix))
|
||||
@ -1327,23 +1315,23 @@ public class MapManager {
|
||||
}
|
||||
|
||||
public boolean getSwampShading() {
|
||||
return plug_in.swampshading;
|
||||
return core.swampshading;
|
||||
}
|
||||
|
||||
public boolean getWaterBiomeShading() {
|
||||
return plug_in.waterbiomeshading;
|
||||
return core.waterbiomeshading;
|
||||
}
|
||||
|
||||
public boolean getFenceJoin() {
|
||||
return plug_in.fencejoin;
|
||||
return core.fencejoin;
|
||||
}
|
||||
|
||||
public boolean getBetterGrass() {
|
||||
return plug_in.bettergrass;
|
||||
return core.bettergrass;
|
||||
}
|
||||
|
||||
public CompassMode getCompassMode() {
|
||||
return plug_in.compassmode;
|
||||
return core.compassmode;
|
||||
}
|
||||
|
||||
public boolean getHideOres() {
|
||||
@ -1400,7 +1388,7 @@ public class MapManager {
|
||||
ticklistcalls.incrementAndGet();
|
||||
}
|
||||
/* Connect any jobs tied to this player back to the player (resumes output to player) */
|
||||
void connectTasksToPlayer(Player p) {
|
||||
void connectTasksToPlayer(DynmapPlayer p) {
|
||||
String pn = p.getName();
|
||||
for(FullWorldRenderState job : active_renders.values()) {
|
||||
if(pn.equals(job.player)) {
|
||||
|
@ -1,17 +1,10 @@
|
||||
package org.dynmap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.world.SpawnChangeEvent;
|
||||
import org.bukkit.event.world.WorldListener;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.dynmap.common.DynmapListenerManager;
|
||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
import org.dynmap.common.DynmapListenerManager.WorldEventListener;
|
||||
import org.dynmap.common.DynmapListenerManager.PlayerEventListener;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.markers.Marker;
|
||||
import org.dynmap.markers.MarkerIcon;
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
@ -30,23 +23,23 @@ public class MarkersComponent extends ClientComponent {
|
||||
private MarkerIcon offlineicon;
|
||||
private MarkerSet spawnbedset;
|
||||
private MarkerIcon spawnbedicon;
|
||||
|
||||
private String spawnbedformat;
|
||||
private static final String OFFLINE_PLAYERS_SETID = "offline_players";
|
||||
private static final String PLAYER_SPAWN_BED_SETID = "spawn_beds";
|
||||
|
||||
public MarkersComponent(final DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
public MarkersComponent(final DynmapCore core, ConfigurationNode configuration) {
|
||||
super(core, configuration);
|
||||
/* Register API with plugin, if needed */
|
||||
if(plugin.markerAPIInitialized()) {
|
||||
api = (MarkerAPIImpl)plugin.getMarkerAPI();
|
||||
if(core.markerAPIInitialized()) {
|
||||
api = (MarkerAPIImpl)core.getMarkerAPI();
|
||||
}
|
||||
else {
|
||||
api = MarkerAPIImpl.initializeMarkerAPI(plugin);
|
||||
plugin.registerMarkerAPI(api);
|
||||
api = MarkerAPIImpl.initializeMarkerAPI(core);
|
||||
core.registerMarkerAPI(api);
|
||||
}
|
||||
/* If configuration has enabled sign support, prime it too */
|
||||
if(configuration.getBoolean("enablesigns", false)) {
|
||||
signmgr = MarkerSignManager.initializeSignManager(plugin);
|
||||
signmgr = MarkerSignManager.initializeSignManager(core);
|
||||
}
|
||||
/* If we're posting spawn point markers, initialize and add world listener */
|
||||
if(configuration.getBoolean("showspawn", false)) {
|
||||
@ -56,27 +49,24 @@ public class MarkersComponent extends ClientComponent {
|
||||
if(spawnicon == null) {
|
||||
spawnicon = api.getMarkerIcon(MarkerIcon.WORLD);
|
||||
}
|
||||
WorldListener wl = new WorldListener() {
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
World w = event.getWorld(); /* Get the world */
|
||||
Location loc = w.getSpawnLocation(); /* Get location of spawn */
|
||||
/* Add listener for world loads */
|
||||
WorldEventListener wel = new WorldEventListener() {
|
||||
@Override
|
||||
public void worldEvent(DynmapWorld w) {
|
||||
DynmapLocation loc = w.getSpawnLocation(); /* Get location of spawn */
|
||||
if(loc != null)
|
||||
addUpdateWorld(w, new DynmapLocation(w.getName(), loc.getX(), loc.getY(), loc.getZ()));
|
||||
}
|
||||
public void onSpawnChange(SpawnChangeEvent event) {
|
||||
World w = event.getWorld(); /* Get the world */
|
||||
Location loc = w.getSpawnLocation(); /* Get location of spawn */
|
||||
if(loc != null)
|
||||
addUpdateWorld(w, new DynmapLocation(w.getName(), loc.getX(), loc.getY(), loc.getZ()));
|
||||
addUpdateWorld(w, loc);
|
||||
}
|
||||
};
|
||||
plugin.registerEvent(org.bukkit.event.Event.Type.WORLD_LOAD, wl);
|
||||
plugin.registerEvent(org.bukkit.event.Event.Type.SPAWN_CHANGE, wl);
|
||||
core.listenerManager.addListener(EventType.WORLD_LOAD, wel);
|
||||
/* Add listener for spawn changes */
|
||||
core.listenerManager.addListener(EventType.WORLD_SPAWN_CHANGE, wel);
|
||||
|
||||
/* Initialize already loaded worlds */
|
||||
for(DynmapWorld w : plugin.getMapManager().getWorlds()) {
|
||||
for(DynmapWorld w : core.getMapManager().getWorlds()) {
|
||||
DynmapLocation loc = w.getSpawnLocation();
|
||||
if(loc != null)
|
||||
addUpdateWorld(w.getWorld(), loc);
|
||||
addUpdateWorld(w, loc);
|
||||
}
|
||||
}
|
||||
/* If showing offline players as markers */
|
||||
@ -92,32 +82,30 @@ public class MarkersComponent extends ClientComponent {
|
||||
offlineicon = api.getMarkerIcon(configuration.getString("offlineicon", "offlineuser"));
|
||||
|
||||
/* Add listener for players coming and going */
|
||||
PlayerListener pl = new PlayerListener() {
|
||||
core.listenerManager.addListener(EventType.PLAYER_JOIN, new PlayerEventListener() {
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
public void playerEvent(DynmapPlayer p) {
|
||||
Marker m = offlineset.findMarker(p.getName());
|
||||
if(m != null) {
|
||||
m.deleteMarker();
|
||||
}
|
||||
}
|
||||
});
|
||||
core.listenerManager.addListener(EventType.PLAYER_QUIT, new PlayerEventListener() {
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
Marker m = offlineset.findMarker(p.getName());
|
||||
public void playerEvent(DynmapPlayer p) {
|
||||
String pname = p.getName();
|
||||
Marker m = offlineset.findMarker(pname);
|
||||
if(m != null) {
|
||||
m.deleteMarker();
|
||||
}
|
||||
if(plugin.playerList.isVisiblePlayer(p)) {
|
||||
Location loc = p.getLocation();
|
||||
m = offlineset.createMarker(p.getName(), ChatColor.stripColor(p.getDisplayName()), false,
|
||||
loc.getWorld().getName(), loc.getX(), loc.getY(), loc.getZ(),
|
||||
offlineicon, true);
|
||||
if(core.playerList.isVisiblePlayer(pname)) {
|
||||
DynmapLocation loc = p.getLocation();
|
||||
m = offlineset.createMarker(p.getName(), core.getServer().stripChatColor(p.getDisplayName()), false,
|
||||
loc.world, loc.x, loc.y, loc.z, offlineicon, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
plugin.registerEvent(Type.PLAYER_JOIN, pl);
|
||||
plugin.registerEvent(Type.PLAYER_QUIT, pl);
|
||||
});
|
||||
}
|
||||
else {
|
||||
/* Make set, if needed */
|
||||
@ -137,53 +125,34 @@ public class MarkersComponent extends ClientComponent {
|
||||
spawnbedset.setMinZoom(configuration.getInteger("spawnbedminzoom", 0));
|
||||
|
||||
spawnbedicon = api.getMarkerIcon(configuration.getString("spawnbedicon", "bed"));
|
||||
final String spawnbedformat = configuration.getString("spawnbedformat", "%name%'s bed");
|
||||
spawnbedformat = configuration.getString("spawnbedformat", "%name%'s bed");
|
||||
|
||||
/* Add listener for players coming and going */
|
||||
PlayerListener pl = new PlayerListener() {
|
||||
private void updatePlayer(Player p) {
|
||||
Location bl = p.getBedSpawnLocation();
|
||||
Marker m = spawnbedset.findMarker(p.getName()+"_bed");
|
||||
if(bl == null) { /* No bed location */
|
||||
if(m != null) {
|
||||
m.deleteMarker();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(m != null)
|
||||
m.setLocation(bl.getWorld().getName(), bl.getX(), bl.getY(), bl.getZ());
|
||||
else
|
||||
m = spawnbedset.createMarker(p.getName()+"_bed", spawnbedformat.replace("%name%", ChatColor.stripColor(p.getDisplayName())), false,
|
||||
bl.getWorld().getName(), bl.getX(), bl.getY(), bl.getZ(),
|
||||
spawnbedicon, true);
|
||||
}
|
||||
}
|
||||
core.listenerManager.addListener(EventType.PLAYER_JOIN, new PlayerEventListener() {
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
public void playerEvent(DynmapPlayer p) {
|
||||
updatePlayer(p);
|
||||
}
|
||||
});
|
||||
core.listenerManager.addListener(EventType.PLAYER_QUIT, new PlayerEventListener() {
|
||||
@Override
|
||||
public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
|
||||
final Player p = event.getPlayer();
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
updatePlayer(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
public void playerEvent(DynmapPlayer p) {
|
||||
Marker m = spawnbedset.findMarker(p.getName()+"_bed");
|
||||
if(m != null) {
|
||||
m.deleteMarker();
|
||||
}
|
||||
}
|
||||
};
|
||||
plugin.registerEvent(Type.PLAYER_JOIN, pl);
|
||||
plugin.registerEvent(Type.PLAYER_QUIT, pl);
|
||||
plugin.registerEvent(Type.PLAYER_BED_LEAVE, pl);
|
||||
});
|
||||
core.listenerManager.addListener(EventType.PLAYER_BED_LEAVE, new PlayerEventListener() {
|
||||
@Override
|
||||
public void playerEvent(final DynmapPlayer p) {
|
||||
core.getServer().scheduleServerTask(new Runnable() {
|
||||
public void run() {
|
||||
updatePlayer(p);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
/* Make set, if needed */
|
||||
@ -194,7 +163,26 @@ public class MarkersComponent extends ClientComponent {
|
||||
}
|
||||
}
|
||||
|
||||
private void addUpdateWorld(World w, DynmapLocation loc) {
|
||||
private void updatePlayer(DynmapPlayer p) {
|
||||
DynmapLocation bl = p.getBedSpawnLocation();
|
||||
Marker m = spawnbedset.findMarker(p.getName()+"_bed");
|
||||
if(bl == null) { /* No bed location */
|
||||
if(m != null) {
|
||||
m.deleteMarker();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(m != null)
|
||||
m.setLocation(bl.world, bl.x, bl.y, bl.z);
|
||||
else
|
||||
m = spawnbedset.createMarker(p.getName()+"_bed", spawnbedformat.replace("%name%", core.getServer().stripChatColor(p.getDisplayName())), false,
|
||||
bl.world, bl.x, bl.y, bl.z,
|
||||
spawnbedicon, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addUpdateWorld(DynmapWorld w, DynmapLocation loc) {
|
||||
MarkerSet ms = api.getMarkerSet(MarkerSet.DEFAULT);
|
||||
if(ms != null) {
|
||||
String spawnid = "_spawn_" + w.getName();
|
||||
@ -212,7 +200,7 @@ public class MarkersComponent extends ClientComponent {
|
||||
@Override
|
||||
public void dispose() {
|
||||
if(signmgr != null) {
|
||||
MarkerSignManager.terminateSignManager(this.plugin);
|
||||
MarkerSignManager.terminateSignManager(this.core);
|
||||
signmgr = null;
|
||||
}
|
||||
/* Don't unregister API - other plugins might be using it, and we want to keep non-persistent markers */
|
||||
|
@ -8,10 +8,10 @@ import java.net.URL;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.dynmap.MapType.ImageFormat;
|
||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
import org.dynmap.common.DynmapListenerManager.PlayerEventListener;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.debug.Debug;
|
||||
import org.dynmap.utils.DynmapBufferedImage;
|
||||
import org.dynmap.utils.FileLockManager;
|
||||
@ -133,22 +133,22 @@ public class PlayerFaces {
|
||||
/* TODO: signal update for player icon to client */
|
||||
}
|
||||
}
|
||||
private class LoginListener extends PlayerListener {
|
||||
@Override
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
Runnable job = new LoadPlayerImages(event.getPlayer().getName());
|
||||
if(fetchskins)
|
||||
MapManager.scheduleDelayedJob(job, 0);
|
||||
else
|
||||
job.run();
|
||||
}
|
||||
}
|
||||
public PlayerFaces(DynmapPlugin plugin) {
|
||||
fetchskins = plugin.configuration.getBoolean("fetchskins", true); /* Control whether to fetch skins */
|
||||
refreshskins = plugin.configuration.getBoolean("refreshskins", true); /* Control whether to update existing fetched skins or faces */
|
||||
public PlayerFaces(DynmapCore core) {
|
||||
fetchskins = core.configuration.getBoolean("fetchskins", true); /* Control whether to fetch skins */
|
||||
refreshskins = core.configuration.getBoolean("refreshskins", true); /* Control whether to update existing fetched skins or faces */
|
||||
|
||||
plugin.registerEvent(Type.PLAYER_LOGIN, new LoginListener());
|
||||
facesdir = new File(DynmapPlugin.tilesDirectory, "faces");
|
||||
core.listenerManager.addListener(EventType.PLAYER_JOIN, new PlayerEventListener() {
|
||||
@Override
|
||||
public void playerEvent(DynmapPlayer p) {
|
||||
Runnable job = new LoadPlayerImages(p.getName());
|
||||
if(fetchskins)
|
||||
MapManager.scheduleDelayedJob(job, 0);
|
||||
else
|
||||
job.run();
|
||||
}
|
||||
});
|
||||
facesdir = new File(core.getTilesFolder(), "faces");
|
||||
|
||||
facesdir.mkdirs(); /* Make sure directory exists */
|
||||
faces8x8dir = new File(facesdir, "8x8");
|
||||
faces8x8dir.mkdirs();
|
||||
|
@ -8,20 +8,20 @@ import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.common.DynmapServerInterface;
|
||||
|
||||
public class PlayerList {
|
||||
private Server server;
|
||||
private DynmapServerInterface server;
|
||||
private HashSet<String> hiddenPlayerNames = new HashSet<String>();
|
||||
private File hiddenPlayersFile;
|
||||
private ConfigurationNode configuration;
|
||||
private Player[] online;
|
||||
private DynmapPlayer[] online;
|
||||
|
||||
public PlayerList(Server server, File hiddenPlayersFile, ConfigurationNode configuration) {
|
||||
public PlayerList(DynmapServerInterface server, File hiddenPlayersFile, ConfigurationNode configuration) {
|
||||
this.server = server;
|
||||
this.hiddenPlayersFile = hiddenPlayersFile;
|
||||
this.configuration = configuration;
|
||||
@ -74,45 +74,32 @@ public class PlayerList {
|
||||
hide(playerName);
|
||||
}
|
||||
|
||||
// TODO: Clean this up... one day
|
||||
public Player[] getVisiblePlayers(String worldName) {
|
||||
ArrayList<Player> visiblePlayers = new ArrayList<Player>();
|
||||
Player[] onlinePlayers = online; /* Use copied list - we don't call from server thread */
|
||||
public List<DynmapPlayer> getVisiblePlayers(String worldName) {
|
||||
ArrayList<DynmapPlayer> visiblePlayers = new ArrayList<DynmapPlayer>();
|
||||
DynmapPlayer[] onlinePlayers = online; /* Use copied list - we don't call from server thread */
|
||||
boolean useWhitelist = configuration.getBoolean("display-whitelist", false);
|
||||
for (int i = 0; i < onlinePlayers.length; i++) {
|
||||
Player p = onlinePlayers[i];
|
||||
if(p == null) continue;
|
||||
if (p.getWorld().getName().equals(worldName) && !(useWhitelist ^ hiddenPlayerNames.contains(p.getName().toLowerCase()))) {
|
||||
visiblePlayers.add(p);
|
||||
}
|
||||
}
|
||||
Player[] result = new Player[visiblePlayers.size()];
|
||||
visiblePlayers.toArray(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Player[] getVisiblePlayers() {
|
||||
ArrayList<Player> visiblePlayers = new ArrayList<Player>();
|
||||
Player[] onlinePlayers = online; /* Use copied list - we don't call from server thread */
|
||||
boolean useWhitelist = configuration.getBoolean("display-whitelist", false);
|
||||
for (int i = 0; i < onlinePlayers.length; i++) {
|
||||
Player p = onlinePlayers[i];
|
||||
DynmapPlayer p = onlinePlayers[i];
|
||||
if(p == null) continue;
|
||||
if((worldName != null) && (p.getWorld().equals(worldName) == false)) continue;
|
||||
|
||||
if (!(useWhitelist ^ hiddenPlayerNames.contains(p.getName().toLowerCase()))) {
|
||||
visiblePlayers.add(p);
|
||||
}
|
||||
}
|
||||
Player[] result = new Player[visiblePlayers.size()];
|
||||
visiblePlayers.toArray(result);
|
||||
return result;
|
||||
return visiblePlayers;
|
||||
}
|
||||
|
||||
public List<DynmapPlayer> getVisiblePlayers() {
|
||||
return getVisiblePlayers(null);
|
||||
}
|
||||
|
||||
public Set<Player> getHiddenPlayers() {
|
||||
HashSet<Player> hidden = new HashSet<Player>();
|
||||
Player[] onlinePlayers = online; /* Use copied list - we don't call from server thread */
|
||||
public List<DynmapPlayer> getHiddenPlayers() {
|
||||
ArrayList<DynmapPlayer> hidden = new ArrayList<DynmapPlayer>();
|
||||
DynmapPlayer[] onlinePlayers = online; /* Use copied list - we don't call from server thread */
|
||||
boolean useWhitelist = configuration.getBoolean("display-whitelist", false);
|
||||
for (int i = 0; i < onlinePlayers.length; i++) {
|
||||
Player p = onlinePlayers[i];
|
||||
DynmapPlayer p = onlinePlayers[i];
|
||||
if(p == null) continue;
|
||||
if (useWhitelist ^ hiddenPlayerNames.contains(p.getName().toLowerCase())) {
|
||||
hidden.add(p);
|
||||
@ -120,10 +107,6 @@ public class PlayerList {
|
||||
}
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public boolean isVisiblePlayer(Player p) {
|
||||
return isVisiblePlayer(p.getName());
|
||||
}
|
||||
|
||||
public boolean isVisiblePlayer(String p) {
|
||||
boolean useWhitelist = configuration.getBoolean("display-whitelist", false);
|
||||
@ -133,13 +116,13 @@ public class PlayerList {
|
||||
/**
|
||||
* Call this from server thread to update player list safely
|
||||
*/
|
||||
void updateOnlinePlayers(Player skipone) {
|
||||
Player[] players = server.getOnlinePlayers();
|
||||
Player[] pl = new Player[players.length];
|
||||
void updateOnlinePlayers(String skipone) {
|
||||
DynmapPlayer[] players = server.getOnlinePlayers();
|
||||
DynmapPlayer[] pl = new DynmapPlayer[players.length];
|
||||
System.arraycopy(players, 0, pl, 0, pl.length);
|
||||
if(skipone != null) {
|
||||
for(int i = 0; i < pl.length; i++)
|
||||
if(pl[i] == skipone)
|
||||
if(pl[i].getName().equals(skipone))
|
||||
pl[i] = null;
|
||||
}
|
||||
online = pl;
|
||||
|
@ -6,18 +6,20 @@ import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.dynmap.common.DynmapListenerManager;
|
||||
import org.dynmap.common.DynmapListenerManager.ChatEventListener;
|
||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class SimpleWebChatComponent extends Component {
|
||||
|
||||
public SimpleWebChatComponent(final DynmapPlugin plugin, final ConfigurationNode configuration) {
|
||||
public SimpleWebChatComponent(final DynmapCore plugin, final ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
plugin.events.addListener("webchat", new Event.Listener<ChatEvent>() {
|
||||
@Override
|
||||
public void triggered(ChatEvent t) {
|
||||
DynmapWebChatEvent evt = new DynmapWebChatEvent(t.source, t.name, t.message);
|
||||
plugin.getServer().getPluginManager().callEvent(evt);
|
||||
if(evt.isCancelled() == false) {
|
||||
if(plugin.getServer().sendWebChatEvent(t.source, t.name, t.message)) {
|
||||
String msg;
|
||||
String msgfmt = plugin.configuration.getString("webmsgformat", null);
|
||||
if(msgfmt != null) {
|
||||
@ -40,35 +42,29 @@ public class SimpleWebChatComponent extends Component {
|
||||
});
|
||||
|
||||
if (configuration.getBoolean("allowchat", false)) {
|
||||
PlayerChatListener playerListener = new PlayerChatListener();
|
||||
plugin.registerEvent(org.bukkit.event.Event.Type.PLAYER_CHAT, playerListener);
|
||||
plugin.registerEvent(org.bukkit.event.Event.Type.PLAYER_LOGIN, playerListener);
|
||||
plugin.registerEvent(org.bukkit.event.Event.Type.PLAYER_JOIN, playerListener);
|
||||
plugin.registerEvent(org.bukkit.event.Event.Type.PLAYER_QUIT, playerListener);
|
||||
plugin.listenerManager.addListener(EventType.PLAYER_CHAT, new ChatEventListener() {
|
||||
@Override
|
||||
public void chatEvent(DynmapPlayer p, String msg) {
|
||||
if(core.mapManager != null)
|
||||
core.mapManager.pushUpdate(new Client.ChatMessage("player", "", p.getDisplayName(), msg, p.getName()));
|
||||
}
|
||||
});
|
||||
plugin.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()));
|
||||
}
|
||||
}
|
||||
});
|
||||
plugin.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()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected class PlayerChatListener extends PlayerListener {
|
||||
@Override
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
if(plugin.mapManager != null)
|
||||
plugin.mapManager.pushUpdate(new Client.ChatMessage("player", "", event.getPlayer().getDisplayName(), event.getMessage(), event.getPlayer().getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if((plugin.mapManager != null) && (plugin.playerList != null) && (plugin.playerList.isVisiblePlayer(event.getPlayer()))) {
|
||||
plugin.mapManager.pushUpdate(new Client.PlayerJoinMessage(event.getPlayer().getDisplayName(), event.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if((plugin.mapManager != null) && (plugin.playerList != null) && (plugin.playerList.isVisiblePlayer(event.getPlayer()))) {
|
||||
plugin.mapManager.pushUpdate(new Client.PlayerQuitMessage(event.getPlayer().getDisplayName(), event.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package org.dynmap;
|
||||
|
||||
public class TestComponent extends Component {
|
||||
|
||||
public TestComponent(DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||
public TestComponent(DynmapCore plugin, ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
Log.info("Hello! I'm a component that does stuff! Like saying what is in my configuration: " + configuration.getString("stuff"));
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.dynmap;
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
416
src/main/java/org/dynmap/bukkit/BukkitEventProcessor.java
Normal file
416
src/main/java/org/dynmap/bukkit/BukkitEventProcessor.java
Normal file
@ -0,0 +1,416 @@
|
||||
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.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 */
|
||||
}
|
||||
pm = null;
|
||||
plugin = null;
|
||||
}
|
||||
|
||||
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) {
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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;
|
||||
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);
|
||||
}
|
||||
}
|
94
src/main/java/org/dynmap/bukkit/BukkitWorld.java
Normal file
94
src/main/java/org/dynmap/bukkit/BukkitWorld.java
Normal file
@ -0,0 +1,94 @@
|
||||
package org.dynmap.bukkit;
|
||||
/**
|
||||
* Bukkit specific implementation of DynmapWorld
|
||||
*/
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.utils.BlockLightLevel;
|
||||
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());
|
||||
|
||||
world = w;
|
||||
}
|
||||
/* Test if world is nether */
|
||||
@Override
|
||||
public boolean isNether() {
|
||||
return world.getEnvironment() == World.Environment.NETHER;
|
||||
}
|
||||
/* Get world spawn location */
|
||||
@Override
|
||||
public DynmapLocation getSpawnLocation() {
|
||||
DynmapLocation dloc = new DynmapLocation();
|
||||
Location sloc = world.getSpawnLocation();
|
||||
dloc.x = sloc.getBlockX(); dloc.y = sloc.getBlockY();
|
||||
dloc.z = sloc.getBlockZ(); dloc.world = sloc.getWorld().getName();
|
||||
return dloc;
|
||||
}
|
||||
/* Get world time */
|
||||
@Override
|
||||
public long getTime() {
|
||||
return world.getTime();
|
||||
}
|
||||
/* World is storming */
|
||||
@Override
|
||||
public boolean hasStorm() {
|
||||
return world.hasStorm();
|
||||
}
|
||||
/* World is thundering */
|
||||
@Override
|
||||
public boolean isThundering() {
|
||||
return world.isThundering();
|
||||
}
|
||||
/* 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) {
|
||||
return world.getBlockAt(x, y, z).getLightLevel();
|
||||
}
|
||||
/* Get highest Y coord of given location */
|
||||
@Override
|
||||
public int getHighestBlockYAt(int x, int z) {
|
||||
return world.getHighestBlockYAt(x, z);
|
||||
}
|
||||
/* Test if sky light level is requestable */
|
||||
@Override
|
||||
public boolean canGetSkyLightLevel() {
|
||||
return bll.isReady();
|
||||
}
|
||||
/* Return sky light level */
|
||||
@Override
|
||||
public int getSkyLightLevel(int x, int y, int z) {
|
||||
return bll.getSkyLightLevel(world.getBlockAt(x, y, z));
|
||||
}
|
||||
/**
|
||||
* Get world environment ID (lower case - normal, the_end, nether)
|
||||
*/
|
||||
@Override
|
||||
public String getEnvironment() {
|
||||
return world.getEnvironment().name().toLowerCase();
|
||||
}
|
||||
/**
|
||||
* Get map chunk cache for world
|
||||
*/
|
||||
@Override
|
||||
public MapChunkCache getChunkCache(List<DynmapChunk> chunks) {
|
||||
MapChunkCache c = new NewMapChunkCache();
|
||||
c.setChunks(world, chunks);
|
||||
return c;
|
||||
}
|
||||
}
|
846
src/main/java/org/dynmap/bukkit/DynmapPlugin.java
Normal file
846
src/main/java/org/dynmap/bukkit/DynmapPlugin.java
Normal file
@ -0,0 +1,846 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Type;
|
||||
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.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
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.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.DynmapWebChatEvent;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.common.DynmapCommandSender;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.common.DynmapServerInterface;
|
||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
import org.dynmap.markers.MarkerAPI;
|
||||
import org.dynmap.permissions.BukkitPermissions;
|
||||
import org.dynmap.permissions.NijikokunPermissions;
|
||||
import org.dynmap.permissions.OpPermissions;
|
||||
import org.dynmap.permissions.PermissionProvider;
|
||||
|
||||
public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
private DynmapCore core;
|
||||
private PermissionProvider permissions;
|
||||
private String version;
|
||||
public BukkitEventProcessor bep;
|
||||
|
||||
private MapManager mapManager;
|
||||
public static DynmapPlugin plugin;
|
||||
|
||||
public DynmapPlugin() {
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Server access abstraction class
|
||||
*/
|
||||
public class BukkitServer implements DynmapServerInterface {
|
||||
@Override
|
||||
public void scheduleServerTask(Runnable run, long delay) {
|
||||
getServer().getScheduler().scheduleSyncDelayedTask(DynmapPlugin.this, run, delay);
|
||||
}
|
||||
@Override
|
||||
public DynmapPlayer[] getOnlinePlayers() {
|
||||
Player[] players = getServer().getOnlinePlayers();
|
||||
DynmapPlayer[] dplay = new DynmapPlayer[players.length];
|
||||
for(int i = 0; i < players.length; i++)
|
||||
dplay[i] = new BukkitPlayer(players[i]);
|
||||
return dplay;
|
||||
}
|
||||
@Override
|
||||
public void reload() {
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
pluginManager.disablePlugin(DynmapPlugin.this);
|
||||
pluginManager.enablePlugin(DynmapPlugin.this);
|
||||
}
|
||||
@Override
|
||||
public DynmapPlayer getPlayer(String name) {
|
||||
Player p = getServer().getPlayerExact(name);
|
||||
if(p != null) {
|
||||
return new BukkitPlayer(p);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Set<String> getIPBans() {
|
||||
return getServer().getIPBans();
|
||||
}
|
||||
@Override
|
||||
public <T> Future<T> callSyncMethod(Callable<T> task) {
|
||||
return getServer().getScheduler().callSyncMethod(DynmapPlugin.this, task);
|
||||
}
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return getServer().getServerName();
|
||||
}
|
||||
@Override
|
||||
public boolean isPlayerBanned(String pid) {
|
||||
OfflinePlayer p = getServer().getOfflinePlayer(pid);
|
||||
if((p != null) && p.isBanned())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public String stripChatColor(String s) {
|
||||
return ChatColor.stripColor(s);
|
||||
}
|
||||
private Set<EventType> registered = new HashSet<EventType>();
|
||||
@Override
|
||||
public boolean requestEventNotification(EventType type) {
|
||||
if(registered.contains(type))
|
||||
return true;
|
||||
switch(type) {
|
||||
case WORLD_LOAD:
|
||||
case WORLD_UNLOAD:
|
||||
/* Already called for normal world activation/deactivation */
|
||||
break;
|
||||
case WORLD_SPAWN_CHANGE:
|
||||
bep.registerEvent(Type.SPAWN_CHANGE, new WorldListener() {
|
||||
public void onWorldSpawnChange(SpawnChangeEvent evt) {
|
||||
DynmapWorld w = new BukkitWorld(evt.getWorld());
|
||||
core.listenerManager.processWorldEvent(EventType.WORLD_SPAWN_CHANGE, w);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case PLAYER_JOIN:
|
||||
case PLAYER_QUIT:
|
||||
/* Already handled */
|
||||
break;
|
||||
case PLAYER_BED_LEAVE:
|
||||
bep.registerEvent(Type.PLAYER_BED_LEAVE, new PlayerListener() {
|
||||
@Override
|
||||
public void onPlayerBedLeave(PlayerBedLeaveEvent evt) {
|
||||
DynmapPlayer p = new BukkitPlayer(evt.getPlayer());
|
||||
core.listenerManager.processPlayerEvent(EventType.PLAYER_BED_LEAVE, p);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case PLAYER_CHAT:
|
||||
bep.registerEvent(Type.PLAYER_CHAT, new PlayerListener() {
|
||||
@Override
|
||||
public void onPlayerChat(PlayerChatEvent evt) {
|
||||
DynmapPlayer p = null;
|
||||
if(evt.getPlayer() != null)
|
||||
p = new BukkitPlayer(evt.getPlayer());
|
||||
core.listenerManager.processChatEvent(EventType.PLAYER_CHAT, p, evt.getMessage());
|
||||
}
|
||||
});
|
||||
break;
|
||||
case BLOCK_BREAK:
|
||||
bep.registerEvent(Type.BLOCK_BREAK, new BlockListener() {
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent evt) {
|
||||
Block b = evt.getBlock();
|
||||
Location l = b.getLocation();
|
||||
core.listenerManager.processBlockEvent(EventType.BLOCK_BREAK, b.getType().getId(),
|
||||
l.getWorld().getName(), l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
}
|
||||
});
|
||||
break;
|
||||
case SIGN_CHANGE:
|
||||
bep.registerEvent(Type.SIGN_CHANGE, new BlockListener() {
|
||||
@Override
|
||||
public void onSignChange(SignChangeEvent evt) {
|
||||
Block b = evt.getBlock();
|
||||
Location l = b.getLocation();
|
||||
String[] lines = evt.getLines(); /* Note: changes to this change event - intentional */
|
||||
DynmapPlayer dp = null;
|
||||
Player p = evt.getPlayer();
|
||||
if(p != null) dp = new BukkitPlayer(p);
|
||||
core.listenerManager.processSignChangeEvent(EventType.SIGN_CHANGE, b.getType().getId(),
|
||||
l.getWorld().getName(), l.getBlockX(), l.getBlockY(), l.getBlockZ(), lines, dp);
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
Log.severe("Unhandled event type: " + type);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean sendWebChatEvent(String source, String name, String msg) {
|
||||
DynmapWebChatEvent evt = new DynmapWebChatEvent(source, name, msg);
|
||||
getServer().getPluginManager().callEvent(evt);
|
||||
return (evt.isCancelled() == false);
|
||||
}
|
||||
@Override
|
||||
public void broadcastMessage(String msg) {
|
||||
getServer().broadcastMessage(msg);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Player access abstraction class
|
||||
*/
|
||||
public class BukkitPlayer extends BukkitCommandSender implements DynmapPlayer {
|
||||
private Player player;
|
||||
|
||||
public BukkitPlayer(Player p) {
|
||||
super(p);
|
||||
player = p;
|
||||
}
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return player.isOnline();
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return player.getName();
|
||||
}
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return player.getDisplayName();
|
||||
}
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return player.isOnline();
|
||||
}
|
||||
@Override
|
||||
public DynmapLocation getLocation() {
|
||||
Location loc = player.getLocation();
|
||||
return toLoc(loc);
|
||||
}
|
||||
@Override
|
||||
public String getWorld() {
|
||||
World w = player.getWorld();
|
||||
if(w != null)
|
||||
return w.getName();
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public InetSocketAddress getAddress() {
|
||||
return player.getAddress();
|
||||
}
|
||||
@Override
|
||||
public boolean isSneaking() {
|
||||
return player.isSneaking();
|
||||
}
|
||||
@Override
|
||||
public int getHealth() {
|
||||
return player.getHealth();
|
||||
}
|
||||
@Override
|
||||
public int getArmorPoints() {
|
||||
return Armor.getArmorPoints(player);
|
||||
}
|
||||
@Override
|
||||
public DynmapLocation getBedSpawnLocation() {
|
||||
Location loc = player.getBedSpawnLocation();
|
||||
if(loc != null) {
|
||||
return toLoc(loc);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/* Handler for generic console command sender */
|
||||
public class BukkitCommandSender implements DynmapCommandSender {
|
||||
private CommandSender sender;
|
||||
|
||||
public BukkitCommandSender(CommandSender send) {
|
||||
sender = send;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPrivilege(String privid) {
|
||||
return permissions.has(sender, privid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String msg) {
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return sender.isOp();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
version = pdfFile.getVersion();
|
||||
|
||||
/* Initialize event processor */
|
||||
if(bep == null)
|
||||
bep = new BukkitEventProcessor(this);
|
||||
|
||||
/* Set up player login/quit event handler */
|
||||
registerPlayerLoginListener();
|
||||
|
||||
permissions = NijikokunPermissions.create(getServer(), "dynmap");
|
||||
if (permissions == null)
|
||||
permissions = BukkitPermissions.create("dynmap");
|
||||
if (permissions == null)
|
||||
permissions = new OpPermissions(new String[] { "fullrender", "cancelrender", "radiusrender", "resetstats", "reload", "purgequeue", "pause", "ips-for-id", "ids-for-ip", "add-id-for-ip", "del-id-for-ip" });
|
||||
/* Get and initialize data folder */
|
||||
File dataDirectory = this.getDataFolder();
|
||||
if(dataDirectory.exists() == false)
|
||||
dataDirectory.mkdirs();
|
||||
/* Get MC version */
|
||||
String bukkitver = getServer().getVersion();
|
||||
String mcver = "1.0.0";
|
||||
int idx = bukkitver.indexOf("(MC: ");
|
||||
if(idx > 0) {
|
||||
mcver = bukkitver.substring(idx+5);
|
||||
idx = mcver.indexOf(")");
|
||||
if(idx > 0) mcver = mcver.substring(0, idx);
|
||||
}
|
||||
|
||||
/* Instantiate core */
|
||||
if(core == null)
|
||||
core = new DynmapCore();
|
||||
/* Inject dependencies */
|
||||
core.setPluginVersion(version);
|
||||
core.setMinecraftVersion(mcver);
|
||||
core.setDataFolder(dataDirectory);
|
||||
core.setServer(new BukkitServer());
|
||||
|
||||
/* Enable core */
|
||||
if(!core.enableCore()) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
/* Get map manager from core */
|
||||
mapManager = core.getMapManager();
|
||||
/* Initialized the currently loaded worlds */
|
||||
for (World world : getServer().getWorlds()) {
|
||||
BukkitWorld w = new BukkitWorld(world);
|
||||
if(core.processWorldLoad(w)) /* Have core process load first - fire event listeners if good load after */
|
||||
core.listenerManager.processWorldEvent(EventType.WORLD_LOAD, w);
|
||||
}
|
||||
|
||||
/* Register our update trigger events */
|
||||
registerEvents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
/* Reset registered listeners */
|
||||
bep.cleanup();
|
||||
/* Disable core */
|
||||
core.disableCore();
|
||||
}
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
DynmapCommandSender dsender;
|
||||
if(sender instanceof Player) {
|
||||
dsender = new BukkitPlayer((Player)sender);
|
||||
}
|
||||
else {
|
||||
dsender = new BukkitCommandSender(sender);
|
||||
}
|
||||
return core.processCommand(dsender, cmd.getName(), commandLabel, args);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final MarkerAPI getMarkerAPI() {
|
||||
return core.getMarkerAPI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean markerAPIInitialized() {
|
||||
return core.markerAPIInitialized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean sendBroadcastToWeb(String sender, String msg) {
|
||||
return core.sendBroadcastToWeb(sender, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int triggerRenderOfVolume(String wid, int minx, int miny, int minz,
|
||||
int maxx, int maxy, int maxz) {
|
||||
return core.triggerRenderOfVolume(wid, minx, miny, minz, maxx, maxy, maxz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int triggerRenderOfBlock(String wid, int x, int y, int z) {
|
||||
return core.triggerRenderOfBlock(wid, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setPauseFullRadiusRenders(boolean dopause) {
|
||||
core.setPauseFullRadiusRenders(dopause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getPauseFullRadiusRenders() {
|
||||
return core.getPauseFullRadiusRenders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setPauseUpdateRenders(boolean dopause) {
|
||||
core.setPauseUpdateRenders(dopause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getPauseUpdateRenders() {
|
||||
return core.getPauseUpdateRenders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setPlayerVisiblity(String player, boolean is_visible) {
|
||||
core.setPlayerVisiblity(player, is_visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getPlayerVisbility(String player) {
|
||||
return core.getPlayerVisbility(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void postPlayerMessageToWeb(String playerid, String playerdisplay,
|
||||
String message) {
|
||||
core.postPlayerMessageToWeb(playerid, playerdisplay, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void postPlayerJoinQuitToWeb(String playerid, String playerdisplay,
|
||||
boolean isjoin) {
|
||||
core.postPlayerJoinQuitToWeb(playerid, playerdisplay, isjoin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getDynmapCoreVersion() {
|
||||
return core.getDynmapCoreVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int triggerRenderOfVolume(Location l0, Location l1) {
|
||||
int x0 = l0.getBlockX(), y0 = l0.getBlockY(), z0 = l0.getBlockZ();
|
||||
int x1 = l1.getBlockX(), y1 = l1.getBlockY(), z1 = l1.getBlockZ();
|
||||
|
||||
return core.triggerRenderOfVolume(l0.getWorld().getName(), Math.min(x0, x1), Math.min(y0, y1),
|
||||
Math.min(z0, z1), Math.max(x0, x1), Math.max(y0, y1), Math.max(z0, z1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setPlayerVisiblity(Player player, boolean is_visible) {
|
||||
core.setPlayerVisiblity(player.getName(), is_visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean getPlayerVisbility(Player player) {
|
||||
return core.getPlayerVisbility(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void postPlayerMessageToWeb(Player player, String message) {
|
||||
core.postPlayerMessageToWeb(player.getName(), player.getDisplayName(), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postPlayerJoinQuitToWeb(Player player, boolean isjoin) {
|
||||
core.postPlayerJoinQuitToWeb(player.getName(), player.getDisplayName(), isjoin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDynmapVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
private static DynmapLocation toLoc(Location l) {
|
||||
return new DynmapLocation(l.getWorld().getName(), l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
}
|
||||
|
||||
private void registerPlayerLoginListener() {
|
||||
PlayerListener pl = new PlayerListener() {
|
||||
public void onPlayerJoin(PlayerJoinEvent evt) {
|
||||
DynmapPlayer dp = new BukkitPlayer(evt.getPlayer());
|
||||
core.listenerManager.processPlayerEvent(EventType.PLAYER_JOIN, dp);
|
||||
}
|
||||
public void onPlayerQuit(PlayerQuitEvent evt) {
|
||||
DynmapPlayer dp = new BukkitPlayer(evt.getPlayer());
|
||||
core.listenerManager.processPlayerEvent(EventType.PLAYER_QUIT, dp);
|
||||
}
|
||||
};
|
||||
bep.registerEvent(Type.PLAYER_JOIN, pl);
|
||||
bep.registerEvent(Type.PLAYER_QUIT, pl);
|
||||
}
|
||||
|
||||
private boolean onplace;
|
||||
private boolean onbreak;
|
||||
private boolean onblockform;
|
||||
private boolean onblockfade;
|
||||
private boolean onblockspread;
|
||||
private boolean onblockfromto;
|
||||
private boolean onblockphysics;
|
||||
private boolean onleaves;
|
||||
private boolean onburn;
|
||||
private boolean onpiston;
|
||||
private boolean onplayerjoin;
|
||||
private boolean onplayermove;
|
||||
private boolean ongeneratechunk;
|
||||
private boolean onloadchunk;
|
||||
private boolean onexplosion;
|
||||
|
||||
private void registerEvents() {
|
||||
BlockListener blockTrigger = new BlockListener() {
|
||||
@Override
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = loc.getWorld().getName();
|
||||
mapManager.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onplace) {
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockplace");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = loc.getWorld().getName();
|
||||
mapManager.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onbreak) {
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockbreak");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeavesDecay(LeavesDecayEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = loc.getWorld().getName();
|
||||
mapManager.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onleaves) {
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "leavesdecay");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBurn(BlockBurnEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = loc.getWorld().getName();
|
||||
mapManager.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onburn) {
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockburn");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockForm(BlockFormEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = loc.getWorld().getName();
|
||||
mapManager.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onblockform) {
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockform");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockFade(BlockFadeEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = loc.getWorld().getName();
|
||||
mapManager.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onblockfade) {
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockfade");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockSpread(BlockSpreadEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = loc.getWorld().getName();
|
||||
mapManager.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onblockspread) {
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockspread");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getToBlock().getLocation();
|
||||
String wn = loc.getWorld().getName();
|
||||
mapManager.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onblockfromto)
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockfromto");
|
||||
loc = event.getBlock().getLocation();
|
||||
wn = loc.getWorld().getName();
|
||||
mapManager.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onblockfromto)
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockfromto");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = loc.getWorld().getName();
|
||||
mapManager.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onblockphysics) {
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockphysics");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Block b = event.getBlock();
|
||||
Location loc = b.getLocation();
|
||||
BlockFace dir;
|
||||
try { /* Workaround Bukkit bug = http://leaky.bukkit.org/issues/1227 */
|
||||
dir = event.getDirection();
|
||||
} catch (ClassCastException ccx) {
|
||||
dir = BlockFace.NORTH;
|
||||
}
|
||||
String wn = loc.getWorld().getName();
|
||||
int x = loc.getBlockX(), y = loc.getBlockY(), z = loc.getBlockZ();
|
||||
mapManager.sscache.invalidateSnapshot(wn, x, y, z);
|
||||
if(onpiston)
|
||||
mapManager.touch(wn, x, y, z, "pistonretract");
|
||||
for(int i = 0; i < 2; i++) {
|
||||
x += dir.getModX();
|
||||
y += dir.getModY();
|
||||
z += dir.getModZ();
|
||||
mapManager.sscache.invalidateSnapshot(wn, x, y, z);
|
||||
if(onpiston)
|
||||
mapManager.touch(wn, x, y, z, "pistonretract");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Block b = event.getBlock();
|
||||
Location loc = b.getLocation();
|
||||
BlockFace dir;
|
||||
try { /* Workaround Bukkit bug = http://leaky.bukkit.org/issues/1227 */
|
||||
dir = event.getDirection();
|
||||
} catch (ClassCastException ccx) {
|
||||
dir = BlockFace.NORTH;
|
||||
}
|
||||
String wn = loc.getWorld().getName();
|
||||
int x = loc.getBlockX(), y = loc.getBlockY(), z = loc.getBlockZ();
|
||||
mapManager.sscache.invalidateSnapshot(wn, x, y, z);
|
||||
if(onpiston)
|
||||
mapManager.touch(wn, x, y, z, "pistonretract");
|
||||
for(int i = 0; i < 1+event.getLength(); i++) {
|
||||
x += dir.getModX();
|
||||
y += dir.getModY();
|
||||
z += dir.getModZ();
|
||||
mapManager.sscache.invalidateSnapshot(wn, x, y, z);
|
||||
if(onpiston)
|
||||
mapManager.touch(wn, x, y, z, "pistonretract");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// To trigger rendering.
|
||||
onplace = core.isTrigger("blockplaced");
|
||||
bep.registerEvent(Event.Type.BLOCK_PLACE, blockTrigger);
|
||||
|
||||
onbreak = core.isTrigger("blockbreak");
|
||||
bep.registerEvent(Event.Type.BLOCK_BREAK, blockTrigger);
|
||||
|
||||
if(core.isTrigger("snowform")) Log.info("The 'snowform' trigger has been deprecated due to Bukkit changes - use 'blockformed'");
|
||||
|
||||
onleaves = core.isTrigger("leavesdecay");
|
||||
bep.registerEvent(Event.Type.LEAVES_DECAY, blockTrigger);
|
||||
|
||||
onburn = core.isTrigger("blockburn");
|
||||
bep.registerEvent(Event.Type.BLOCK_BURN, blockTrigger);
|
||||
|
||||
onblockform = core.isTrigger("blockformed");
|
||||
bep.registerEvent(Event.Type.BLOCK_FORM, blockTrigger);
|
||||
|
||||
onblockfade = core.isTrigger("blockfaded");
|
||||
bep.registerEvent(Event.Type.BLOCK_FADE, blockTrigger);
|
||||
|
||||
onblockspread = core.isTrigger("blockspread");
|
||||
bep.registerEvent(Event.Type.BLOCK_SPREAD, blockTrigger);
|
||||
|
||||
onblockfromto = core.isTrigger("blockfromto");
|
||||
bep.registerEvent(Event.Type.BLOCK_FROMTO, blockTrigger);
|
||||
|
||||
onblockphysics = core.isTrigger("blockphysics");
|
||||
bep.registerEvent(Event.Type.BLOCK_PHYSICS, blockTrigger);
|
||||
|
||||
onpiston = core.isTrigger("pistonmoved");
|
||||
bep.registerEvent(Event.Type.BLOCK_PISTON_EXTEND, blockTrigger);
|
||||
bep.registerEvent(Event.Type.BLOCK_PISTON_RETRACT, blockTrigger);
|
||||
/* Register player event trigger handlers */
|
||||
PlayerListener playerTrigger = new PlayerListener() {
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if(onplayerjoin) {
|
||||
Location loc = event.getPlayer().getLocation();
|
||||
mapManager.touch(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "playerjoin");
|
||||
}
|
||||
core.listenerManager.processPlayerEvent(EventType.PLAYER_JOIN, new BukkitPlayer(event.getPlayer()));
|
||||
}
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
core.listenerManager.processPlayerEvent(EventType.PLAYER_QUIT, new BukkitPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Location loc = event.getPlayer().getLocation();
|
||||
mapManager.touch(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "playermove");
|
||||
}
|
||||
};
|
||||
|
||||
onplayerjoin = core.isTrigger("playerjoin");
|
||||
onplayermove = core.isTrigger("playermove");
|
||||
bep.registerEvent(Event.Type.PLAYER_JOIN, playerTrigger);
|
||||
bep.registerEvent(Event.Type.PLAYER_QUIT, playerTrigger);
|
||||
if(onplayermove)
|
||||
bep.registerEvent(Event.Type.PLAYER_MOVE, playerTrigger);
|
||||
|
||||
/* Register entity event triggers */
|
||||
EntityListener entityTrigger = new EntityListener() {
|
||||
@Override
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
Location loc = event.getLocation();
|
||||
String wname = loc.getWorld().getName();
|
||||
int minx, maxx, miny, maxy, minz, maxz;
|
||||
minx = maxx = loc.getBlockX();
|
||||
miny = maxy = loc.getBlockY();
|
||||
minz = maxz = loc.getBlockZ();
|
||||
/* Calculate volume impacted by explosion */
|
||||
List<Block> blocks = event.blockList();
|
||||
for(Block b: blocks) {
|
||||
Location l = b.getLocation();
|
||||
int x = l.getBlockX();
|
||||
if(x < minx) minx = x;
|
||||
if(x > maxx) maxx = x;
|
||||
int y = l.getBlockY();
|
||||
if(y < miny) miny = y;
|
||||
if(y > maxy) maxy = y;
|
||||
int z = l.getBlockZ();
|
||||
if(z < minz) minz = z;
|
||||
if(z > maxz) maxz = z;
|
||||
}
|
||||
mapManager.sscache.invalidateSnapshot(wname, minx, miny, minz, maxx, maxy, maxz);
|
||||
if(onexplosion) {
|
||||
mapManager.touchVolume(wname, minx, miny, minz, maxx, maxy, maxz, "entityexplode");
|
||||
}
|
||||
}
|
||||
};
|
||||
onexplosion = core.isTrigger("explosion");
|
||||
bep.registerEvent(Event.Type.ENTITY_EXPLODE, entityTrigger);
|
||||
|
||||
|
||||
/* Register world event triggers */
|
||||
WorldListener worldTrigger = new WorldListener() {
|
||||
@Override
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
if(core.ignore_chunk_loads)
|
||||
return;
|
||||
Chunk c = event.getChunk();
|
||||
/* Touch extreme corners */
|
||||
int x = c.getX() << 4;
|
||||
int z = c.getZ() << 4;
|
||||
mapManager.touchVolume(event.getWorld().getName(), x, 0, z, x+15, 128, z+16, "chunkload");
|
||||
}
|
||||
@Override
|
||||
public void onChunkPopulate(ChunkPopulateEvent event) {
|
||||
Chunk c = event.getChunk();
|
||||
/* Touch extreme corners */
|
||||
int x = c.getX() << 4;
|
||||
int z = c.getZ() << 4;
|
||||
mapManager.touchVolume(event.getWorld().getName(), x, 0, z, x+15, 128, z+16, "chunkpopulate");
|
||||
}
|
||||
@Override
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
core.updateConfigHashcode();
|
||||
BukkitWorld w = new BukkitWorld(event.getWorld());
|
||||
if(core.processWorldLoad(w)) /* Have core process load first - fire event listeners if good load after */
|
||||
core.listenerManager.processWorldEvent(EventType.WORLD_LOAD, w);
|
||||
}
|
||||
@Override
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
core.updateConfigHashcode();
|
||||
DynmapWorld w = core.getWorld(event.getWorld().getName());
|
||||
if(w != null)
|
||||
core.listenerManager.processWorldEvent(EventType.WORLD_UNLOAD, w);
|
||||
}
|
||||
};
|
||||
|
||||
ongeneratechunk = core.isTrigger("chunkgenerated");
|
||||
if(ongeneratechunk) {
|
||||
bep.registerEvent(Event.Type.CHUNK_POPULATED, worldTrigger);
|
||||
}
|
||||
onloadchunk = core.isTrigger("chunkloaded");
|
||||
if(onloadchunk) {
|
||||
bep.registerEvent(Event.Type.CHUNK_LOAD, worldTrigger);
|
||||
}
|
||||
|
||||
// To link configuration to real loaded worlds.
|
||||
bep.registerEvent(Event.Type.WORLD_LOAD, worldTrigger);
|
||||
bep.registerEvent(Event.Type.WORLD_UNLOAD, worldTrigger);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.dynmap.utils;
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -14,10 +14,14 @@ import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.MapIterator;
|
||||
import org.dynmap.utils.MapChunkCache.HiddenChunkStyle;
|
||||
import org.dynmap.utils.MapChunkCache.VisibilityLimit;
|
||||
import org.dynmap.utils.MapIterator.BlockStep;
|
||||
|
||||
/**
|
||||
@ -446,7 +450,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
|
||||
checkTickList();
|
||||
|
||||
DynmapPlugin.setIgnoreChunkLoads(true);
|
||||
DynmapCore.setIgnoreChunkLoads(true);
|
||||
//boolean isnormral = w.getEnvironment() == Environment.NORMAL;
|
||||
// Load the required chunks.
|
||||
while((cnt < max_to_load) && iterator.hasNext()) {
|
||||
@ -556,7 +560,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
DynmapPlugin.setIgnoreChunkLoads(false);
|
||||
DynmapCore.setIgnoreChunkLoads(false);
|
||||
|
||||
if(iterator.hasNext() == false) { /* If we're done */
|
||||
isempty = true;
|
37
src/main/java/org/dynmap/common/DynmapChatColor.java
Normal file
37
src/main/java/org/dynmap/common/DynmapChatColor.java
Normal file
@ -0,0 +1,37 @@
|
||||
package org.dynmap.common;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public enum DynmapChatColor {
|
||||
BLACK(0x0),
|
||||
DARK_BLUE(0x1),
|
||||
DARK_GREEN(0x2),
|
||||
DARK_AQUA(0x3),
|
||||
DARK_RED(0x4),
|
||||
DARK_PURPLE(0x5),
|
||||
GOLD(0x6),
|
||||
GRAY(0x7),
|
||||
DARK_GRAY(0x8),
|
||||
BLUE(0x9),
|
||||
GREEN(0xA),
|
||||
AQUA(0xB),
|
||||
RED(0xC),
|
||||
LIGHT_PURPLE(0xD),
|
||||
YELLOW(0xE),
|
||||
WHITE(0xF);
|
||||
|
||||
private final int code;
|
||||
private final String str;
|
||||
|
||||
private DynmapChatColor(final int code) {
|
||||
this.code = code;
|
||||
this.str = String.format("\u00A7%x", code);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return str;
|
||||
}
|
||||
}
|
24
src/main/java/org/dynmap/common/DynmapCommandSender.java
Normal file
24
src/main/java/org/dynmap/common/DynmapCommandSender.java
Normal file
@ -0,0 +1,24 @@
|
||||
package org.dynmap.common;
|
||||
|
||||
public interface DynmapCommandSender {
|
||||
/**
|
||||
* Does command sender have given security privilege
|
||||
* @param privid - privilege ID
|
||||
* @return true if it does, false if it doesn't
|
||||
*/
|
||||
public boolean hasPrivilege(String privid);
|
||||
/**
|
||||
* Send given message to command sender
|
||||
* @param msg - message to be sent (with color codes marked &0 to &F)
|
||||
*/
|
||||
public void sendMessage(String msg);
|
||||
/**
|
||||
* Test if command sender is still connected/online
|
||||
* @return true if connected, false if not
|
||||
*/
|
||||
public boolean isConnected();
|
||||
/**
|
||||
* Is operator privilege
|
||||
*/
|
||||
public boolean isOp();
|
||||
}
|
124
src/main/java/org/dynmap/common/DynmapListenerManager.java
Normal file
124
src/main/java/org/dynmap/common/DynmapListenerManager.java
Normal file
@ -0,0 +1,124 @@
|
||||
package org.dynmap.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapWorld;
|
||||
|
||||
/**
|
||||
* Simple handler for managing event listeners and dispatch in a neutral fashion
|
||||
*
|
||||
*/
|
||||
public class DynmapListenerManager {
|
||||
private DynmapCore core;
|
||||
|
||||
public DynmapListenerManager(DynmapCore core) {
|
||||
this.core = core;
|
||||
}
|
||||
public interface EventListener {
|
||||
}
|
||||
public interface WorldEventListener extends EventListener {
|
||||
public void worldEvent(DynmapWorld w);
|
||||
}
|
||||
public interface PlayerEventListener extends EventListener {
|
||||
public void playerEvent(DynmapPlayer p);
|
||||
}
|
||||
public interface ChatEventListener extends EventListener {
|
||||
public void chatEvent(DynmapPlayer p, String msg);
|
||||
}
|
||||
public interface BlockEventListener extends EventListener {
|
||||
public void blockEvent(int blkid, String w, int x, int y, int z);
|
||||
}
|
||||
public interface SignChangeEventListener extends EventListener {
|
||||
public void signChangeEvent(int blkid, String w, int x, int y, int z, String[] lines, DynmapPlayer p);
|
||||
}
|
||||
public enum EventType {
|
||||
WORLD_LOAD,
|
||||
WORLD_UNLOAD,
|
||||
WORLD_SPAWN_CHANGE,
|
||||
PLAYER_JOIN,
|
||||
PLAYER_QUIT,
|
||||
PLAYER_BED_LEAVE,
|
||||
PLAYER_CHAT,
|
||||
BLOCK_BREAK,
|
||||
SIGN_CHANGE
|
||||
}
|
||||
private Map<EventType, ArrayList<EventListener>> listeners = new EnumMap<EventType, ArrayList<EventListener>>(EventType.class);
|
||||
|
||||
public void addListener(EventType type, EventListener listener) {
|
||||
ArrayList<EventListener> lst = listeners.get(type);
|
||||
if(lst == null) {
|
||||
lst = new ArrayList<EventListener>();
|
||||
listeners.put(type, lst);
|
||||
core.getServer().requestEventNotification(type);
|
||||
}
|
||||
lst.add(listener);
|
||||
}
|
||||
|
||||
public void processWorldEvent(EventType type, DynmapWorld w) {
|
||||
ArrayList<EventListener> lst = listeners.get(type);
|
||||
if(lst == null) return;
|
||||
int sz = lst.size();
|
||||
for(int i = 0; i < sz; i++) {
|
||||
EventListener el = lst.get(i);
|
||||
if(el instanceof WorldEventListener) {
|
||||
((WorldEventListener)el).worldEvent(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void processPlayerEvent(EventType type, DynmapPlayer p) {
|
||||
ArrayList<EventListener> lst = listeners.get(type);
|
||||
if(lst == null) return;
|
||||
int sz = lst.size();
|
||||
for(int i = 0; i < sz; i++) {
|
||||
EventListener el = lst.get(i);
|
||||
if(el instanceof PlayerEventListener) {
|
||||
((PlayerEventListener)el).playerEvent(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void processChatEvent(EventType type, DynmapPlayer p, String msg) {
|
||||
ArrayList<EventListener> lst = listeners.get(type);
|
||||
if(lst == null) return;
|
||||
int sz = lst.size();
|
||||
for(int i = 0; i < sz; i++) {
|
||||
EventListener el = lst.get(i);
|
||||
if(el instanceof ChatEventListener) {
|
||||
((ChatEventListener)el).chatEvent(p, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void processBlockEvent(EventType type, int blkid, String world, int x, int y, int z)
|
||||
{
|
||||
ArrayList<EventListener> lst = listeners.get(type);
|
||||
if(lst == null) return;
|
||||
int sz = lst.size();
|
||||
for(int i = 0; i < sz; i++) {
|
||||
EventListener el = lst.get(i);
|
||||
if(el instanceof BlockEventListener) {
|
||||
((BlockEventListener)el).blockEvent(blkid, world, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void processSignChangeEvent(EventType type, int blkid, String world, int x, int y, int z, String[] lines, DynmapPlayer p)
|
||||
{
|
||||
ArrayList<EventListener> lst = listeners.get(type);
|
||||
if(lst == null) return;
|
||||
int sz = lst.size();
|
||||
for(int i = 0; i < sz; i++) {
|
||||
EventListener el = lst.get(i);
|
||||
if(el instanceof SignChangeEventListener) {
|
||||
((SignChangeEventListener)el).signChangeEvent(blkid, world, x, y, z, lines, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Clean up registered listeners */
|
||||
public void cleanup() {
|
||||
for(ArrayList<EventListener> l : listeners.values())
|
||||
l.clear();
|
||||
listeners.clear();
|
||||
}
|
||||
}
|
57
src/main/java/org/dynmap/common/DynmapPlayer.java
Normal file
57
src/main/java/org/dynmap/common/DynmapPlayer.java
Normal file
@ -0,0 +1,57 @@
|
||||
package org.dynmap.common;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.dynmap.DynmapLocation;
|
||||
|
||||
/**
|
||||
* Player (server neutral) - represents online or offline player
|
||||
*/
|
||||
public interface DynmapPlayer extends DynmapCommandSender {
|
||||
/**
|
||||
* Get player ID
|
||||
* @return ID (case insensitive)
|
||||
*/
|
||||
public String getName();
|
||||
/**
|
||||
* Get player display name
|
||||
* @return display name
|
||||
*/
|
||||
public String getDisplayName();
|
||||
/**
|
||||
* Is player online?
|
||||
* @return true if online
|
||||
*/
|
||||
public boolean isOnline();
|
||||
/**
|
||||
* Get current location of player
|
||||
* @return location
|
||||
*/
|
||||
public DynmapLocation getLocation();
|
||||
/**
|
||||
* Get world ID of player
|
||||
* @return id
|
||||
*/
|
||||
public String getWorld();
|
||||
/**
|
||||
* Get connected address for player
|
||||
*/
|
||||
public InetSocketAddress getAddress();
|
||||
/**
|
||||
* Check if player is sneaking
|
||||
*/
|
||||
public boolean isSneaking();
|
||||
/**
|
||||
* Get health
|
||||
*/
|
||||
public int getHealth();
|
||||
/**
|
||||
* Get armor points
|
||||
*/
|
||||
public int getArmorPoints();
|
||||
/**
|
||||
* Get spawn bed location
|
||||
*/
|
||||
public DynmapLocation getBedSpawnLocation();
|
||||
}
|
75
src/main/java/org/dynmap/common/DynmapServerInterface.java
Normal file
75
src/main/java/org/dynmap/common/DynmapServerInterface.java
Normal file
@ -0,0 +1,75 @@
|
||||
package org.dynmap.common;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
|
||||
/**
|
||||
* This interface defines a server-neutral interface for the DynmapCore and other neutral components to use to access server provided
|
||||
* services. Platform-specific plugin must supply DynmapCore with an instance of an object implementing this interface.
|
||||
*/
|
||||
public interface DynmapServerInterface {
|
||||
/**
|
||||
* Schedule task to run on server-safe thread (one suitable for other server API calls)
|
||||
* @param run - runnable method
|
||||
* @param delay - delay in server ticks (50msec)
|
||||
*/
|
||||
public void scheduleServerTask(Runnable run, long delay);
|
||||
/**
|
||||
* Call method on server-safe thread
|
||||
* @param call - Callable method
|
||||
* @return future for completion of call
|
||||
*/
|
||||
public <T> Future<T> callSyncMethod(Callable<T> task);
|
||||
/**
|
||||
* Get list of online players
|
||||
* @return list of online players
|
||||
*/
|
||||
public DynmapPlayer[] getOnlinePlayers();
|
||||
/**
|
||||
* Request reload of plugin
|
||||
*/
|
||||
public void reload();
|
||||
/**
|
||||
* Get active player
|
||||
* @param name - player name
|
||||
* @return player
|
||||
*/
|
||||
public DynmapPlayer getPlayer(String name);
|
||||
/**
|
||||
* Get banned IPs
|
||||
*/
|
||||
public Set<String> getIPBans();
|
||||
/**
|
||||
* Get server name
|
||||
*/
|
||||
public String getServerName();
|
||||
/**
|
||||
* Test if player ID is banned
|
||||
*/
|
||||
public boolean isPlayerBanned(String pid);
|
||||
/**
|
||||
* Strip out chat color
|
||||
*/
|
||||
public String stripChatColor(String s);
|
||||
/**
|
||||
* Request notificiation for given events (used by DynmapListenerManager)
|
||||
*/
|
||||
public boolean requestEventNotification(EventType type);
|
||||
/**
|
||||
* Send notification of web chat message
|
||||
* @param source - source
|
||||
* @param name - name
|
||||
* @param msg - message text
|
||||
* @return true if not cancelled
|
||||
*/
|
||||
public boolean sendWebChatEvent(String source, String name, String msg);
|
||||
/**
|
||||
* Broadcast message to players
|
||||
* @param msg
|
||||
*/
|
||||
public void broadcastMessage(String msg);
|
||||
}
|
@ -14,8 +14,9 @@ import org.dynmap.Color;
|
||||
import org.dynmap.ColorScheme;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.DynmapPlugin.CompassMode;
|
||||
import org.dynmap.DynmapCore.CompassMode;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.TileHashManager;
|
||||
import org.dynmap.MapTile;
|
||||
@ -42,11 +43,11 @@ public class FlatMap extends MapType {
|
||||
private Texture textured = Texture.NONE;
|
||||
private boolean isbigmap;
|
||||
|
||||
public FlatMap(ConfigurationNode configuration) {
|
||||
public FlatMap(DynmapCore core, ConfigurationNode configuration) {
|
||||
this.configuration = configuration;
|
||||
name = configuration.getString("name", null);
|
||||
prefix = configuration.getString("prefix", name);
|
||||
colorScheme = ColorScheme.getScheme((String) configuration.get("colorscheme"));
|
||||
colorScheme = ColorScheme.getScheme(core, (String) configuration.get("colorscheme"));
|
||||
Object o = configuration.get("maximumheight");
|
||||
if (o != null) {
|
||||
maximumHeight = Integer.parseInt(String.valueOf(o));
|
||||
|
@ -3,6 +3,7 @@ package org.dynmap.hdmap;
|
||||
import static org.dynmap.JSONUtils.s;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.MapIterator;
|
||||
import org.json.simple.JSONObject;
|
||||
@ -12,7 +13,7 @@ public class CaveHDShader implements HDShader {
|
||||
private boolean iflit;
|
||||
|
||||
|
||||
public CaveHDShader(ConfigurationNode configuration) {
|
||||
public CaveHDShader(DynmapCore core, ConfigurationNode configuration) {
|
||||
name = (String) configuration.get("name");
|
||||
iflit = configuration.getBoolean("onlyiflit", false);
|
||||
}
|
||||
|
@ -2,13 +2,14 @@ package org.dynmap.hdmap;
|
||||
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.json.simple.JSONObject;
|
||||
import static org.dynmap.JSONUtils.s;
|
||||
|
||||
public class DefaultHDLighting implements HDLighting {
|
||||
private String name;
|
||||
|
||||
public DefaultHDLighting(ConfigurationNode configuration) {
|
||||
public DefaultHDLighting(DynmapCore core, ConfigurationNode configuration) {
|
||||
name = (String) configuration.get("name");
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.block.Biome;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ColorScheme;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.MapIterator;
|
||||
import org.json.simple.JSONObject;
|
||||
@ -19,9 +20,9 @@ public class DefaultHDShader implements HDShader {
|
||||
}
|
||||
protected BiomeColorOption biomecolored = BiomeColorOption.NONE; /* Use biome for coloring */
|
||||
|
||||
public DefaultHDShader(ConfigurationNode configuration) {
|
||||
public DefaultHDShader(DynmapCore core, ConfigurationNode configuration) {
|
||||
name = (String) configuration.get("name");
|
||||
colorScheme = ColorScheme.getScheme(configuration.getString("colorscheme", "default"));
|
||||
colorScheme = ColorScheme.getScheme(core, configuration.getString("colorscheme", "default"));
|
||||
transparency = configuration.getBoolean("transparency", true); /* Default on */
|
||||
String biomeopt = configuration.getString("biomecolored", "none");
|
||||
if(biomeopt.equals("biome")) {
|
||||
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||
import org.dynmap.Client;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.Log;
|
||||
@ -36,7 +37,7 @@ public class HDMap extends MapType {
|
||||
public static final String IMGFORMAT_JPG = "jpg";
|
||||
|
||||
|
||||
public HDMap(ConfigurationNode configuration) {
|
||||
public HDMap(DynmapCore core, ConfigurationNode configuration) {
|
||||
name = configuration.getString("name", null);
|
||||
if(name == null) {
|
||||
Log.severe("HDMap missing required attribute 'name' - disabled");
|
||||
|
@ -6,7 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
@ -25,29 +25,29 @@ public class HDMapManager {
|
||||
public static boolean waterlightingfix;
|
||||
public static boolean biomeshadingfix;
|
||||
|
||||
public void loadHDShaders(DynmapPlugin plugin) {
|
||||
public void loadHDShaders(DynmapCore core) {
|
||||
Log.verboseinfo("Loading shaders...");
|
||||
|
||||
File f = new File(plugin.getDataFolder(), "shaders.txt");
|
||||
if(!plugin.updateUsingDefaultResource("/shaders.txt", f, "shaders")) {
|
||||
File f = new File(core.getDataFolder(), "shaders.txt");
|
||||
if(!core.updateUsingDefaultResource("/shaders.txt", f, "shaders")) {
|
||||
return;
|
||||
}
|
||||
org.bukkit.util.config.Configuration bukkitShaderConfig = new org.bukkit.util.config.Configuration(f);
|
||||
bukkitShaderConfig.load();
|
||||
ConfigurationNode shadercfg = new ConfigurationNode(bukkitShaderConfig);
|
||||
|
||||
for(HDShader shader : shadercfg.<HDShader>createInstances("shaders", new Class<?>[0], new Object[0])) {
|
||||
for(HDShader shader : shadercfg.<HDShader>createInstances("shaders", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||
if(shader.getName() == null) continue;
|
||||
shaders.put(shader.getName(), shader);
|
||||
}
|
||||
/* Load custom shaders, if file is defined - or create empty one if not */
|
||||
f = new File(plugin.getDataFolder(), "custom-shaders.txt");
|
||||
plugin.createDefaultFileFromResource("/custom-shaders.txt", f);
|
||||
f = new File(core.getDataFolder(), "custom-shaders.txt");
|
||||
core.createDefaultFileFromResource("/custom-shaders.txt", f);
|
||||
if(f.exists()) {
|
||||
bukkitShaderConfig = new org.bukkit.util.config.Configuration(f);
|
||||
bukkitShaderConfig.load();
|
||||
ConfigurationNode customshadercfg = new ConfigurationNode(bukkitShaderConfig);
|
||||
for(HDShader shader : customshadercfg.<HDShader>createInstances("shaders", new Class<?>[0], new Object[0])) {
|
||||
for(HDShader shader : customshadercfg.<HDShader>createInstances("shaders", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||
if(shader.getName() == null) continue;
|
||||
shaders.put(shader.getName(), shader);
|
||||
}
|
||||
@ -57,27 +57,27 @@ public class HDMapManager {
|
||||
TexturePack.handleHideOres();
|
||||
}
|
||||
|
||||
public void loadHDPerspectives(DynmapPlugin plugin) {
|
||||
public void loadHDPerspectives(DynmapCore core) {
|
||||
Log.verboseinfo("Loading perspectives...");
|
||||
File f = new File(plugin.getDataFolder(), "perspectives.txt");
|
||||
if(!plugin.updateUsingDefaultResource("/perspectives.txt", f, "perspectives")) {
|
||||
File f = new File(core.getDataFolder(), "perspectives.txt");
|
||||
if(!core.updateUsingDefaultResource("/perspectives.txt", f, "perspectives")) {
|
||||
return;
|
||||
}
|
||||
org.bukkit.util.config.Configuration bukkitPerspectiveConfig = new org.bukkit.util.config.Configuration(f);
|
||||
bukkitPerspectiveConfig.load();
|
||||
ConfigurationNode perspectivecfg = new ConfigurationNode(bukkitPerspectiveConfig);
|
||||
for(HDPerspective perspective : perspectivecfg.<HDPerspective>createInstances("perspectives", new Class<?>[0], new Object[0])) {
|
||||
for(HDPerspective perspective : perspectivecfg.<HDPerspective>createInstances("perspectives", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||
if(perspective.getName() == null) continue;
|
||||
perspectives.put(perspective.getName(), perspective);
|
||||
}
|
||||
/* Load custom perspectives, if file is defined - or create empty one if not */
|
||||
f = new File(plugin.getDataFolder(), "custom-perspectives.txt");
|
||||
plugin.createDefaultFileFromResource("/custom-perspectives.txt", f);
|
||||
f = new File(core.getDataFolder(), "custom-perspectives.txt");
|
||||
core.createDefaultFileFromResource("/custom-perspectives.txt", f);
|
||||
if(f.exists()) {
|
||||
bukkitPerspectiveConfig = new org.bukkit.util.config.Configuration(f);
|
||||
bukkitPerspectiveConfig.load();
|
||||
perspectivecfg = new ConfigurationNode(bukkitPerspectiveConfig);
|
||||
for(HDPerspective perspective : perspectivecfg.<HDPerspective>createInstances("perspectives", new Class<?>[0], new Object[0])) {
|
||||
for(HDPerspective perspective : perspectivecfg.<HDPerspective>createInstances("perspectives", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||
if(perspective.getName() == null) continue;
|
||||
perspectives.put(perspective.getName(), perspective);
|
||||
}
|
||||
@ -85,28 +85,28 @@ public class HDMapManager {
|
||||
Log.info("Loaded " + perspectives.size() + " perspectives.");
|
||||
}
|
||||
|
||||
public void loadHDLightings(DynmapPlugin plugin) {
|
||||
public void loadHDLightings(DynmapCore core) {
|
||||
Log.verboseinfo("Loading lightings...");
|
||||
File f = new File(plugin.getDataFolder(), "lightings.txt");
|
||||
if(!plugin.updateUsingDefaultResource("/lightings.txt", f, "lightings")) {
|
||||
File f = new File(core.getDataFolder(), "lightings.txt");
|
||||
if(!core.updateUsingDefaultResource("/lightings.txt", f, "lightings")) {
|
||||
return;
|
||||
}
|
||||
org.bukkit.util.config.Configuration bukkitLightingsConfig = new org.bukkit.util.config.Configuration(f);
|
||||
bukkitLightingsConfig.load();
|
||||
ConfigurationNode lightingcfg = new ConfigurationNode(bukkitLightingsConfig);
|
||||
|
||||
for(HDLighting lighting : lightingcfg.<HDLighting>createInstances("lightings", new Class<?>[0], new Object[0])) {
|
||||
for(HDLighting lighting : lightingcfg.<HDLighting>createInstances("lightings", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||
if(lighting.getName() == null) continue;
|
||||
lightings.put(lighting.getName(), lighting);
|
||||
}
|
||||
/* Load custom lightings, if file is defined - or create empty one if not */
|
||||
f = new File(plugin.getDataFolder(), "custom-lightings.txt");
|
||||
plugin.createDefaultFileFromResource("/custom-lightings.txt", f);
|
||||
f = new File(core.getDataFolder(), "custom-lightings.txt");
|
||||
core.createDefaultFileFromResource("/custom-lightings.txt", f);
|
||||
if(f.exists()) {
|
||||
bukkitLightingsConfig = new org.bukkit.util.config.Configuration(f);
|
||||
bukkitLightingsConfig.load();
|
||||
lightingcfg = new ConfigurationNode(bukkitLightingsConfig);
|
||||
for(HDLighting lighting : lightingcfg.<HDLighting>createInstances("lightings", new Class<?>[0], new Object[0])) {
|
||||
for(HDLighting lighting : lightingcfg.<HDLighting>createInstances("lightings", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||
if(lighting.getName() == null) continue;
|
||||
lightings.put(lighting.getName(), lighting);
|
||||
}
|
||||
|
@ -14,8 +14,9 @@ import org.dynmap.Client;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.DynmapPlugin.CompassMode;
|
||||
import org.dynmap.DynmapCore.CompassMode;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.MapTile;
|
||||
@ -762,7 +763,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||
}
|
||||
}
|
||||
|
||||
public IsoHDPerspective(ConfigurationNode configuration) {
|
||||
public IsoHDPerspective(DynmapCore core, ConfigurationNode configuration) {
|
||||
name = configuration.getString("name", null);
|
||||
if(name == null) {
|
||||
Log.severe("Perspective definition missing name - must be defined and unique");
|
||||
|
@ -2,6 +2,7 @@ package org.dynmap.hdmap;
|
||||
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.Log;
|
||||
|
||||
public class ShadowHDLighting extends DefaultHDLighting {
|
||||
@ -10,8 +11,8 @@ public class ShadowHDLighting extends DefaultHDLighting {
|
||||
protected int lightscale[]; /* scale skylight level (light = lightscale[skylight] */
|
||||
protected boolean night_and_day; /* If true, render both day (prefix+'-day') and night (prefix) tiles */
|
||||
|
||||
public ShadowHDLighting(ConfigurationNode configuration) {
|
||||
super(configuration);
|
||||
public ShadowHDLighting(DynmapCore core, ConfigurationNode configuration) {
|
||||
super(core, configuration);
|
||||
double shadowweight = configuration.getDouble("shadowstrength", 0.0);
|
||||
if(shadowweight > 0.0) {
|
||||
shadowscale = new int[16];
|
||||
|
@ -22,7 +22,7 @@ import javax.imageio.ImageIO;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.utils.DynmapBufferedImage;
|
||||
@ -219,12 +219,12 @@ public class TexturePack {
|
||||
|
||||
}
|
||||
/** Get or load texture pack */
|
||||
public static TexturePack getTexturePack(String tpname) {
|
||||
public static TexturePack getTexturePack(DynmapCore core, String tpname) {
|
||||
TexturePack tp = packs.get(tpname);
|
||||
if(tp != null)
|
||||
return tp;
|
||||
try {
|
||||
tp = new TexturePack(tpname); /* Attempt to load pack */
|
||||
tp = new TexturePack(core, tpname); /* Attempt to load pack */
|
||||
packs.put(tpname, tp);
|
||||
return tp;
|
||||
} catch (FileNotFoundException fnfx) {
|
||||
@ -235,9 +235,9 @@ public class TexturePack {
|
||||
/**
|
||||
* Constructor for texture pack, by name
|
||||
*/
|
||||
private TexturePack(String tpname) throws FileNotFoundException {
|
||||
private TexturePack(DynmapCore core, String tpname) throws FileNotFoundException {
|
||||
ZipFile zf = null;
|
||||
File texturedir = getTexturePackDirectory();
|
||||
File texturedir = getTexturePackDirectory(core);
|
||||
boolean use_generate = HDMapManager.usegeneratedtextures;
|
||||
if(HDMapManager.biomeshadingfix == false)
|
||||
water_toned_op = COLORMOD_OLD_WATERSHADED;
|
||||
@ -650,8 +650,8 @@ public class TexturePack {
|
||||
}
|
||||
|
||||
/* Get texture pack directory */
|
||||
private static File getTexturePackDirectory() {
|
||||
return new File(DynmapPlugin.dataDirectory, "texturepacks");
|
||||
private static File getTexturePackDirectory(DynmapCore core) {
|
||||
return new File(core.getDataFolder(), "texturepacks");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import static org.dynmap.JSONUtils.s;
|
||||
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
@ -19,10 +20,10 @@ public class TexturePackHDShader implements HDShader {
|
||||
private boolean waterbiomeshaded;
|
||||
private boolean bettergrass;
|
||||
|
||||
public TexturePackHDShader(ConfigurationNode configuration) {
|
||||
public TexturePackHDShader(DynmapCore core, ConfigurationNode configuration) {
|
||||
tpname = configuration.getString("texturepack", "minecraft");
|
||||
name = configuration.getString("name", tpname);
|
||||
tp = TexturePack.getTexturePack(tpname);
|
||||
tp = TexturePack.getTexturePack(core, tpname);
|
||||
biome_shaded = configuration.getBoolean("biomeshaded", true);
|
||||
swamp_shaded = configuration.getBoolean("swampshaded", MapManager.mapman.getSwampShading());
|
||||
waterbiomeshaded = configuration.getBoolean("waterbiomeshaded", MapManager.mapman.getWaterBiomeShading());
|
||||
|
@ -4,6 +4,7 @@ import static org.dynmap.JSONUtils.s;
|
||||
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.MapIterator;
|
||||
@ -28,7 +29,7 @@ public class TopoHDShader implements HDShader {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public TopoHDShader(ConfigurationNode configuration) {
|
||||
public TopoHDShader(DynmapCore core, ConfigurationNode configuration) {
|
||||
name = (String) configuration.get("name");
|
||||
|
||||
fillcolor = new Color[128]; /* Color by Y */
|
||||
|
@ -4,7 +4,6 @@ import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.CustomEventListener;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
@ -12,9 +11,13 @@ import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.dynmap.Client;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
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
|
||||
@ -22,7 +25,7 @@ public class HeroChatHandler {
|
||||
|
||||
private List<String> hcchannels;
|
||||
private String hcwebinputchannel;
|
||||
private DynmapPlugin plugin;
|
||||
private DynmapCore core;
|
||||
private HeroChatChannel hcwebinputchan;
|
||||
|
||||
private class OurPluginListener extends ServerListener {
|
||||
@ -229,9 +232,9 @@ public class HeroChatHandler {
|
||||
if (hcchannels.contains(c.getName()) ||
|
||||
hcchannels.contains(c.getNick())) {
|
||||
if(cce.isSentByPlayer()) { /* Player message? */
|
||||
org.bukkit.entity.Player p = plugin.getServer().getPlayer(cce.getSource());
|
||||
if((p != null) && (plugin.mapManager != null)) {
|
||||
plugin.mapManager.pushUpdate(new Client.ChatMessage("player",
|
||||
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(),
|
||||
@ -244,21 +247,21 @@ public class HeroChatHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public HeroChatHandler(ConfigurationNode cfg, DynmapPlugin plugin, Server server) {
|
||||
public HeroChatHandler(ConfigurationNode cfg, DynmapCore core) {
|
||||
/* If we're enabling hero chat support */
|
||||
Log.verboseinfo("HeroChat support configured");
|
||||
this.plugin = plugin;
|
||||
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 = server.getPluginManager().getPlugin("HeroChat");
|
||||
Plugin hc = DynmapPlugin.plugin.getServer().getPluginManager().getPlugin("HeroChat");
|
||||
if(hc != null) {
|
||||
activateHeroChat(hc);
|
||||
}
|
||||
else {
|
||||
/* Set up to hear when HeroChat is enabled */
|
||||
plugin.registerEvent(Event.Type.PLUGIN_ENABLE, new OurPluginListener());
|
||||
DynmapPlugin.plugin.bep.registerEvent(Event.Type.PLUGIN_ENABLE, new OurPluginListener());
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,7 +279,7 @@ public class HeroChatHandler {
|
||||
return;
|
||||
}
|
||||
/* Register event handler */
|
||||
plugin.registerEvent(Event.Type.CUSTOM_EVENT, new OurEventListener());
|
||||
DynmapPlugin.plugin.bep.registerEvent(Event.Type.CUSTOM_EVENT, new OurEventListener());
|
||||
Log.verboseinfo("HeroChat integration active");
|
||||
}
|
||||
/**
|
||||
|
@ -2,29 +2,26 @@ package org.dynmap.herochat;
|
||||
|
||||
import static org.dynmap.JSONUtils.s;
|
||||
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.dynmap.ChatEvent;
|
||||
import org.dynmap.Client;
|
||||
import org.dynmap.Component;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.DynmapWebChatEvent;
|
||||
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 DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||
public HeroWebChatComponent(final DynmapCore plugin, ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
handler = new HeroChatHandler(configuration, plugin, plugin.getServer());
|
||||
handler = new HeroChatHandler(configuration, plugin);
|
||||
plugin.events.addListener("webchat", new Event.Listener<ChatEvent>() {
|
||||
@Override
|
||||
public void triggered(ChatEvent t) {
|
||||
DynmapWebChatEvent evt = new DynmapWebChatEvent(t.source, t.name, t.message);
|
||||
plugin.getServer().getPluginManager().callEvent(evt);
|
||||
if(evt.isCancelled() == false) {
|
||||
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;
|
||||
@ -50,25 +47,22 @@ public class HeroWebChatComponent extends Component {
|
||||
});
|
||||
|
||||
// Also make HeroChat announce joins and quits.
|
||||
PlayerChatListener playerListener = new PlayerChatListener();
|
||||
plugin.registerEvent(org.bukkit.event.Event.Type.PLAYER_LOGIN, playerListener);
|
||||
plugin.registerEvent(org.bukkit.event.Event.Type.PLAYER_JOIN, playerListener);
|
||||
plugin.registerEvent(org.bukkit.event.Event.Type.PLAYER_QUIT, playerListener);
|
||||
}
|
||||
|
||||
protected class PlayerChatListener extends PlayerListener {
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if((plugin.mapManager != null) && (plugin.playerList != null) && (plugin.playerList.isVisiblePlayer(event.getPlayer()))) {
|
||||
plugin.mapManager.pushUpdate(new Client.PlayerJoinMessage(event.getPlayer().getDisplayName(), event.getPlayer().getName()));
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if((plugin.mapManager != null) && (plugin.playerList != null) && (plugin.playerList.isVisiblePlayer(event.getPlayer()))) {
|
||||
plugin.mapManager.pushUpdate(new Client.PlayerQuitMessage(event.getPlayer().getDisplayName(), event.getPlayer().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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,15 @@ package org.dynmap.kzedmap;
|
||||
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.utils.MapIterator;
|
||||
import org.dynmap.utils.MapIterator.BlockStep;
|
||||
|
||||
public class CaveTileRenderer extends DefaultTileRenderer {
|
||||
private boolean iflit;
|
||||
public CaveTileRenderer(ConfigurationNode configuration) {
|
||||
super(configuration);
|
||||
public CaveTileRenderer(DynmapCore core, ConfigurationNode configuration) {
|
||||
super(core, configuration);
|
||||
iflit = configuration.getBoolean("onlyiflit", false);
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,10 @@ import org.dynmap.Client;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ColorScheme;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.DynmapPlugin.CompassMode;
|
||||
import org.dynmap.DynmapCore.CompassMode;
|
||||
import org.dynmap.MapType.ImageFormat;
|
||||
import org.dynmap.TileHashManager;
|
||||
import org.dynmap.debug.Debug;
|
||||
@ -58,7 +59,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
||||
|
||||
public boolean isNightAndDayEnabled() { return night_and_day; }
|
||||
|
||||
public DefaultTileRenderer(ConfigurationNode configuration) {
|
||||
public DefaultTileRenderer(DynmapCore core, ConfigurationNode configuration) {
|
||||
this.configuration = configuration;
|
||||
name = configuration.getString("name", null);
|
||||
prefix = configuration.getString("prefix", name);
|
||||
@ -94,7 +95,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
||||
lightscale[i] = i - (15-v);
|
||||
}
|
||||
}
|
||||
colorScheme = ColorScheme.getScheme((String)configuration.get("colorscheme"));
|
||||
colorScheme = ColorScheme.getScheme(core, (String)configuration.get("colorscheme"));
|
||||
night_and_day = configuration.getBoolean("night-and-day", false);
|
||||
transparency = configuration.getBoolean("transparency", true); /* Default on */
|
||||
String biomeopt = configuration.getString("biomecolored", "none");
|
||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.utils.MapIterator;
|
||||
import org.dynmap.utils.MapIterator.BlockStep;
|
||||
@ -12,8 +13,8 @@ import org.dynmap.utils.MapIterator.BlockStep;
|
||||
public class HighlightTileRenderer extends DefaultTileRenderer {
|
||||
protected HashSet<Integer> highlightBlocks = new HashSet<Integer>();
|
||||
|
||||
public HighlightTileRenderer(ConfigurationNode configuration) {
|
||||
super(configuration);
|
||||
public HighlightTileRenderer(DynmapCore core, ConfigurationNode configuration) {
|
||||
super(core, configuration);
|
||||
List<Integer> highlight = configuration.<Integer>getList("highlight");
|
||||
for(Integer i : highlight) {
|
||||
highlightBlocks.add(i);
|
||||
|
@ -9,6 +9,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
@ -40,9 +41,9 @@ public class KzedMap extends MapType {
|
||||
MapTileRenderer[] renderers;
|
||||
private boolean isbigmap;
|
||||
|
||||
public KzedMap(ConfigurationNode configuration) {
|
||||
public KzedMap(DynmapCore core, ConfigurationNode configuration) {
|
||||
Log.verboseinfo("Loading renderers for map '" + getClass().toString() + "'...");
|
||||
List<MapTileRenderer> renderers = configuration.<MapTileRenderer>createInstances("renderers", new Class<?>[0], new Object[0]);
|
||||
List<MapTileRenderer> renderers = configuration.<MapTileRenderer>createInstances("renderers", new Class<?>[] { DynmapCore.class }, new Object[] { core } );
|
||||
this.renderers = new MapTileRenderer[renderers.size()];
|
||||
renderers.toArray(this.renderers);
|
||||
Log.verboseinfo("Loaded " + renderers.size() + " renderers for map '" + getClass().toString() + "'.");
|
||||
|
@ -20,24 +20,17 @@ import java.util.TreeSet;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
import org.bukkit.util.config.ConfigurationNode;
|
||||
import org.dynmap.Client;
|
||||
import org.dynmap.ClientUpdateEvent;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.Event;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.Client.ComponentMessage;
|
||||
import org.dynmap.Client.PlayerJoinMessage;
|
||||
import org.dynmap.common.DynmapCommandSender;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.markers.AreaMarker;
|
||||
import org.dynmap.markers.Marker;
|
||||
import org.dynmap.markers.MarkerAPI;
|
||||
@ -56,9 +49,8 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
private File markertiledir; /* Marker directory for web server (under tiles) */
|
||||
private HashMap<String, MarkerIconImpl> markericons = new HashMap<String, MarkerIconImpl>();
|
||||
private HashMap<String, MarkerSetImpl> markersets = new HashMap<String, MarkerSetImpl>();
|
||||
private HashMap<String, List<Location>> pointaccum = new HashMap<String, List<Location>>();
|
||||
private Server server;
|
||||
private Plugin dynmap;
|
||||
private HashMap<String, List<DynmapLocation>> pointaccum = new HashMap<String, List<DynmapLocation>>();
|
||||
private DynmapCore core;
|
||||
static MarkerAPIImpl api;
|
||||
|
||||
/* Built-in icons */
|
||||
@ -224,23 +216,22 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
}
|
||||
dirty_worlds.clear();
|
||||
}
|
||||
server.getScheduler().scheduleSyncDelayedTask(dynmap, this, 20);
|
||||
core.getServer().scheduleServerTask(this, 20);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton initializer
|
||||
*/
|
||||
public static MarkerAPIImpl initializeMarkerAPI(DynmapPlugin plugin) {
|
||||
public static MarkerAPIImpl initializeMarkerAPI(DynmapCore core) {
|
||||
if(api != null) {
|
||||
api.cleanup(plugin);
|
||||
api.cleanup(core);
|
||||
}
|
||||
api = new MarkerAPIImpl();
|
||||
api.dynmap = plugin;
|
||||
api.server = plugin.getServer();
|
||||
api.core = core;
|
||||
/* Initialize persistence file name */
|
||||
api.markerpersist = new File(plugin.getDataFolder(), "markers.yml");
|
||||
api.markerpersist_old = new File(plugin.getDataFolder(), "markers.yml.old");
|
||||
api.markerpersist = new File(core.getDataFolder(), "markers.yml");
|
||||
api.markerpersist_old = new File(core.getDataFolder(), "markers.yml.old");
|
||||
/* Fill in default icons and sets, if needed */
|
||||
for(int i = 0; i < builtin_icons.length; i++) {
|
||||
String id = builtin_icons[i];
|
||||
@ -255,13 +246,13 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
}
|
||||
|
||||
/* Build paths for markers */
|
||||
api.markerdir = new File(plugin.getDataFolder(), "markers");
|
||||
api.markerdir = new File(core.getDataFolder(), "markers");
|
||||
if(api.markerdir.isDirectory() == false) {
|
||||
if(api.markerdir.mkdirs() == false) { /* Create directory if needed */
|
||||
Log.severe("Error creating markers directory - " + api.markerdir.getPath());
|
||||
}
|
||||
}
|
||||
api.markertiledir = new File(DynmapPlugin.tilesDirectory, "_markers_");
|
||||
api.markertiledir = new File(core.getTilesFolder(), "_markers_");
|
||||
if(api.markertiledir.isDirectory() == false) {
|
||||
if(api.markertiledir.mkdirs() == false) { /* Create directory if needed */
|
||||
Log.severe("Error creating markers directory - " + api.markertiledir.getPath());
|
||||
@ -274,7 +265,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
/* Freshen files */
|
||||
api.freshenMarkerFiles();
|
||||
/* Add listener so we update marker files for other worlds as they become active */
|
||||
plugin.events.addListener("worldactivated", api);
|
||||
core.events.addListener("worldactivated", api);
|
||||
|
||||
api.scheduleWriteJob(); /* Start write job */
|
||||
|
||||
@ -282,13 +273,13 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
}
|
||||
|
||||
private void scheduleWriteJob() {
|
||||
server.getScheduler().scheduleSyncDelayedTask(dynmap, new DoFileWrites(), 20);
|
||||
core.getServer().scheduleServerTask(new DoFileWrites(), 20);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup
|
||||
*/
|
||||
public void cleanup(DynmapPlugin plugin) {
|
||||
public void cleanup(DynmapCore plugin) {
|
||||
plugin.events.removeListener("worldactivated", api);
|
||||
|
||||
stop = true;
|
||||
@ -589,7 +580,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean processAreaArgs(CommandSender sender, AreaMarker marker, Map<String,String> parms) {
|
||||
private static boolean processAreaArgs(DynmapCommandSender sender, AreaMarker marker, Map<String,String> parms) {
|
||||
String val = null;
|
||||
try {
|
||||
double ytop = marker.getTopY();
|
||||
@ -656,7 +647,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
private static final String ARG_YBOTTOM = "ybottom";
|
||||
|
||||
/* Parse argument strings : handle 'attrib:value' and quoted strings */
|
||||
private static Map<String,String> parseArgs(String[] args, CommandSender snd) {
|
||||
private static Map<String,String> parseArgs(String[] args, DynmapCommandSender snd) {
|
||||
HashMap<String,String> rslt = new HashMap<String,String>();
|
||||
/* Build command line, so we can parse our way - make sure there is trailing space */
|
||||
String cmdline = "";
|
||||
@ -716,9 +707,8 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
|
||||
|
||||
|
||||
public static boolean onCommand(DynmapPlugin plugin, CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
public static boolean onCommand(DynmapCore plugin, DynmapCommandSender sender, String cmd, String commandLabel, String[] args) {
|
||||
String id, setid, file, label, newlabel, iconid, prio, minzoom;
|
||||
String val;
|
||||
|
||||
if(api == null) {
|
||||
sender.sendMessage("Markers component is not enabled.");
|
||||
@ -726,16 +716,16 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
}
|
||||
if(args.length == 0)
|
||||
return false;
|
||||
Player player = null;
|
||||
if (sender instanceof Player)
|
||||
player = (Player) sender;
|
||||
DynmapPlayer player = null;
|
||||
if (sender instanceof DynmapPlayer)
|
||||
player = (DynmapPlayer) sender;
|
||||
/* Check if valid command */
|
||||
String c = args[0];
|
||||
if (!commands.contains(c)) {
|
||||
return false;
|
||||
}
|
||||
/* Process commands */
|
||||
if(c.equals("add") && plugin.checkPlayerPermission(sender, "marker.add")) {
|
||||
if(c.equals("add") && api.core.checkPlayerPermission(sender, "marker.add")) {
|
||||
if(player == null) {
|
||||
sender.sendMessage("Command can only be used by player");
|
||||
}
|
||||
@ -748,7 +738,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
id = parms.get(ARG_ID);
|
||||
label = parms.get(ARG_LABEL);
|
||||
|
||||
Location loc = player.getLocation();
|
||||
DynmapLocation loc = player.getLocation();
|
||||
/* Fill in defaults for missing parameters */
|
||||
if(iconid == null) {
|
||||
iconid = MarkerIcon.DEFAULT;
|
||||
@ -768,7 +758,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
return true;
|
||||
}
|
||||
Marker m = set.createMarker(id, label,
|
||||
loc.getWorld().getName(), loc.getX(), loc.getY(), loc.getZ(), ico, true);
|
||||
loc.world, loc.x, loc.y, loc.z, ico, true);
|
||||
if(m == null) {
|
||||
sender.sendMessage("Error creating marker");
|
||||
}
|
||||
@ -819,8 +809,8 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Location loc = player.getLocation();
|
||||
marker.setLocation(loc.getWorld().getName(), loc.getX(), loc.getY(), loc.getZ());
|
||||
DynmapLocation loc = player.getLocation();
|
||||
marker.setLocation(loc.world, loc.x, loc.y, loc.z);
|
||||
sender.sendMessage("Updated location of marker id:" + marker.getMarkerID() + " (" + marker.getLabel() + ")");
|
||||
}
|
||||
else {
|
||||
@ -1268,7 +1258,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
}
|
||||
/* Add point to accumulator */
|
||||
else if(c.equals("addcorner") && plugin.checkPlayerPermission(sender, "marker.addarea")) {
|
||||
Location loc = null;
|
||||
DynmapLocation loc = null;
|
||||
if(player == null) {
|
||||
id = "-console-";
|
||||
}
|
||||
@ -1276,28 +1266,28 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
id = player.getName();
|
||||
loc = player.getLocation();
|
||||
}
|
||||
List<Location> ll = api.pointaccum.get(id); /* Find list */
|
||||
List<DynmapLocation> ll = api.pointaccum.get(id); /* Find list */
|
||||
|
||||
if(args.length > 2) { /* Enough for coord */
|
||||
World w = null;
|
||||
String w = null;
|
||||
if(args.length == 3) { /* No world */
|
||||
if(ll == null) { /* No points? Error */
|
||||
sender.sendMessage("First added corner needs world ID after coordinates");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
w = ll.get(0).getWorld(); /* Use same world */
|
||||
w = ll.get(0).world; /* Use same world */
|
||||
}
|
||||
}
|
||||
else { /* Get world ID */
|
||||
w = api.server.getWorld(args[3]);
|
||||
if(w == null) {
|
||||
w = args[3];
|
||||
if(api.core.getWorld(w) == null) {
|
||||
sender.sendMessage("Invalid world ID: " + args[3]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
try {
|
||||
loc = new Location(w, Double.parseDouble(args[1]), 64.0, Double.parseDouble(args[2]));
|
||||
loc = new DynmapLocation(w, Double.parseDouble(args[1]), 64.0, Double.parseDouble(args[2]));
|
||||
} catch (NumberFormatException nfx) {
|
||||
sender.sendMessage("Bad format: /dmarker addcorner <x> <z> <world>");
|
||||
return true;
|
||||
@ -1308,16 +1298,16 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
return true;
|
||||
}
|
||||
if(ll == null) {
|
||||
ll = new ArrayList<Location>();
|
||||
ll = new ArrayList<DynmapLocation>();
|
||||
api.pointaccum.put(id, ll);
|
||||
}
|
||||
else { /* Else, if list exists, see if world matches */
|
||||
if(ll.get(0).getWorld().equals(loc.getWorld()) == false) {
|
||||
if(ll.get(0).world.equals(loc.world) == false) {
|
||||
ll.clear(); /* Reset list - point on new world */
|
||||
}
|
||||
}
|
||||
ll.add(loc);
|
||||
sender.sendMessage("Added corner #" + ll.size() + " at {" + loc.getX() + "," + loc.getY() + "," + loc.getZ() + "} to list");
|
||||
sender.sendMessage("Added corner #" + ll.size() + " at {" + loc.x + "," + loc.y + "," + loc.z + "} to list");
|
||||
}
|
||||
else if(c.equals("clearcorners") && plugin.checkPlayerPermission(sender, "marker.addarea")) {
|
||||
if(player == null) {
|
||||
@ -1337,7 +1327,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
else {
|
||||
pid = player.getName();
|
||||
}
|
||||
List<Location> ll = api.pointaccum.get(pid); /* Find list */
|
||||
List<DynmapLocation> ll = api.pointaccum.get(pid); /* Find list */
|
||||
if((ll == null) || (ll.size() < 2)) { /* Not enough points? */
|
||||
sender.sendMessage("At least two corners must be added with /dmarker addcorner before an area can be added");
|
||||
return true;
|
||||
@ -1362,12 +1352,12 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
double[] xx = new double[ll.size()];
|
||||
double[] zz = new double[ll.size()];
|
||||
for(int i = 0; i < ll.size(); i++) {
|
||||
Location loc = ll.get(i);
|
||||
xx[i] = loc.getX();
|
||||
zz[i] = loc.getZ();
|
||||
DynmapLocation loc = ll.get(i);
|
||||
xx[i] = loc.x;
|
||||
zz[i] = loc.z;
|
||||
}
|
||||
/* Make area marker */
|
||||
AreaMarker m = set.createAreaMarker(id, label, false, ll.get(0).getWorld().getName(), xx, zz, true);
|
||||
AreaMarker m = set.createAreaMarker(id, label, false, ll.get(0).world, xx, zz, true);
|
||||
if(m == null) {
|
||||
sender.sendMessage("Error creating area");
|
||||
}
|
||||
|
@ -2,20 +2,11 @@ package org.dynmap.markers.impl;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.common.DynmapChatColor;
|
||||
import org.dynmap.common.DynmapListenerManager;
|
||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.markers.Marker;
|
||||
import org.dynmap.markers.MarkerIcon;
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
@ -23,34 +14,35 @@ import org.dynmap.markers.MarkerSet;
|
||||
public class MarkerSignManager {
|
||||
|
||||
private static MarkerSignManager mgr = null;
|
||||
private static DynmapPlugin plugin = null;
|
||||
private static DynmapCore plugin = null;
|
||||
|
||||
private static class SignListener extends BlockListener {
|
||||
private static final int SIGNPOST_ID = 63;
|
||||
private static final int WALLSIGN_ID = 68;
|
||||
|
||||
private static class SignListener implements DynmapListenerManager.BlockEventListener, DynmapListenerManager.SignChangeEventListener {
|
||||
@Override
|
||||
public void onSignChange(SignChangeEvent evt) {
|
||||
if(evt.isCancelled() || (mgr == null))
|
||||
public void signChangeEvent(int blkid, String wname, int x, int y, int z, String[] lines, DynmapPlayer p) {
|
||||
if(mgr == null)
|
||||
return;
|
||||
if(!evt.getLine(0).equalsIgnoreCase("[dynmap]")) { /* If not dynmap sign, quit */
|
||||
if(!lines[0].equalsIgnoreCase("[dynmap]")) { /* If not dynmap sign, quit */
|
||||
return;
|
||||
}
|
||||
Player p = evt.getPlayer();
|
||||
/* If allowed to do marker signs */
|
||||
if((p == null) || ((plugin != null) && (plugin.checkPlayerPermission(p, "marker.sign")))) {
|
||||
Location loc = evt.getBlock().getLocation();
|
||||
String id = getSignMarkerID(loc); /* Get marker ID */
|
||||
String id = getSignMarkerID(wname, x, y, z); /* Get marker ID */
|
||||
String set = MarkerSet.DEFAULT;
|
||||
String icon = MarkerIcon.SIGN;
|
||||
String label = "";
|
||||
evt.setLine(0, ""); /* Blank out [dynmap] */
|
||||
lines[0] = ""; /* Blank out [dynmap] */
|
||||
for(int i = 1; i < 4; i++) { /* Check other lines for icon: or set: */
|
||||
String v = ChatColor.stripColor(evt.getLine(i));
|
||||
String v = plugin.getServer().stripChatColor(lines[i]);
|
||||
if(v.startsWith("icon:")) { /* icon: */
|
||||
icon = v.substring(5);
|
||||
evt.setLine(i, "");
|
||||
lines[i] = "";
|
||||
}
|
||||
else if(v.startsWith("set:")) { /* set: */
|
||||
set = v.substring(4);
|
||||
evt.setLine(i, "");
|
||||
lines[i] = "";
|
||||
}
|
||||
else if(v.length() > 0) {
|
||||
if(label.length() > 0) {
|
||||
@ -63,13 +55,13 @@ public class MarkerSignManager {
|
||||
MarkerSet ms = MarkerAPIImpl.api.getMarkerSet(set);
|
||||
if(ms == null) {
|
||||
if(p != null) p.sendMessage("Bad marker set - [dynmap] sign invalid");
|
||||
evt.setLine(0, ChatColor.RED + "<Bad Marker Set>");
|
||||
lines[0] = DynmapChatColor.RED + "<Bad Marker Set>";
|
||||
return;
|
||||
}
|
||||
MarkerIcon mi = MarkerAPIImpl.api.getMarkerIcon(icon); /* Get icon */
|
||||
if(mi == null) {
|
||||
if(p != null) p.sendMessage("Bad marker icon - [dynmap] sign invalid");
|
||||
evt.setLine(0, ChatColor.RED + "<Bad Marker Icon>");
|
||||
lines[0] = DynmapChatColor.RED + "<Bad Marker Icon>";
|
||||
return;
|
||||
}
|
||||
Marker marker = ms.findMarker(id);
|
||||
@ -79,25 +71,22 @@ public class MarkerSignManager {
|
||||
marker.setMarkerIcon(mi);
|
||||
}
|
||||
else { /* Make new marker */
|
||||
marker = ms.createMarker(id, label, true, loc.getWorld().getName(), loc.getX() + 0.5, loc.getY() + 0.5, loc.getZ() + 0.5,
|
||||
marker = ms.createMarker(id, label, true, wname, (double)x + 0.5, (double)y + 0.5, (double)z + 0.5,
|
||||
mi, true);
|
||||
if(marker == null) {
|
||||
if(p != null) p.sendMessage("Bad marker - [dynmap] sign invalid");
|
||||
evt.setLine(0, ChatColor.RED + "<Bad Marker>");
|
||||
lines[0] = DynmapChatColor.RED + "<Bad Marker>";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent evt) {
|
||||
if(evt.isCancelled() || (mgr == null))
|
||||
public void blockEvent(int blkid, String wname, int x, int y, int z) {
|
||||
if(mgr == null)
|
||||
return;
|
||||
Block blk = evt.getBlock();
|
||||
Material m = blk.getType();
|
||||
if((m == Material.SIGN) || (m == Material.SIGN_POST) || (m == Material.WALL_SIGN)) { /* If sign */
|
||||
Location loc = blk.getLocation();
|
||||
String id = getSignMarkerID(loc); /* Marker sign? */
|
||||
if((blkid == WALLSIGN_ID) || (blkid == SIGNPOST_ID)) { /* If sign */
|
||||
String id = getSignMarkerID(wname, x, y, z); /* Marker sign? */
|
||||
Set<MarkerSet> sets = MarkerAPIImpl.api.getMarkerSets();
|
||||
for(MarkerSet ms : sets) {
|
||||
Marker marker = ms.findMarker(id); /* See if in this set */
|
||||
@ -118,22 +107,21 @@ public class MarkerSignManager {
|
||||
return v;
|
||||
}
|
||||
|
||||
public static MarkerSignManager initializeSignManager(DynmapPlugin plugin) {
|
||||
public static MarkerSignManager initializeSignManager(DynmapCore plugin) {
|
||||
mgr = new MarkerSignManager();
|
||||
if(sl == null) {
|
||||
sl = new SignListener();
|
||||
PluginManager pm = plugin.getServer().getPluginManager();
|
||||
pm.registerEvent(Event.Type.BLOCK_BREAK, sl, Event.Priority.Monitor, plugin);
|
||||
pm.registerEvent(Event.Type.SIGN_CHANGE, sl, Event.Priority.Low, plugin);
|
||||
plugin.listenerManager.addListener(EventType.BLOCK_BREAK, sl);
|
||||
plugin.listenerManager.addListener(EventType.SIGN_CHANGE, sl);
|
||||
}
|
||||
MarkerSignManager.plugin = plugin;
|
||||
return mgr;
|
||||
}
|
||||
public static void terminateSignManager(DynmapPlugin plugin) {
|
||||
public static void terminateSignManager(DynmapCore plugin) {
|
||||
mgr = null;
|
||||
}
|
||||
|
||||
private static String getSignMarkerID(Location loc) {
|
||||
return "_sign_" + loc.getWorld().getName() + "_" + loc.getBlockX() + "_" + loc.getBlockY() + "_" + loc.getBlockZ();
|
||||
private static String getSignMarkerID(String wname, int x, int y, int z) {
|
||||
return "_sign_" + wname + "_" + x + "_" + y + "_" + z;
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,14 @@ package org.dynmap.regions;
|
||||
|
||||
import org.dynmap.Component;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.Log;
|
||||
|
||||
public class RegionsComponent extends Component {
|
||||
private static String deprecated_ids[] = { "Residence", "Factions", "Towny", "WorldGuard" };
|
||||
private static String deprecated_new_plugins[] = { "dynmap-residence", "Dynmap-Factions", "Dynmap-Towny", "Dynmap-WorldGuard" };
|
||||
|
||||
public RegionsComponent(final DynmapPlugin plugin, final ConfigurationNode configuration) {
|
||||
public RegionsComponent(final DynmapCore plugin, final ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
|
||||
String regiontype = configuration.getString("name", "WorldGuard");
|
||||
|
@ -8,18 +8,18 @@ import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.Event;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class ClientConfigurationServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 9106801553080522469L;
|
||||
private DynmapPlugin plugin;
|
||||
private DynmapCore plugin;
|
||||
private byte[] cachedConfiguration = null;
|
||||
private int cached_config_hashcode = 0;
|
||||
|
||||
public ClientConfigurationServlet(DynmapPlugin plugin) {
|
||||
public ClientConfigurationServlet(DynmapCore plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.events.addListener("worldactivated", new Event.Listener<DynmapWorld>() {
|
||||
@Override
|
||||
|
@ -13,16 +13,16 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.dynmap.ClientUpdateEvent;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.web.HttpField;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class ClientUpdateServlet extends HttpServlet {
|
||||
private DynmapPlugin plugin;
|
||||
private DynmapCore plugin;
|
||||
|
||||
public ClientUpdateServlet(DynmapPlugin plugin) {
|
||||
public ClientUpdateServlet(DynmapCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.dynmap.servlet;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.Event;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.web.HttpStatus;
|
||||
@ -40,7 +39,7 @@ public class SendMessageServlet extends HttpServlet {
|
||||
public boolean use_player_login_ip = false;
|
||||
public boolean require_player_login_ip = false;
|
||||
public boolean check_user_ban = false;
|
||||
public DynmapPlugin plug_in;
|
||||
public DynmapCore plug_in;
|
||||
|
||||
|
||||
@Override
|
||||
@ -77,8 +76,7 @@ public class SendMessageServlet extends HttpServlet {
|
||||
if (ids != null) {
|
||||
String id = ids.get(0);
|
||||
if (check_user_ban) {
|
||||
OfflinePlayer p = plug_in.getServer().getOfflinePlayer(id);
|
||||
if ((p != null) && p.isBanned()) {
|
||||
if (plug_in.getServer().isPlayerBanned(id)) {
|
||||
Log.info("Ignore message from '" + message.name + "' - banned player (" + id + ")");
|
||||
response.sendError(HttpStatus.Forbidden.getCode());
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: dynmap
|
||||
main: org.dynmap.DynmapPlugin
|
||||
main: org.dynmap.bukkit.DynmapPlugin
|
||||
version: "${project.version}-${BUILD_NUMBER}"
|
||||
authors: [FrozenCow, mikeprimm]
|
||||
softdepend: [ Permissions, PermissionEx, bPermissions, PermissionsBukkit]
|
||||
|
Loading…
Reference in New Issue
Block a user