Skip to content

Commit

Permalink
Merge pull request #4018 from webbukkit/v3.0
Browse files Browse the repository at this point in the history
v3.7-beta-1
  • Loading branch information
mikeprimm authored Sep 23, 2023
2 parents f7d0928 + 2d723af commit 54dc316
Show file tree
Hide file tree
Showing 109 changed files with 8,708 additions and 147 deletions.
2 changes: 2 additions & 0 deletions DynmapCore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ eclipse {
}
}

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

dependencies {
implementation project(':DynmapCoreAPI')
implementation 'javax.servlet:javax.servlet-api:3.1'
Expand Down
20 changes: 12 additions & 8 deletions DynmapCore/src/main/java/org/dynmap/ConfigurationNode.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package org.dynmap;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -82,13 +86,13 @@ public boolean load() {
initparse();
// If no file to read, just return false
if (!f.canRead()) { return false; }
FileInputStream fis = null;
Reader fr = null;
try {
fis = new FileInputStream(f);
Object o = yaml.load(new UnicodeReader(fis));
fr = new UnicodeReader(new BufferedInputStream(new FileInputStream(f)));
Object o = yaml.load(fr);
if((o != null) && (o instanceof Map))
entries = (Map<String, Object>)o;
fis.close();
fr.close();
}
catch (YAMLException e) {
Log.severe("Error parsing " + f.getPath() + ". Use http://yamllint.com to debug the YAML syntax." );
Expand All @@ -97,8 +101,8 @@ public boolean load() {
Log.severe("Error reading " + f.getPath());
return false;
} finally {
if(fis != null) {
try { fis.close(); } catch (IOException x) {}
if(fr != null) {
try { fr.close(); } catch (IOException x) {}
}
}
return (entries != null);
Expand All @@ -111,7 +115,7 @@ public boolean save() {
public boolean save(File file) {
initparse();

FileOutputStream stream = null;
OutputStream stream = null;

File parent = file.getParentFile();

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

try {
stream = new FileOutputStream(file);
stream = new BufferedOutputStream(new FileOutputStream(file));
OutputStreamWriter writer = new OutputStreamWriter(stream, "UTF-8");
yaml.dump(entries, writer);
return true;
Expand Down
6 changes: 5 additions & 1 deletion DynmapCore/src/main/java/org/dynmap/DynmapMapCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ private void initTabCompletions() {
mapSetArgs.put("boostzoom", emptySupplier);
mapSetArgs.put("tilescale", emptySupplier);
mapSetArgs.put("tileupdatedelay", emptySupplier);
mapSetArgs.put("readonly", booleanSupplier);

tabCompletions = new HashMap<>();
tabCompletions.put("worldaddlimit", worldAddLimitArgs);
Expand Down Expand Up @@ -696,7 +697,7 @@ private boolean handleMapList(DynmapCommandSender sender, String[] args, DynmapC
sb.append(", lighting=").append(hdmt.getLighting().getName()).append(", mapzoomin=").append(hdmt.getMapZoomIn()).append(", mapzoomout=").append(hdmt.getMapZoomOutLevels());
sb.append(", img-format=").append(hdmt.getImageFormatSetting()).append(", icon=").append(hdmt.getIcon());
sb.append(", append-to-world=").append(hdmt.getAppendToWorld()).append(", boostzoom=").append(hdmt.getBoostZoom());
sb.append(", protected=").append(hdmt.isProtected()).append(", tilescale=").append(hdmt.getTileScale());
sb.append(", protected=").append(hdmt.isProtected()).append(", tilescale=").append(hdmt.getTileScale()).append(", readonly=").append(hdmt.isReadOnly());
if(hdmt.tileupdatedelay > 0) {
sb.append(", tileupdatedelay=").append(hdmt.tileupdatedelay);
}
Expand Down Expand Up @@ -996,6 +997,9 @@ else if(tok[0].equalsIgnoreCase("append-to-world")) {
else if(tok[0].equalsIgnoreCase("protected")) {
did_update |= mt.setProtected(Boolean.parseBoolean(tok[1]));
}
else if(tok[0].equalsIgnoreCase("readonly")) {
did_update |= mt.setReadOnly(Boolean.parseBoolean(tok[1]));
}
}
if(did_update) {
if(core.updateWorldConfig(w)) {
Expand Down
22 changes: 18 additions & 4 deletions DynmapCore/src/main/java/org/dynmap/MapManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,12 @@ else if(pausedforworld) {
renderedmaps.addAll(map.getMapsSharingRender(world));

/* Now, prime the render queue */
for (MapTile mt : map.getTiles(world, (int)loc.x, (int)loc.y, (int)loc.z)) {
if (!found.getFlag(mt.tileOrdinalX(), mt.tileOrdinalY())) {
found.setFlag(mt.tileOrdinalX(), mt.tileOrdinalY(), true);
renderQueue.add(mt);
if (map.isReadOnly() == false) {
for (MapTile mt : map.getTiles(world, (int)loc.x, (int)loc.y, (int)loc.z)) {
if (!found.getFlag(mt.tileOrdinalX(), mt.tileOrdinalY())) {
found.setFlag(mt.tileOrdinalX(), mt.tileOrdinalY(), true);
renderQueue.add(mt);
}
}
}
if(!updaterender) { /* Only add other seed points for fullrender */
Expand Down Expand Up @@ -1072,6 +1074,10 @@ private void addNextTilesToUpdate(int cnt) {
tiles.clear();
for(DynmapWorld w : worlds) {
for(MapTypeState mts : w.mapstate) {
if (mts.type.isReadOnly()) {
continue;
}

if(mts.getNextInvalidTileCoord(coord)) {
mts.type.addMapTiles(tiles, w, coord.x, coord.y);
mts.validateTile(coord.x, coord.y);
Expand Down Expand Up @@ -1903,6 +1909,10 @@ private void processTouchEvents() {
}
if(world == null) continue;
for (MapTypeState mts : world.mapstate) {
if (mts.type.isReadOnly()) {
continue;
}

List<TileFlags.TileCoord> tiles = mts.type.getTileCoords(world, evt.x, evt.y, evt.z);
invalidates += mts.invalidateTiles(tiles);
}
Expand Down Expand Up @@ -1935,6 +1945,10 @@ private void processTouchEvents() {
if(world == null) continue;
int invalidates = 0;
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);
invalidates += mts.invalidateTiles(tiles);
}
Expand Down
24 changes: 24 additions & 0 deletions DynmapCore/src/main/java/org/dynmap/MapType.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

public abstract class MapType {
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;

public enum ImageVariant {
Expand Down Expand Up @@ -207,6 +211,26 @@ public boolean setProtected(boolean p) {
}
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 int getTileUpdateDelay(DynmapWorld w) {
Expand Down
3 changes: 2 additions & 1 deletion DynmapCore/src/main/java/org/dynmap/hdmap/HDBlockModels.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.dynmap.hdmap;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -356,7 +357,7 @@ private static void loadModelFile(InputStream in, String fname, ConfigurationNod
int layerbits = 0;
int rownum = 0;
int scale = 0;
rdr = new LineNumberReader(new InputStreamReader(in));
rdr = new LineNumberReader(new BufferedReader(new InputStreamReader(in)));
while ((line = rdr.readLine()) != null) {
boolean skip = false;
int lineNum = rdr.getLineNumber();
Expand Down
2 changes: 2 additions & 0 deletions DynmapCore/src/main/java/org/dynmap/hdmap/HDMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public HDMap(DynmapCore core, ConfigurationNode configuration) {
this.append_to_world = configuration.getString("append_to_world", "");
setProtected(configuration.getBoolean("protected", false));
setTileUpdateDelay(configuration.getInteger("tileupdatedelay", -1));
setReadOnly(configuration.getBoolean("readonly", false));
}

public ConfigurationNode saveConfiguration() {
Expand Down Expand Up @@ -180,6 +181,7 @@ public ConfigurationNode saveConfiguration() {
cn.put("backgroundnight", bg_night_cfg);
cn.put("append_to_world", append_to_world);
cn.put("protected", isProtected());
cn.put("readonly", isReadOnly());
if(this.tileupdatedelay > 0) {
cn.put("tileupdatedelay", this.tileupdatedelay);
}
Expand Down
6 changes: 6 additions & 0 deletions DynmapCore/src/main/java/org/dynmap/hdmap/HDMapManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ public HDShaderState[] getShaderStateForTile(HDMapTile tile, MapChunkCache cache
/* If limited to one map, and this isn't it, skip */
if((mapname != null) && (!hdmap.getName().equals(mapname)))
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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ public boolean render(MapChunkCache cache, HDMapTile tile, String mapname) {
// Mark the tiles we're going to render as validated
for (int i = 0; i < numshaders; i++) {
MapTypeState mts = world.getMapState(shaderstate[i].getMap());
if (mts != null) {
if (mts != null && mts.type.isReadOnly() == false) {
mts.validateTile(tile.tx, tile.ty);
}
}
Expand Down
5 changes: 3 additions & 2 deletions DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.dynmap.hdmap;

import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -1823,7 +1824,7 @@ private static void loadTileSetsFile(InputStream txtfile, String txtname, Config

try {
String line;
rdr = new LineNumberReader(new InputStreamReader(txtfile));
rdr = new LineNumberReader(new BufferedReader(new InputStreamReader(txtfile)));
while((line = rdr.readLine()) != null) {
if(line.startsWith("#")) {
}
Expand Down Expand Up @@ -1922,7 +1923,7 @@ private static void loadTextureFile(InputStream txtfile, String txtname, Configu
Map<DynmapBlockState, BitSet> bsprslt;
try {
String line;
rdr = new LineNumberReader(new InputStreamReader(txtfile));
rdr = new LineNumberReader(new BufferedReader(new InputStreamReader(txtfile)));
while((line = rdr.readLine()) != null) {
boolean skip = false;
int lineNum = rdr.getLineNumber();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.dynmap.hdmap;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -61,21 +62,21 @@ public InputStream openModTPResource(String rname, String modname) {
if (zf != null) {
ZipEntry ze = zf.getEntry(rname);
if ((ze != null) && (!ze.isDirectory())) {
return zf.getInputStream(ze);
return new BufferedInputStream(zf.getInputStream(ze));
}
}
else if (tpdir != null) {
File f = new File(tpdir, rname);
if (f.isFile() && f.canRead()) {
return new FileInputStream(f);
return new BufferedInputStream(new FileInputStream(f));
}
}
} catch (IOException iox) {
}
// Fall through - load as resource from mod, if possible, or from jar
InputStream is = dsi.openResource(modname, rname);
if (is != null) {
return is;
return new BufferedInputStream(is);
}
if (modname != null) {
ModSource ms = src_by_mod.get(modname);
Expand Down Expand Up @@ -118,7 +119,7 @@ else if (ms.directory != null) {
Log.warning("Resource " + rname + " for mod " + modname + " not found");
}

return is;
return (is != null) ? new BufferedInputStream(is) : null;
}
public void close() {
if(zf != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.dynmap.modsupport.impl;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Locale;
Expand Down Expand Up @@ -274,9 +276,9 @@ public void writeToFile(File destdir) throws IOException {
return;
}
File f = new File(destdir, this.txtDef.getModID() + "-models.txt");
FileWriter fw = null;
Writer fw = null;
try {
fw = new FileWriter(f);
fw = new BufferedWriter(new FileWriter(f));
// Write modname line
String s = "modname:" + this.txtDef.getModID();
fw.write(s + "\n\n");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.dynmap.modsupport.impl;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -278,9 +280,9 @@ public boolean isPublished() {

public void writeToFile(File destdir) throws IOException {
File f = new File(destdir, this.modid + "-texture.txt");
FileWriter fw = null;
Writer fw = null;
try {
fw = new FileWriter(f);
fw = new BufferedWriter(new FileWriter(f));
// Write modname line
String s = "modname:" + this.modid;
fw.write(s + "\n\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Logger;
Expand Down
Loading

0 comments on commit 54dc316

Please sign in to comment.