mirror of
https://github.com/encounter/dynmap.git
synced 2026-03-30 11:08:39 -07:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07f2496f2f | |||
| 2f6e52261c | |||
| a117987840 | |||
| cbb8cc061e | |||
| c03365d574 | |||
| 827f18b8e0 | |||
| 1603015631 | |||
| c2d97ba3d5 | |||
| 418b175923 | |||
| fdc14b413d | |||
| e6d509c3e6 | |||
| b10ec3a331 | |||
| 9f8617d81d | |||
| 265e037b74 | |||
| f50e73180c | |||
| aad4b64603 | |||
| aeeb09f600 |
@@ -2,7 +2,6 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<artifactId>dynmap</artifactId>
|
||||
<version>0.70.2</version>
|
||||
<name>dynmap</name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@@ -185,4 +184,5 @@
|
||||
<version>1.2.5-R5.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<version>1.0</version>
|
||||
</project>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -9,6 +12,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -47,6 +51,7 @@ import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.world.ChunkPopulateEvent;
|
||||
import org.bukkit.event.world.SpawnChangeEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
@@ -68,6 +73,7 @@ import org.dynmap.DynmapWebChatEvent;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.MapType;
|
||||
import org.dynmap.PlayerList;
|
||||
import org.dynmap.bukkit.permissions.BukkitPermissions;
|
||||
import org.dynmap.bukkit.permissions.NijikokunPermissions;
|
||||
@@ -81,6 +87,7 @@ import org.dynmap.common.DynmapCommandSender;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.common.DynmapServerInterface;
|
||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
import org.dynmap.hdmap.HDMap;
|
||||
import org.dynmap.markers.MarkerAPI;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
|
||||
@@ -95,7 +102,42 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
public static DynmapPlugin plugin;
|
||||
public SpoutPluginBlocks spb;
|
||||
public PluginManager pm;
|
||||
private Metrics metrics;
|
||||
private BukkitEnableCoreCallback enabCoreCB = new BukkitEnableCoreCallback();
|
||||
private Method ismodloaded;
|
||||
private HashMap<String, BukkitWorld> world_by_name = new HashMap<String, BukkitWorld>();
|
||||
/* Lookup cache */
|
||||
private World last_world;
|
||||
private BukkitWorld last_bworld;
|
||||
|
||||
private final BukkitWorld getWorldByName(String name) {
|
||||
if((last_world != null) && (last_world.getName().equals(name))) {
|
||||
return last_bworld;
|
||||
}
|
||||
return world_by_name.get(name);
|
||||
}
|
||||
private final BukkitWorld getWorld(World w) {
|
||||
if(last_world == w) {
|
||||
return last_bworld;
|
||||
}
|
||||
BukkitWorld bw = world_by_name.get(w.getName());
|
||||
if(bw == null) {
|
||||
bw = new BukkitWorld(w);
|
||||
world_by_name.put(w.getName(), bw);
|
||||
}
|
||||
last_world = w;
|
||||
last_bworld = bw;
|
||||
|
||||
return bw;
|
||||
}
|
||||
private final void removeWorld(World w) {
|
||||
world_by_name.remove(w.getName());
|
||||
if(w == last_world) {
|
||||
last_world = null;
|
||||
last_bworld = null;
|
||||
}
|
||||
}
|
||||
|
||||
private class BukkitEnableCoreCallback extends DynmapCore.EnableCoreCallbacks {
|
||||
@Override
|
||||
public void configurationLoaded() {
|
||||
@@ -104,8 +146,9 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
if(core.configuration.getBoolean("spout/enabled", true)) {
|
||||
has_spout = true;
|
||||
Log.info("Detected Spout");
|
||||
spb = new SpoutPluginBlocks();
|
||||
spb.processSpoutBlocks(DynmapPlugin.this, core);
|
||||
if(spb == null) {
|
||||
spb = new SpoutPluginBlocks(DynmapPlugin.this);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.info("Detected Spout - Support Disabled");
|
||||
@@ -131,6 +174,12 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
|
||||
public DynmapPlugin() {
|
||||
plugin = this;
|
||||
try {
|
||||
Class<?> c = Class.forName("cpw.mods.fml.common.Loader");
|
||||
ismodloaded = c.getMethod("isModLoaded", String.class);
|
||||
} catch (NoSuchMethodException nsmx) {
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +254,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
pm.registerEvents(new Listener() {
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onSpawnChange(SpawnChangeEvent evt) {
|
||||
DynmapWorld w = new BukkitWorld(evt.getWorld());
|
||||
DynmapWorld w = getWorld(evt.getWorld());
|
||||
core.listenerManager.processWorldEvent(EventType.WORLD_SPAWN_CHANGE, w);
|
||||
}
|
||||
}, DynmapPlugin.this);
|
||||
@@ -264,7 +313,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
if(b == null) return; /* Work around for stupid mods.... */
|
||||
Location l = b.getLocation();
|
||||
core.listenerManager.processBlockEvent(EventType.BLOCK_BREAK, b.getType().getId(),
|
||||
BukkitWorld.normalizeWorldName(l.getWorld().getName()), l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
getWorld(l.getWorld()).getName(), l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
}
|
||||
}, DynmapPlugin.this);
|
||||
break;
|
||||
@@ -280,7 +329,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
Player p = evt.getPlayer();
|
||||
if(p != null) dp = new BukkitPlayer(p);
|
||||
core.listenerManager.processSignChangeEvent(EventType.SIGN_CHANGE, b.getType().getId(),
|
||||
BukkitWorld.normalizeWorldName(l.getWorld().getName()), l.getBlockX(), l.getBlockY(), l.getBlockZ(), lines, dp);
|
||||
getWorld(l.getWorld()).getName(), l.getBlockX(), l.getBlockY(), l.getBlockZ(), lines, dp);
|
||||
}
|
||||
}, DynmapPlugin.this);
|
||||
break;
|
||||
@@ -319,11 +368,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
}
|
||||
@Override
|
||||
public DynmapWorld getWorldByName(String wname) {
|
||||
World w = getServer().getWorld(wname); /* FInd world */
|
||||
if(w != null) {
|
||||
return new BukkitWorld(w);
|
||||
}
|
||||
return null;
|
||||
return DynmapPlugin.this.getWorldByName(wname);
|
||||
}
|
||||
@Override
|
||||
public DynmapPlayer getOfflinePlayer(String name) {
|
||||
@@ -407,6 +452,8 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
Boolean delay;
|
||||
try {
|
||||
delay = f.get();
|
||||
} catch (CancellationException cx) {
|
||||
return null;
|
||||
} catch (Exception ix) {
|
||||
Log.severe(ix);
|
||||
return null;
|
||||
@@ -425,6 +472,23 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
public int getCurrentPlayers() {
|
||||
return getServer().getOnlinePlayers().length;
|
||||
}
|
||||
@Override
|
||||
public boolean isModLoaded(String name) {
|
||||
if(ismodloaded != null) {
|
||||
try {
|
||||
Object rslt =ismodloaded.invoke(null, name);
|
||||
if(rslt instanceof Boolean) {
|
||||
if(((Boolean)rslt).booleanValue()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException iax) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Player access abstraction class
|
||||
@@ -476,7 +540,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
}
|
||||
World w = player.getWorld();
|
||||
if(w != null)
|
||||
return BukkitWorld.normalizeWorldName(w.getName());
|
||||
return DynmapPlugin.this.getWorld(w).getName();
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
@@ -611,8 +675,46 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
core.setDataFolder(dataDirectory);
|
||||
core.setServer(new BukkitServer());
|
||||
|
||||
/* Load configuration */
|
||||
if(!core.initConfiguration(enabCoreCB)) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
/* See if we need to wait before enabling core */
|
||||
if(!readyToEnable()) {
|
||||
Listener pl = new Listener() {
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onPluginEnabled(PluginEnableEvent evt) {
|
||||
if (!readyToEnable()) {
|
||||
spb.markPluginEnabled(evt.getPlugin());
|
||||
if (readyToEnable()) { /* If we;re ready now, finish enable */
|
||||
doEnable(); /* Finish enable */
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
pm.registerEvents(pl, this);
|
||||
}
|
||||
else {
|
||||
doEnable();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean readyToEnable() {
|
||||
if (spb != null) {
|
||||
return spb.isReady();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void doEnable() {
|
||||
/* Prep spout support, if needed */
|
||||
if(spb != null) {
|
||||
spb.processSpoutBlocks(this, core);
|
||||
}
|
||||
|
||||
/* Enable core */
|
||||
if(!core.enableCore(new BukkitEnableCoreCallback())) {
|
||||
if(!core.enableCore(enabCoreCB)) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
@@ -623,7 +725,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
mapManager = core.getMapManager();
|
||||
/* Initialized the currently loaded worlds */
|
||||
for (World world : getServer().getWorlds()) {
|
||||
BukkitWorld w = new BukkitWorld(world);
|
||||
BukkitWorld w = getWorld(world);
|
||||
if(core.processWorldLoad(w)) /* Have core process load first - fire event listeners if good load after */
|
||||
core.listenerManager.processWorldEvent(EventType.WORLD_LOAD, w);
|
||||
}
|
||||
@@ -631,11 +733,18 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
/* Register our update trigger events */
|
||||
registerEvents();
|
||||
|
||||
/* Submit metrics to mcstats.org */
|
||||
initMetrics();
|
||||
|
||||
Log.info("Enabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (metrics != null) {
|
||||
metrics = null;
|
||||
}
|
||||
|
||||
/* Disable core */
|
||||
core.disableCore();
|
||||
|
||||
@@ -737,7 +846,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
int x0 = l0.getBlockX(), y0 = l0.getBlockY(), z0 = l0.getBlockZ();
|
||||
int x1 = l1.getBlockX(), y1 = l1.getBlockY(), z1 = l1.getBlockZ();
|
||||
|
||||
return core.triggerRenderOfVolume(BukkitWorld.normalizeWorldName(l0.getWorld().getName()), Math.min(x0, x1), Math.min(y0, y1),
|
||||
return core.triggerRenderOfVolume(getWorld(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));
|
||||
}
|
||||
|
||||
@@ -800,7 +909,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
if(bt == 9) bt = 8;
|
||||
if(btt.typeid == 9) btt.typeid = 8;
|
||||
if((bt != btt.typeid) || (btt.data != w.getBlockAt(loc).getData())) {
|
||||
String wn = BukkitWorld.normalizeWorldName(w.getName());
|
||||
String wn = getWorld(w).getName();
|
||||
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), btt.trigger);
|
||||
}
|
||||
@@ -870,7 +979,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockplace");
|
||||
}
|
||||
@@ -887,7 +996,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
Block b = event.getBlock();
|
||||
if(b == null) return; /* Stupid mod workaround */
|
||||
Location loc = b.getLocation();
|
||||
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockbreak");
|
||||
}
|
||||
@@ -902,7 +1011,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onleaves) {
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "leavesdecay");
|
||||
@@ -919,7 +1028,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onburn) {
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockburn");
|
||||
@@ -988,7 +1097,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
} catch (ClassCastException ccx) {
|
||||
dir = BlockFace.NORTH;
|
||||
}
|
||||
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
int x = loc.getBlockX(), y = loc.getBlockY(), z = loc.getBlockZ();
|
||||
sscache.invalidateSnapshot(wn, x, y, z);
|
||||
if(onpiston)
|
||||
@@ -1014,7 +1123,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
} catch (ClassCastException ccx) {
|
||||
dir = BlockFace.NORTH;
|
||||
}
|
||||
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
int x = loc.getBlockX(), y = loc.getBlockY(), z = loc.getBlockZ();
|
||||
sscache.invalidateSnapshot(wn, x, y, z);
|
||||
if(onpiston)
|
||||
@@ -1038,7 +1147,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockspread");
|
||||
}
|
||||
@@ -1053,7 +1162,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockform");
|
||||
}
|
||||
@@ -1068,7 +1177,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockfade");
|
||||
}
|
||||
@@ -1087,7 +1196,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockgrow");
|
||||
}
|
||||
@@ -1103,7 +1212,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onBlockRedstone(BlockRedstoneEvent event) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockredstone");
|
||||
}
|
||||
@@ -1117,7 +1226,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if(onplayerjoin) {
|
||||
Location loc = event.getPlayer().getLocation();
|
||||
mapManager.touch(BukkitWorld.normalizeWorldName(loc.getWorld().getName()), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "playerjoin");
|
||||
mapManager.touch(getWorld(loc.getWorld()).getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "playerjoin");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1131,7 +1240,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Location loc = event.getPlayer().getLocation();
|
||||
mapManager.touch(BukkitWorld.normalizeWorldName(loc.getWorld().getName()), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "playermove");
|
||||
mapManager.touch(getWorld(loc.getWorld()).getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "playermove");
|
||||
}
|
||||
};
|
||||
pm.registerEvents(playermove, this);
|
||||
@@ -1142,7 +1251,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
Location loc = event.getLocation();
|
||||
String wname = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wname = getWorld(loc.getWorld()).getName();
|
||||
int minx, maxx, miny, maxy, minz, maxz;
|
||||
minx = maxx = loc.getBlockX();
|
||||
miny = maxy = loc.getBlockY();
|
||||
@@ -1175,21 +1284,21 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
core.updateConfigHashcode();
|
||||
BukkitWorld w = new BukkitWorld(event.getWorld());
|
||||
BukkitWorld w = getWorld(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);
|
||||
}
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
core.updateConfigHashcode();
|
||||
DynmapWorld w = core.getWorld(BukkitWorld.normalizeWorldName(event.getWorld().getName()));
|
||||
if(w != null)
|
||||
core.listenerManager.processWorldEvent(EventType.WORLD_UNLOAD, w);
|
||||
DynmapWorld w = getWorld(event.getWorld());
|
||||
core.listenerManager.processWorldEvent(EventType.WORLD_UNLOAD, w);
|
||||
removeWorld(event.getWorld());
|
||||
}
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onStructureGrow(StructureGrowEvent event) {
|
||||
Location loc = event.getLocation();
|
||||
String wname = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
String wname = getWorld(loc.getWorld()).getName();
|
||||
int minx, maxx, miny, maxy, minz, maxz;
|
||||
minx = maxx = loc.getBlockX();
|
||||
miny = maxy = loc.getBlockY();
|
||||
@@ -1226,7 +1335,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
/* Touch extreme corners */
|
||||
int x = c.getX() << 4;
|
||||
int z = c.getZ() << 4;
|
||||
mapManager.touchVolume(BukkitWorld.normalizeWorldName(event.getWorld().getName()), x, 0, z, x+15, 128, z+16, "chunkpopulate");
|
||||
mapManager.touchVolume(getWorld(event.getWorld()).getName(), x, 0, z, x+15, 128, z+16, "chunkpopulate");
|
||||
}
|
||||
};
|
||||
pm.registerEvents(chunkTrigger, this);
|
||||
@@ -1280,4 +1389,86 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
public boolean testIfPlayerInfoProtected() {
|
||||
return core.testIfPlayerInfoProtected();
|
||||
}
|
||||
|
||||
private void initMetrics() {
|
||||
try {
|
||||
metrics = new Metrics(this);
|
||||
|
||||
Metrics.Graph features = metrics.createGraph("Features Used");
|
||||
|
||||
features.addPlotter(new Metrics.Plotter("Internal Web Server") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
if (!core.configuration.getBoolean("disable-webserver", false))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
features.addPlotter(new Metrics.Plotter("Spout") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
if(plugin.has_spout)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
features.addPlotter(new Metrics.Plotter("Login Security") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
if(core.configuration.getBoolean("login-enabled", false))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
features.addPlotter(new Metrics.Plotter("Player Info Protected") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
if(core.player_info_protected)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
Metrics.Graph maps = metrics.createGraph("Map Data");
|
||||
maps.addPlotter(new Metrics.Plotter("Worlds") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
if(core.mapManager != null)
|
||||
return core.mapManager.getWorlds().size();
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
maps.addPlotter(new Metrics.Plotter("Maps") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
int cnt = 0;
|
||||
if(core.mapManager != null) {
|
||||
for(DynmapWorld w :core.mapManager.getWorlds()) {
|
||||
cnt += w.maps.size();
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
});
|
||||
maps.addPlotter(new Metrics.Plotter("HD Maps") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
int cnt = 0;
|
||||
if(core.mapManager != null) {
|
||||
for(DynmapWorld w :core.mapManager.getWorlds()) {
|
||||
for(MapType mt : w.maps) {
|
||||
if(mt instanceof HDMap) {
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
});
|
||||
metrics.start();
|
||||
} catch (IOException e) {
|
||||
// Failed to submit the stats :-(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,15 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import net.minecraft.server.ChunkProviderServer;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.Biome;
|
||||
@@ -28,6 +33,8 @@ import org.getspout.spoutapi.block.SpoutChunk;
|
||||
public class NewMapChunkCache implements MapChunkCache {
|
||||
private static boolean init = false;
|
||||
private static boolean use_spout = false;
|
||||
private static Field unloadqueue = null;
|
||||
private static Method queuecontainskey = null;
|
||||
|
||||
private World w;
|
||||
private DynmapWorld dw;
|
||||
@@ -659,6 +666,21 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
if(!init) {
|
||||
use_spout = DynmapPlugin.plugin.hasSpout();
|
||||
|
||||
try {
|
||||
unloadqueue = ChunkProviderServer.class.getField("unloadQueue");
|
||||
Class cls = unloadqueue.getType();
|
||||
String nm = cls.getName();
|
||||
if (nm.equals("org.bukkit.craftbukkit.util.LongHashset")) {
|
||||
queuecontainskey = unloadqueue.getType().getMethod("containsKey", new Class[] { int.class, int.class });
|
||||
}
|
||||
else {
|
||||
unloadqueue = null;
|
||||
}
|
||||
} catch (NoSuchFieldException nsfx) {
|
||||
unloadqueue = null;
|
||||
} catch (NoSuchMethodException nsmx) {
|
||||
unloadqueue = null;
|
||||
}
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
@@ -709,7 +731,14 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
public int loadChunks(int max_to_load) {
|
||||
long t0 = System.nanoTime();
|
||||
CraftWorld cw = (CraftWorld)w;
|
||||
LongHashset unloadqueue = cw.getHandle().chunkProviderServer.unloadQueue;
|
||||
Object queue = null;
|
||||
try {
|
||||
if (unloadqueue != null) {
|
||||
queue = unloadqueue.get(cw.getHandle().chunkProviderServer);
|
||||
}
|
||||
} catch (IllegalArgumentException iax) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
int cnt = 0;
|
||||
if(iterator == null)
|
||||
iterator = chunks.listIterator();
|
||||
@@ -754,7 +783,15 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
chunks_attempted++;
|
||||
boolean wasLoaded = w.isChunkLoaded(chunk.x, chunk.z);
|
||||
boolean didload = false;
|
||||
boolean isunloadpending = unloadqueue.containsKey(chunk.x, chunk.z);
|
||||
boolean isunloadpending = false;
|
||||
if (queue != null) {
|
||||
try {
|
||||
isunloadpending = (Boolean)queuecontainskey.invoke(queue, chunk.x, chunk.z);
|
||||
} catch (IllegalAccessException iax) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
}
|
||||
if (isunloadpending) { /* Workaround: can't be pending if not loaded */
|
||||
wasLoaded = true;
|
||||
}
|
||||
@@ -877,45 +914,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
snaparray = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get block ID at coordinates
|
||||
*/
|
||||
public int getBlockTypeID(int x, int y, int z) {
|
||||
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||
return ss.getBlockTypeId(x & 0xF, y, z & 0xF);
|
||||
}
|
||||
/**
|
||||
* Get block data at coordiates
|
||||
*/
|
||||
public byte getBlockData(int x, int y, int z) {
|
||||
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||
return (byte)ss.getBlockData(x & 0xF, y, z & 0xF);
|
||||
}
|
||||
/* Get sky light level
|
||||
*/
|
||||
public int getBlockSkyLight(int x, int y, int z) {
|
||||
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||
return ss.getBlockSkyLight(x & 0xF, y, z & 0xF);
|
||||
}
|
||||
/* Get emitted light level
|
||||
*/
|
||||
public int getBlockEmittedLight(int x, int y, int z) {
|
||||
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||
return ss.getBlockEmittedLight(x & 0xF, y, z & 0xF);
|
||||
}
|
||||
public BiomeMap getBiome(int x, int z) {
|
||||
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||
Biome b = ss.getBiome(x & 0xF, z & 0xF);
|
||||
return (b != null)?biome_to_bmap[b.ordinal()]:null;
|
||||
}
|
||||
public double getRawBiomeTemperature(int x, int z) {
|
||||
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||
return ss.getRawBiomeTemperature(x & 0xF, z & 0xF);
|
||||
}
|
||||
public double getRawBiomeRainfall(int x, int z) {
|
||||
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||
return ss.getRawBiomeRainfall(x & 0xF, z & 0xF);
|
||||
}
|
||||
private void initSectionData(int idx) {
|
||||
isSectionNotEmpty[idx] = new boolean[nsect + 1];
|
||||
if(snaparray[idx] != EMPTY) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
@@ -33,7 +34,29 @@ import org.getspout.spoutapi.material.MaterialData;
|
||||
public class SpoutPluginBlocks {
|
||||
private Field textXPosField; /* float[][] textXPos */
|
||||
private Field textYPosField; /* float[][] textYPos */
|
||||
|
||||
private HashSet<String> plugins_pending = new HashSet<String>();
|
||||
|
||||
public SpoutPluginBlocks(Plugin plugin) {
|
||||
/* First, see if any spout plugins that need to be enabled */
|
||||
for(Plugin p : plugin.getServer().getPluginManager().getPlugins()) {
|
||||
List<String> dep = p.getDescription().getDepend();
|
||||
if((dep != null) && (dep.contains("Spout"))) {
|
||||
Log.info("Found Spout plugin: " + p.getName());
|
||||
if(p.isEnabled() == false) {
|
||||
plugins_pending.add(p.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
return plugins_pending.isEmpty();
|
||||
}
|
||||
|
||||
public void markPluginEnabled(Plugin p) {
|
||||
plugins_pending.remove(p.getName());
|
||||
}
|
||||
|
||||
private boolean initSpoutAccess() {
|
||||
boolean success = false;
|
||||
try {
|
||||
@@ -73,17 +96,6 @@ public class SpoutPluginBlocks {
|
||||
|
||||
/* Process spout blocks - return true if something changed */
|
||||
public boolean processSpoutBlocks(DynmapPlugin plugin, DynmapCore core) {
|
||||
/* First, see if any spout plugins that need to be enabled */
|
||||
for(Plugin p : plugin.getServer().getPluginManager().getPlugins()) {
|
||||
List<String> dep = p.getDescription().getDepend();
|
||||
if((dep != null) && (dep.contains("Spout"))) {
|
||||
Log.info("Found Spout plugin: " + p.getName());
|
||||
if(p.isEnabled() == false) {
|
||||
plugin.getPluginLoader().enablePlugin(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File datadir = core.getDataFolder();
|
||||
if(textYPosField == null) {
|
||||
if(initSpoutAccess() == false)
|
||||
|
||||
@@ -218,37 +218,6 @@ skin-url: "http://s3.amazonaws.com/MinecraftSkins/%player%.png"
|
||||
# 'newnorth' is used to rotate maps and rose (requires fullrender of any HDMap map - same as 'newrose' for FlatMap or KzedMap)
|
||||
compass-mode: newnorth
|
||||
|
||||
### Mod block support ###
|
||||
# Enable Industrial Craft 2 block rendering support (core, Advanced Machines, Charging Bench, Power Converters, Compact Solars, Nuclear Control)
|
||||
#ic2-support: true
|
||||
#ic2-advancesmachines-support: true
|
||||
#ic2-chargingbench-support: true
|
||||
#ic2-powerconverters-support: true
|
||||
#ic2-compactsolars-support: true
|
||||
#ic2-nuclearcontrol-support: true
|
||||
# Enable BuildCraft block rendering support
|
||||
#buildcraft-support: true
|
||||
# Enable RedPower2 block rendering support
|
||||
#redpower2-support: true
|
||||
# Enable NetherOres block rendering support
|
||||
#netherores-support: true
|
||||
# Enable RailCraft block rendering support
|
||||
#railcraft-support: true
|
||||
# Enable Kaevator's Superslopes block rendering support
|
||||
#superslopes-support: true
|
||||
# Enabled ComputerCraft block rendering support
|
||||
#computercraft-support: true
|
||||
# Enabled LC Trees++ block rendering support
|
||||
#lctrees-support: true
|
||||
# Enable Forestry block rending support
|
||||
#forestry-support: true
|
||||
# Enable IronCheck block rendering support
|
||||
#ironchest-support: true
|
||||
# Enable TubeCraft block rendering support
|
||||
#tubecraft-support: true
|
||||
# Enable Ender Storage block rendering support
|
||||
#enderstorage-support: true
|
||||
|
||||
render-triggers:
|
||||
#- playermove
|
||||
#- playerjoin
|
||||
|
||||
Reference in New Issue
Block a user