mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-24 17:47:40 +01:00
feat: add readonly
map option
This option will prevent the map from being updated by the renderer. It can be used if you want a "natural" map, i.e. you want to generate a map and preserve it without being updated with users buildings.
This commit is contained in:
parent
b310a57b64
commit
20592cd805
@ -629,10 +629,12 @@ public class MapManager {
|
|||||||
renderedmaps.addAll(map.getMapsSharingRender(world));
|
renderedmaps.addAll(map.getMapsSharingRender(world));
|
||||||
|
|
||||||
/* Now, prime the render queue */
|
/* Now, prime the render queue */
|
||||||
for (MapTile mt : map.getTiles(world, (int)loc.x, (int)loc.y, (int)loc.z)) {
|
if (map.isReadOnly() == false) {
|
||||||
if (!found.getFlag(mt.tileOrdinalX(), mt.tileOrdinalY())) {
|
for (MapTile mt : map.getTiles(world, (int)loc.x, (int)loc.y, (int)loc.z)) {
|
||||||
found.setFlag(mt.tileOrdinalX(), mt.tileOrdinalY(), true);
|
if (!found.getFlag(mt.tileOrdinalX(), mt.tileOrdinalY())) {
|
||||||
renderQueue.add(mt);
|
found.setFlag(mt.tileOrdinalX(), mt.tileOrdinalY(), true);
|
||||||
|
renderQueue.add(mt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!updaterender) { /* Only add other seed points for fullrender */
|
if(!updaterender) { /* Only add other seed points for fullrender */
|
||||||
@ -1072,6 +1074,10 @@ public class MapManager {
|
|||||||
tiles.clear();
|
tiles.clear();
|
||||||
for(DynmapWorld w : worlds) {
|
for(DynmapWorld w : worlds) {
|
||||||
for(MapTypeState mts : w.mapstate) {
|
for(MapTypeState mts : w.mapstate) {
|
||||||
|
if (mts.type.isReadOnly()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(mts.getNextInvalidTileCoord(coord)) {
|
if(mts.getNextInvalidTileCoord(coord)) {
|
||||||
mts.type.addMapTiles(tiles, w, coord.x, coord.y);
|
mts.type.addMapTiles(tiles, w, coord.x, coord.y);
|
||||||
mts.validateTile(coord.x, coord.y);
|
mts.validateTile(coord.x, coord.y);
|
||||||
@ -1903,6 +1909,10 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
if(world == null) continue;
|
if(world == null) continue;
|
||||||
for (MapTypeState mts : world.mapstate) {
|
for (MapTypeState mts : world.mapstate) {
|
||||||
|
if (mts.type.isReadOnly()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
List<TileFlags.TileCoord> tiles = mts.type.getTileCoords(world, evt.x, evt.y, evt.z);
|
List<TileFlags.TileCoord> tiles = mts.type.getTileCoords(world, evt.x, evt.y, evt.z);
|
||||||
invalidates += mts.invalidateTiles(tiles);
|
invalidates += mts.invalidateTiles(tiles);
|
||||||
}
|
}
|
||||||
@ -1935,6 +1945,10 @@ public class MapManager {
|
|||||||
if(world == null) continue;
|
if(world == null) continue;
|
||||||
int invalidates = 0;
|
int invalidates = 0;
|
||||||
for (MapTypeState mts : world.mapstate) {
|
for (MapTypeState mts : world.mapstate) {
|
||||||
|
if (mts.type.isReadOnly()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
List<TileFlags.TileCoord> tiles = mts.type.getTileCoords(world, evt.xmin, evt.ymin, evt.zmin, evt.xmax, evt.ymax, evt.zmax);
|
List<TileFlags.TileCoord> tiles = mts.type.getTileCoords(world, evt.xmin, evt.ymin, evt.zmin, evt.xmax, evt.ymax, evt.zmax);
|
||||||
invalidates += mts.invalidateTiles(tiles);
|
invalidates += mts.invalidateTiles(tiles);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,10 @@ import org.json.simple.JSONObject;
|
|||||||
|
|
||||||
public abstract class MapType {
|
public abstract class MapType {
|
||||||
private boolean is_protected;
|
private boolean is_protected;
|
||||||
|
/**
|
||||||
|
* Is the map type read-only? (i.e. should not be updated by renderer)
|
||||||
|
*/
|
||||||
|
private boolean is_readonly;
|
||||||
protected int tileupdatedelay;
|
protected int tileupdatedelay;
|
||||||
|
|
||||||
public enum ImageVariant {
|
public enum ImageVariant {
|
||||||
@ -207,6 +211,26 @@ public abstract class MapType {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Is the map type read-only? (i.e. should not be updated by renderer)
|
||||||
|
* @return true if read-only
|
||||||
|
*/
|
||||||
|
public boolean isReadOnly() {
|
||||||
|
return is_readonly;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set read-only state of map type
|
||||||
|
* @param r - true if read-only
|
||||||
|
* @return true if state changed
|
||||||
|
*/
|
||||||
|
public boolean setReadOnly(boolean r) {
|
||||||
|
if(is_readonly != r) {
|
||||||
|
is_readonly = r;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
public abstract String getPrefix();
|
public abstract String getPrefix();
|
||||||
|
|
||||||
public int getTileUpdateDelay(DynmapWorld w) {
|
public int getTileUpdateDelay(DynmapWorld w) {
|
||||||
|
@ -153,6 +153,7 @@ public class HDMap extends MapType {
|
|||||||
this.append_to_world = configuration.getString("append_to_world", "");
|
this.append_to_world = configuration.getString("append_to_world", "");
|
||||||
setProtected(configuration.getBoolean("protected", false));
|
setProtected(configuration.getBoolean("protected", false));
|
||||||
setTileUpdateDelay(configuration.getInteger("tileupdatedelay", -1));
|
setTileUpdateDelay(configuration.getInteger("tileupdatedelay", -1));
|
||||||
|
setReadOnly(configuration.getBoolean("readonly", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigurationNode saveConfiguration() {
|
public ConfigurationNode saveConfiguration() {
|
||||||
|
@ -131,6 +131,12 @@ public class HDMapManager {
|
|||||||
/* If limited to one map, and this isn't it, skip */
|
/* If limited to one map, and this isn't it, skip */
|
||||||
if((mapname != null) && (!hdmap.getName().equals(mapname)))
|
if((mapname != null) && (!hdmap.getName().equals(mapname)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Maps can be set to read-only, which means they don't get re-rendered
|
||||||
|
if (map.isReadOnly()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
shaders.add(hdmap.getShader().getStateInstance(hdmap, cache, mapiter, scale));
|
shaders.add(hdmap.getShader().getStateInstance(hdmap, cache, mapiter, scale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1268,7 +1268,7 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
// Mark the tiles we're going to render as validated
|
// Mark the tiles we're going to render as validated
|
||||||
for (int i = 0; i < numshaders; i++) {
|
for (int i = 0; i < numshaders; i++) {
|
||||||
MapTypeState mts = world.getMapState(shaderstate[i].getMap());
|
MapTypeState mts = world.getMapState(shaderstate[i].getMap());
|
||||||
if (mts != null) {
|
if (mts != null && mts.type.isReadOnly() == false) {
|
||||||
mts.validateTile(tile.tx, tile.ty);
|
mts.validateTile(tile.tx, tile.ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user