Skip to content

Commit 54dc316

Browse files
authored
Merge pull request #4018 from webbukkit/v3.0
v3.7-beta-1
2 parents f7d0928 + 2d723af commit 54dc316

109 files changed

Lines changed: 8708 additions & 147 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DynmapCore/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ eclipse {
88
}
99
}
1010

11+
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
12+
1113
dependencies {
1214
implementation project(':DynmapCoreAPI')
1315
implementation 'javax.servlet:javax.servlet-api:3.1'

DynmapCore/src/main/java/org/dynmap/ConfigurationNode.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package org.dynmap;
22

3+
import java.io.BufferedInputStream;
4+
import java.io.BufferedOutputStream;
35
import java.io.File;
46
import java.io.FileInputStream;
57
import java.io.FileOutputStream;
68
import java.io.IOException;
79
import java.io.InputStream;
10+
import java.io.OutputStream;
811
import java.io.OutputStreamWriter;
12+
import java.io.Reader;
913
import java.lang.reflect.Constructor;
1014
import java.util.ArrayList;
1115
import java.util.Collection;
@@ -82,13 +86,13 @@ public boolean load() {
8286
initparse();
8387
// If no file to read, just return false
8488
if (!f.canRead()) { return false; }
85-
FileInputStream fis = null;
89+
Reader fr = null;
8690
try {
87-
fis = new FileInputStream(f);
88-
Object o = yaml.load(new UnicodeReader(fis));
91+
fr = new UnicodeReader(new BufferedInputStream(new FileInputStream(f)));
92+
Object o = yaml.load(fr);
8993
if((o != null) && (o instanceof Map))
9094
entries = (Map<String, Object>)o;
91-
fis.close();
95+
fr.close();
9296
}
9397
catch (YAMLException e) {
9498
Log.severe("Error parsing " + f.getPath() + ". Use http://yamllint.com to debug the YAML syntax." );
@@ -97,8 +101,8 @@ public boolean load() {
97101
Log.severe("Error reading " + f.getPath());
98102
return false;
99103
} finally {
100-
if(fis != null) {
101-
try { fis.close(); } catch (IOException x) {}
104+
if(fr != null) {
105+
try { fr.close(); } catch (IOException x) {}
102106
}
103107
}
104108
return (entries != null);
@@ -111,7 +115,7 @@ public boolean save() {
111115
public boolean save(File file) {
112116
initparse();
113117

114-
FileOutputStream stream = null;
118+
OutputStream stream = null;
115119

116120
File parent = file.getParentFile();
117121

@@ -120,7 +124,7 @@ public boolean save(File file) {
120124
}
121125

122126
try {
123-
stream = new FileOutputStream(file);
127+
stream = new BufferedOutputStream(new FileOutputStream(file));
124128
OutputStreamWriter writer = new OutputStreamWriter(stream, "UTF-8");
125129
yaml.dump(entries, writer);
126130
return true;

DynmapCore/src/main/java/org/dynmap/DynmapMapCommands.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ private void initTabCompletions() {
9292
mapSetArgs.put("boostzoom", emptySupplier);
9393
mapSetArgs.put("tilescale", emptySupplier);
9494
mapSetArgs.put("tileupdatedelay", emptySupplier);
95+
mapSetArgs.put("readonly", booleanSupplier);
9596

9697
tabCompletions = new HashMap<>();
9798
tabCompletions.put("worldaddlimit", worldAddLimitArgs);
@@ -696,7 +697,7 @@ private boolean handleMapList(DynmapCommandSender sender, String[] args, DynmapC
696697
sb.append(", lighting=").append(hdmt.getLighting().getName()).append(", mapzoomin=").append(hdmt.getMapZoomIn()).append(", mapzoomout=").append(hdmt.getMapZoomOutLevels());
697698
sb.append(", img-format=").append(hdmt.getImageFormatSetting()).append(", icon=").append(hdmt.getIcon());
698699
sb.append(", append-to-world=").append(hdmt.getAppendToWorld()).append(", boostzoom=").append(hdmt.getBoostZoom());
699-
sb.append(", protected=").append(hdmt.isProtected()).append(", tilescale=").append(hdmt.getTileScale());
700+
sb.append(", protected=").append(hdmt.isProtected()).append(", tilescale=").append(hdmt.getTileScale()).append(", readonly=").append(hdmt.isReadOnly());
700701
if(hdmt.tileupdatedelay > 0) {
701702
sb.append(", tileupdatedelay=").append(hdmt.tileupdatedelay);
702703
}
@@ -996,6 +997,9 @@ else if(tok[0].equalsIgnoreCase("append-to-world")) {
996997
else if(tok[0].equalsIgnoreCase("protected")) {
997998
did_update |= mt.setProtected(Boolean.parseBoolean(tok[1]));
998999
}
1000+
else if(tok[0].equalsIgnoreCase("readonly")) {
1001+
did_update |= mt.setReadOnly(Boolean.parseBoolean(tok[1]));
1002+
}
9991003
}
10001004
if(did_update) {
10011005
if(core.updateWorldConfig(w)) {

DynmapCore/src/main/java/org/dynmap/MapManager.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,12 @@ else if(pausedforworld) {
629629
renderedmaps.addAll(map.getMapsSharingRender(world));
630630

631631
/* Now, prime the render queue */
632-
for (MapTile mt : map.getTiles(world, (int)loc.x, (int)loc.y, (int)loc.z)) {
633-
if (!found.getFlag(mt.tileOrdinalX(), mt.tileOrdinalY())) {
634-
found.setFlag(mt.tileOrdinalX(), mt.tileOrdinalY(), true);
635-
renderQueue.add(mt);
632+
if (map.isReadOnly() == false) {
633+
for (MapTile mt : map.getTiles(world, (int)loc.x, (int)loc.y, (int)loc.z)) {
634+
if (!found.getFlag(mt.tileOrdinalX(), mt.tileOrdinalY())) {
635+
found.setFlag(mt.tileOrdinalX(), mt.tileOrdinalY(), true);
636+
renderQueue.add(mt);
637+
}
636638
}
637639
}
638640
if(!updaterender) { /* Only add other seed points for fullrender */
@@ -1072,6 +1074,10 @@ private void addNextTilesToUpdate(int cnt) {
10721074
tiles.clear();
10731075
for(DynmapWorld w : worlds) {
10741076
for(MapTypeState mts : w.mapstate) {
1077+
if (mts.type.isReadOnly()) {
1078+
continue;
1079+
}
1080+
10751081
if(mts.getNextInvalidTileCoord(coord)) {
10761082
mts.type.addMapTiles(tiles, w, coord.x, coord.y);
10771083
mts.validateTile(coord.x, coord.y);
@@ -1903,6 +1909,10 @@ private void processTouchEvents() {
19031909
}
19041910
if(world == null) continue;
19051911
for (MapTypeState mts : world.mapstate) {
1912+
if (mts.type.isReadOnly()) {
1913+
continue;
1914+
}
1915+
19061916
List<TileFlags.TileCoord> tiles = mts.type.getTileCoords(world, evt.x, evt.y, evt.z);
19071917
invalidates += mts.invalidateTiles(tiles);
19081918
}
@@ -1935,6 +1945,10 @@ private void processTouchEvents() {
19351945
if(world == null) continue;
19361946
int invalidates = 0;
19371947
for (MapTypeState mts : world.mapstate) {
1948+
if (mts.type.isReadOnly()) {
1949+
continue;
1950+
}
1951+
19381952
List<TileFlags.TileCoord> tiles = mts.type.getTileCoords(world, evt.xmin, evt.ymin, evt.zmin, evt.xmax, evt.ymax, evt.zmax);
19391953
invalidates += mts.invalidateTiles(tiles);
19401954
}

DynmapCore/src/main/java/org/dynmap/MapType.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
public abstract class MapType {
1212
private boolean is_protected;
13+
/**
14+
* Is the map type read-only? (i.e. should not be updated by renderer)
15+
*/
16+
private boolean is_readonly;
1317
protected int tileupdatedelay;
1418

1519
public enum ImageVariant {
@@ -207,6 +211,26 @@ public boolean setProtected(boolean p) {
207211
}
208212
return false;
209213
}
214+
/**
215+
* Is the map type read-only? (i.e. should not be updated by renderer)
216+
* @return true if read-only
217+
*/
218+
public boolean isReadOnly() {
219+
return is_readonly;
220+
}
221+
222+
/**
223+
* Set read-only state of map type
224+
* @param r - true if read-only
225+
* @return true if state changed
226+
*/
227+
public boolean setReadOnly(boolean r) {
228+
if(is_readonly != r) {
229+
is_readonly = r;
230+
return true;
231+
}
232+
return false;
233+
}
210234
public abstract String getPrefix();
211235

212236
public int getTileUpdateDelay(DynmapWorld w) {

DynmapCore/src/main/java/org/dynmap/hdmap/HDBlockModels.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.dynmap.hdmap;
22

3+
import java.io.BufferedReader;
34
import java.io.File;
45
import java.io.FileInputStream;
56
import java.io.IOException;
@@ -356,7 +357,7 @@ private static void loadModelFile(InputStream in, String fname, ConfigurationNod
356357
int layerbits = 0;
357358
int rownum = 0;
358359
int scale = 0;
359-
rdr = new LineNumberReader(new InputStreamReader(in));
360+
rdr = new LineNumberReader(new BufferedReader(new InputStreamReader(in)));
360361
while ((line = rdr.readLine()) != null) {
361362
boolean skip = false;
362363
int lineNum = rdr.getLineNumber();

DynmapCore/src/main/java/org/dynmap/hdmap/HDMap.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public HDMap(DynmapCore core, ConfigurationNode configuration) {
153153
this.append_to_world = configuration.getString("append_to_world", "");
154154
setProtected(configuration.getBoolean("protected", false));
155155
setTileUpdateDelay(configuration.getInteger("tileupdatedelay", -1));
156+
setReadOnly(configuration.getBoolean("readonly", false));
156157
}
157158

158159
public ConfigurationNode saveConfiguration() {
@@ -180,6 +181,7 @@ public ConfigurationNode saveConfiguration() {
180181
cn.put("backgroundnight", bg_night_cfg);
181182
cn.put("append_to_world", append_to_world);
182183
cn.put("protected", isProtected());
184+
cn.put("readonly", isReadOnly());
183185
if(this.tileupdatedelay > 0) {
184186
cn.put("tileupdatedelay", this.tileupdatedelay);
185187
}

DynmapCore/src/main/java/org/dynmap/hdmap/HDMapManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ public HDShaderState[] getShaderStateForTile(HDMapTile tile, MapChunkCache cache
131131
/* If limited to one map, and this isn't it, skip */
132132
if((mapname != null) && (!hdmap.getName().equals(mapname)))
133133
continue;
134+
135+
// Maps can be set to read-only, which means they don't get re-rendered
136+
if (map.isReadOnly()) {
137+
continue;
138+
}
139+
134140
shaders.add(hdmap.getShader().getStateInstance(hdmap, cache, mapiter, scale));
135141
}
136142
}

DynmapCore/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ public boolean render(MapChunkCache cache, HDMapTile tile, String mapname) {
12681268
// Mark the tiles we're going to render as validated
12691269
for (int i = 0; i < numshaders; i++) {
12701270
MapTypeState mts = world.getMapState(shaderstate[i].getMap());
1271-
if (mts != null) {
1271+
if (mts != null && mts.type.isReadOnly() == false) {
12721272
mts.validateTile(tile.tx, tile.ty);
12731273
}
12741274
}

DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.dynmap.hdmap;
22

33
import java.awt.image.BufferedImage;
4+
import java.io.BufferedReader;
45
import java.io.File;
56
import java.io.FileInputStream;
67
import java.io.FileNotFoundException;
@@ -1823,7 +1824,7 @@ private static void loadTileSetsFile(InputStream txtfile, String txtname, Config
18231824

18241825
try {
18251826
String line;
1826-
rdr = new LineNumberReader(new InputStreamReader(txtfile));
1827+
rdr = new LineNumberReader(new BufferedReader(new InputStreamReader(txtfile)));
18271828
while((line = rdr.readLine()) != null) {
18281829
if(line.startsWith("#")) {
18291830
}
@@ -1922,7 +1923,7 @@ private static void loadTextureFile(InputStream txtfile, String txtname, Configu
19221923
Map<DynmapBlockState, BitSet> bsprslt;
19231924
try {
19241925
String line;
1925-
rdr = new LineNumberReader(new InputStreamReader(txtfile));
1926+
rdr = new LineNumberReader(new BufferedReader(new InputStreamReader(txtfile)));
19261927
while((line = rdr.readLine()) != null) {
19271928
boolean skip = false;
19281929
int lineNum = rdr.getLineNumber();

0 commit comments

Comments
 (0)