mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-09-28 05:37:27 +02:00
Add support for single map render via /dynmap fullrender world:map, /dynmap radiusrender radius mapname
This commit is contained in:
parent
b800984e3f
commit
4316e1f3e4
@ -579,14 +579,17 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
else if(c.equals("radiusrender") && checkPlayerPermission(sender,"radiusrender")) {
|
||||
if (player != null) {
|
||||
int radius = 0;
|
||||
String mapname = null;
|
||||
if(args.length > 1) {
|
||||
radius = Integer.parseInt(args[1]); /* Parse radius */
|
||||
if(radius < 0)
|
||||
radius = 0;
|
||||
if(args.length > 2)
|
||||
mapname = args[2];
|
||||
}
|
||||
Location loc = player.getLocation();
|
||||
if(loc != null)
|
||||
mapManager.renderWorldRadius(loc, sender, radius);
|
||||
mapManager.renderWorldRadius(loc, sender, mapname, radius);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage("Command can only be issued by player.");
|
||||
@ -616,18 +619,28 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
} else if (c.equals("fullrender") && checkPlayerPermission(sender,"fullrender")) {
|
||||
String map = null;
|
||||
if (args.length > 1) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
World w = getServer().getWorld(args[i]);
|
||||
int dot = args[i].indexOf(":");
|
||||
World w;
|
||||
String wname = args[i];
|
||||
if(dot >= 0) {
|
||||
wname = args[i].substring(0, dot);
|
||||
map = args[i].substring(dot+1);
|
||||
}
|
||||
w = getServer().getWorld(wname);
|
||||
if(w != null)
|
||||
mapManager.renderFullWorld(new Location(w, 0, 0, 0),sender);
|
||||
mapManager.renderFullWorld(new Location(w, 0, 0, 0),sender, map);
|
||||
else
|
||||
sender.sendMessage("World '" + args[i] + "' not defined/loaded");
|
||||
sender.sendMessage("World '" + wname + "' not defined/loaded");
|
||||
}
|
||||
} else if (player != null) {
|
||||
Location loc = player.getLocation();
|
||||
if(args.length > 1)
|
||||
map = args[1];
|
||||
if(loc != null)
|
||||
mapManager.renderFullWorld(loc, sender);
|
||||
mapManager.renderFullWorld(loc, sender, map);
|
||||
} else {
|
||||
sender.sendMessage("World name is required");
|
||||
}
|
||||
|
@ -166,15 +166,16 @@ public class MapManager {
|
||||
int cxmin, cxmax, czmin, czmax;
|
||||
String rendertype;
|
||||
boolean cancelled;
|
||||
String mapname;
|
||||
|
||||
/* Full world, all maps render */
|
||||
FullWorldRenderState(DynmapWorld dworld, Location l, CommandSender sender) {
|
||||
this(dworld, l, sender, -1);
|
||||
FullWorldRenderState(DynmapWorld dworld, Location l, CommandSender sender, String mapname) {
|
||||
this(dworld, l, sender, mapname, -1);
|
||||
rendertype = "Full render";
|
||||
}
|
||||
|
||||
/* Full world, all maps render, with optional render radius */
|
||||
FullWorldRenderState(DynmapWorld dworld, Location l, CommandSender sender, int radius) {
|
||||
FullWorldRenderState(DynmapWorld dworld, Location l, CommandSender sender, String mapname, int radius) {
|
||||
world = dworld;
|
||||
loc = l;
|
||||
found = new HashSet<MapTile>();
|
||||
@ -193,6 +194,7 @@ public class MapManager {
|
||||
czmax = (l.getBlockZ() + radius+15)>>4;
|
||||
rendertype = "Radius render";
|
||||
}
|
||||
this.mapname = mapname;
|
||||
}
|
||||
|
||||
/* Single tile render - used for incremental renders */
|
||||
@ -240,8 +242,17 @@ public class MapManager {
|
||||
/* Advance to next unrendered map */
|
||||
while(map_index < world.maps.size()) {
|
||||
map_index++; /* Move to next one */
|
||||
if((map_index < world.maps.size()) && (renderedmaps.contains(world.maps.get(map_index)) == false))
|
||||
break;
|
||||
if(map_index >= world.maps.size()) break;
|
||||
/* If single map render, see if this is our target */
|
||||
if(mapname != null) {
|
||||
if(world.maps.get(map_index).getName().equals(mapname)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(renderedmaps.contains(world.maps.get(map_index)) == false)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(map_index >= world.maps.size()) { /* Last one done? */
|
||||
sender.sendMessage(rendertype + " of '" + world.world.getName() + "' finished.");
|
||||
@ -253,6 +264,8 @@ public class MapManager {
|
||||
/* Build active map list */
|
||||
activemaps = "";
|
||||
for(String n : activemaplist) {
|
||||
if((mapname != null) && (!mapname.equals(n)))
|
||||
continue;
|
||||
if(activemaps.length() > 0)
|
||||
activemaps += ",";
|
||||
activemaps += n;
|
||||
@ -307,12 +320,12 @@ public class MapManager {
|
||||
}
|
||||
if(tile0 != null) { /* Single tile? */
|
||||
if(cache.isEmpty() == false)
|
||||
tile.render(cache);
|
||||
tile.render(cache, null);
|
||||
}
|
||||
else {
|
||||
/* Switch to not checking if rendered tile is blank - breaks us on skylands, where tiles can be nominally blank - just work off chunk cache empty */
|
||||
if (cache.isEmpty() == false) {
|
||||
tile.render(cache);
|
||||
tile.render(cache, mapname);
|
||||
found.remove(tile);
|
||||
rendered.add(tile);
|
||||
for (MapTile adjTile : map.getAdjecentTiles(tile)) {
|
||||
@ -434,7 +447,7 @@ public class MapManager {
|
||||
}
|
||||
}
|
||||
|
||||
void renderFullWorld(Location l, CommandSender sender) {
|
||||
void renderFullWorld(Location l, CommandSender sender, String mapname) {
|
||||
DynmapWorld world = getWorld(l.getWorld().getName());
|
||||
if (world == null) {
|
||||
sender.sendMessage("Could not render: world '" + l.getWorld().getName() + "' not defined in configuration.");
|
||||
@ -448,7 +461,7 @@ public class MapManager {
|
||||
sender.sendMessage(rndr.rendertype + " of world '" + wname + "' already active.");
|
||||
return;
|
||||
}
|
||||
rndr = new FullWorldRenderState(world,l,sender); /* Make new activation record */
|
||||
rndr = new FullWorldRenderState(world,l,sender, mapname); /* Make new activation record */
|
||||
active_renders.put(wname, rndr); /* Add to active table */
|
||||
}
|
||||
/* Schedule first tile to be worked */
|
||||
@ -457,7 +470,7 @@ public class MapManager {
|
||||
sender.sendMessage("Full render starting on world '" + wname + "'...");
|
||||
}
|
||||
|
||||
void renderWorldRadius(Location l, CommandSender sender, int radius) {
|
||||
void renderWorldRadius(Location l, CommandSender sender, String mapname, int radius) {
|
||||
DynmapWorld world = getWorld(l.getWorld().getName());
|
||||
if (world == null) {
|
||||
sender.sendMessage("Could not render: world '" + l.getWorld().getName() + "' not defined in configuration.");
|
||||
@ -471,7 +484,7 @@ public class MapManager {
|
||||
sender.sendMessage(rndr.rendertype + " of world '" + wname + "' already active.");
|
||||
return;
|
||||
}
|
||||
rndr = new FullWorldRenderState(world,l,sender, radius); /* Make new activation record */
|
||||
rndr = new FullWorldRenderState(world,l,sender, mapname, radius); /* Make new activation record */
|
||||
active_renders.put(wname, rndr); /* Add to active table */
|
||||
}
|
||||
/* Schedule first tile to be worked */
|
||||
|
@ -10,7 +10,7 @@ import org.dynmap.utils.MapChunkCache;
|
||||
public abstract class MapTile {
|
||||
protected DynmapWorld world;
|
||||
|
||||
public abstract boolean render(MapChunkCache cache);
|
||||
public abstract boolean render(MapChunkCache cache, String mapname);
|
||||
public abstract List<DynmapChunk> getRequiredChunks();
|
||||
public abstract MapTile[] getAdjecentTiles();
|
||||
|
||||
|
@ -495,7 +495,7 @@ public class FlatMap extends MapType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean render(MapChunkCache cache) {
|
||||
public boolean render(MapChunkCache cache, String mapname) {
|
||||
return map.render(cache, this, MapManager.mapman.getTileFile(this));
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class HDMapManager {
|
||||
/**
|
||||
* Initialize shader states for all shaders for given tile
|
||||
*/
|
||||
public HDShaderState[] getShaderStateForTile(HDMapTile tile, MapChunkCache cache, MapIterator mapiter) {
|
||||
public HDShaderState[] getShaderStateForTile(HDMapTile tile, MapChunkCache cache, MapIterator mapiter, String mapname) {
|
||||
DynmapWorld w = MapManager.mapman.worldsLookup.get(tile.getWorld().getName());
|
||||
if(w == null) return new HDShaderState[0];
|
||||
ArrayList<HDShaderState> shaders = new ArrayList<HDShaderState>();
|
||||
@ -127,6 +127,9 @@ public class HDMapManager {
|
||||
if(map instanceof HDMap) {
|
||||
HDMap hdmap = (HDMap)map;
|
||||
if(hdmap.getPerspective() == tile.perspective) {
|
||||
/* If limited to one map, and this isn't it, skip */
|
||||
if((mapname != null) && (!hdmap.getName().equals(mapname)))
|
||||
continue;
|
||||
shaders.add(hdmap.getShader().getStateInstance(hdmap, cache, mapiter));
|
||||
}
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ public class HDMapTile extends MapTile {
|
||||
@Override
|
||||
public boolean isBlockTypeDataNeeded() { return MapManager.mapman.hdmapman.isBlockTypeDataNeeded(this); }
|
||||
|
||||
public boolean render(MapChunkCache cache) {
|
||||
return perspective.render(cache, this);
|
||||
public boolean render(MapChunkCache cache, String mapname) {
|
||||
return perspective.render(cache, this, mapname);
|
||||
}
|
||||
|
||||
public List<DynmapChunk> getRequiredChunks() {
|
||||
|
@ -18,7 +18,7 @@ public interface HDPerspective {
|
||||
/* Get chunks needed for given tile */
|
||||
List<DynmapChunk> getRequiredChunks(MapTile tile);
|
||||
/* Render given tile */
|
||||
boolean render(MapChunkCache cache, HDMapTile tile);
|
||||
boolean render(MapChunkCache cache, HDMapTile tile, String mapname);
|
||||
|
||||
public boolean isBiomeDataNeeded();
|
||||
public boolean isHightestBlockYDataNeeded();
|
||||
|
@ -888,11 +888,11 @@ public class IsoHDPerspective implements HDPerspective {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean render(MapChunkCache cache, HDMapTile tile) {
|
||||
public boolean render(MapChunkCache cache, HDMapTile tile, String mapname) {
|
||||
Color rslt = new Color();
|
||||
MapIterator mapiter = cache.getIterator(0, 0, 0);
|
||||
/* Build shader state object for each shader */
|
||||
HDShaderState[] shaderstate = MapManager.mapman.hdmapman.getShaderStateForTile(tile, cache, mapiter);
|
||||
HDShaderState[] shaderstate = MapManager.mapman.hdmapman.getShaderStateForTile(tile, cache, mapiter, mapname);
|
||||
int numshaders = shaderstate.length;
|
||||
if(numshaders == 0)
|
||||
return false;
|
||||
|
@ -75,7 +75,7 @@ public class KzedMapTile extends MapTile {
|
||||
return getWorld().getName() + ":" + getFilename();
|
||||
}
|
||||
|
||||
public boolean render(MapChunkCache cache) {
|
||||
public boolean render(MapChunkCache cache, String mapname) {
|
||||
return map.render(cache, this, MapManager.mapman.getTileFile(this));
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class KzedZoomedMapTile extends MapTile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean render(MapChunkCache cache) {
|
||||
public boolean render(MapChunkCache cache, String mapname) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,11 @@ commands:
|
||||
/<command> show - shows the player from the map.
|
||||
/<command> show TheDude - shows the player 'TheDude' from the map.
|
||||
/<command> render - Renders the tile at your location.
|
||||
/<command> fullrender - (Attempts to) render entire world from your location.
|
||||
/<command> fullrender world - (Attempts to) render entire world 'world'.
|
||||
/<command> radiusrender ## - (Attempts to) render at least ## block radius from your location.
|
||||
/<command> fullrender - Render all maps for entire world from your location.
|
||||
/<command> fullrender world - Render all maps for entire world 'world'.
|
||||
/<command> fullrender world:mapname - Render map 'mapname' of world 'world'.
|
||||
/<command> radiusrender ## - Render at least ## block radius from your location on all maps.
|
||||
/<command> radiusrender ## mapname - Render at least ## block radius from your location on map 'mapname'
|
||||
/<command> cancelrender - Cancels any active renders on current world
|
||||
/<command> cancelrender world - Cancels any active renders of world 'world'
|
||||
/<command> stats - Show render statistics.
|
||||
|
Loading…
Reference in New Issue
Block a user