Update gradle, update configurate-library and improve gradle build

This commit is contained in:
Blue (Lukas Rieger) 2021-05-16 18:13:30 +02:00
parent 53378ba059
commit c0edb3d294
No known key found for this signature in database
GPG Key ID: 904C4995F9E1F800
63 changed files with 782 additions and 693 deletions

@ -1 +1 @@
Subproject commit 6bdbdb150db6ae0b2b4bf10fc9632e03367b310f
Subproject commit 7774935fb3be51ea32b144261d1e5a02294f9d49

View File

@ -3,10 +3,10 @@ plugins {
}
dependencies {
compile 'com.mojang:brigadier:1.0.17'
api 'com.mojang:brigadier:1.0.17'
compile project(':BlueMapCore')
compile project(':BlueMapAPI')
api project(':BlueMapCore')
api project(':BlueMapAPI')
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
}
@ -34,8 +34,8 @@ task buildWebapp(type: NpmTask) {
task zipWebapp(type: Zip) {
dependsOn 'buildWebapp'
from fileTree('BlueMapVue/dist/')
archiveName 'webapp.zip'
destinationDir(file('src/main/resources/de/bluecolored/bluemap/'))
archiveFileName.set('webapp.zip')
destinationDirectory.set(file('src/main/resources/de/bluecolored/bluemap/'))
outputs.upToDateWhen { false }
}

View File

@ -26,15 +26,16 @@
import com.flowpowered.math.vector.Vector2d;
import com.flowpowered.math.vector.Vector3d;
import com.google.common.base.Preconditions;
import de.bluecolored.bluemap.api.BlueMapAPI;
import de.bluecolored.bluemap.api.BlueMapMap;
import de.bluecolored.bluemap.api.marker.ExtrudeMarker;
import de.bluecolored.bluemap.api.marker.Shape;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.awt.*;
import java.util.List;
import java.util.Objects;
public class ExtrudeMarkerImpl extends ObjectMarkerImpl implements ExtrudeMarker {
public static final String MARKER_TYPE = "extrude";
@ -51,7 +52,7 @@ public class ExtrudeMarkerImpl extends ObjectMarkerImpl implements ExtrudeMarker
public ExtrudeMarkerImpl(String id, BlueMapMap map, Vector3d position, Shape shape, float shapeMinY, float shapeMaxY) {
super(id, map, position);
Preconditions.checkNotNull(shape);
Objects.requireNonNull(shape);
this.shape = shape;
this.shapeMinY = shapeMinY;
@ -85,7 +86,7 @@ public float getShapeMaxY() {
@Override
public synchronized void setShape(Shape shape, float shapeMinY, float shapeMaxY) {
Preconditions.checkNotNull(shape);
Objects.requireNonNull(shape);
this.shape = shape;
this.shapeMinY = shapeMinY;
@ -122,7 +123,7 @@ public Color getLineColor() {
@Override
public synchronized void setLineColor(Color color) {
Preconditions.checkNotNull(color);
Objects.requireNonNull(color);
this.lineColor = color;
this.hasUnsavedChanges = true;
@ -135,7 +136,7 @@ public Color getFillColor() {
@Override
public synchronized void setFillColor(Color color) {
Preconditions.checkNotNull(color);
Objects.requireNonNull(color);
this.fillColor = color;
this.hasUnsavedChanges = true;
@ -148,32 +149,32 @@ public void load(BlueMapAPI api, ConfigurationNode markerNode, boolean overwrite
if (!overwriteChanges && hasUnsavedChanges) return;
this.hasUnsavedChanges = false;
this.shape = readShape(markerNode.getNode("shape"));
this.shapeMinY = markerNode.getNode("shapeMinY").getFloat(0);
this.shapeMaxY = markerNode.getNode("shapeMaxY").getFloat(255);
this.depthTest = markerNode.getNode("depthTest").getBoolean(true);
this.lineWidth = markerNode.getNode("lineWidth").getInt(2);
this.lineColor = readColor(markerNode.getNode("lineColor"));
this.fillColor = readColor(markerNode.getNode("fillColor"));
this.shape = readShape(markerNode.node("shape"));
this.shapeMinY = markerNode.node("shapeMinY").getFloat(0);
this.shapeMaxY = markerNode.node("shapeMaxY").getFloat(255);
this.depthTest = markerNode.node("depthTest").getBoolean(true);
this.lineWidth = markerNode.node("lineWidth").getInt(2);
this.lineColor = readColor(markerNode.node("lineColor"));
this.fillColor = readColor(markerNode.node("fillColor"));
}
@Override
public void save(ConfigurationNode markerNode) {
public void save(ConfigurationNode markerNode) throws SerializationException {
super.save(markerNode);
writeShape(markerNode.getNode("shape"), this.shape);
markerNode.getNode("shapeMinY").setValue(Math.round(shapeMinY * 1000f) / 1000f);
markerNode.getNode("shapeMaxY").setValue(Math.round(shapeMaxY * 1000f) / 1000f);
markerNode.getNode("depthTest").setValue(this.depthTest);
markerNode.getNode("lineWidth").setValue(this.lineWidth);
writeColor(markerNode.getNode("lineColor"), this.lineColor);
writeColor(markerNode.getNode("fillColor"), this.fillColor);
writeShape(markerNode.node("shape"), this.shape);
markerNode.node("shapeMinY").set(Math.round(shapeMinY * 1000f) / 1000f);
markerNode.node("shapeMaxY").set(Math.round(shapeMaxY * 1000f) / 1000f);
markerNode.node("depthTest").set(this.depthTest);
markerNode.node("lineWidth").set(this.lineWidth);
writeColor(markerNode.node("lineColor"), this.lineColor);
writeColor(markerNode.node("fillColor"), this.fillColor);
hasUnsavedChanges = false;
}
private Shape readShape(ConfigurationNode node) throws MarkerFileFormatException {
List<? extends ConfigurationNode> posNodes = node.getChildrenList();
List<? extends ConfigurationNode> posNodes = node.childrenList();
if (posNodes.size() < 3) throw new MarkerFileFormatException("Failed to read shape: point-list has fewer than 3 entries!");
@ -187,10 +188,10 @@ private Shape readShape(ConfigurationNode node) throws MarkerFileFormatException
private static Vector2d readShapePos(ConfigurationNode node) throws MarkerFileFormatException {
ConfigurationNode nx, nz;
nx = node.getNode("x");
nz = node.getNode("z");
nx = node.node("x");
nz = node.node("z");
if (nx.isVirtual() || nz.isVirtual()) throw new MarkerFileFormatException("Failed to read shape position: Node x or z is not set!");
if (nx.virtual() || nz.virtual()) throw new MarkerFileFormatException("Failed to read shape position: Node x or z is not set!");
return new Vector2d(
nx.getDouble(),
@ -200,12 +201,12 @@ private static Vector2d readShapePos(ConfigurationNode node) throws MarkerFileFo
private static Color readColor(ConfigurationNode node) throws MarkerFileFormatException {
ConfigurationNode nr, ng, nb, na;
nr = node.getNode("r");
ng = node.getNode("g");
nb = node.getNode("b");
na = node.getNode("a");
nr = node.node("r");
ng = node.node("g");
nb = node.node("b");
na = node.node("a");
if (nr.isVirtual() || ng.isVirtual() || nb.isVirtual()) throw new MarkerFileFormatException("Failed to read color: Node r,g or b is not set!");
if (nr.virtual() || ng.virtual() || nb.virtual()) throw new MarkerFileFormatException("Failed to read color: Node r,g or b is not set!");
float alpha = na.getFloat(1);
if (alpha < 0 || alpha > 1) throw new MarkerFileFormatException("Failed to read color: alpha value out of range (0-1)!");
@ -217,25 +218,25 @@ private static Color readColor(ConfigurationNode node) throws MarkerFileFormatEx
}
}
private static void writeShape(ConfigurationNode node, Shape shape) {
private static void writeShape(ConfigurationNode node, Shape shape) throws SerializationException {
for (int i = 0; i < shape.getPointCount(); i++) {
ConfigurationNode pointNode = node.appendListNode();
Vector2d point = shape.getPoint(i);
pointNode.getNode("x").setValue(Math.round(point.getX() * 1000d) / 1000d);
pointNode.getNode("z").setValue(Math.round(point.getY() * 1000d) / 1000d);
pointNode.node("x").set(Math.round(point.getX() * 1000d) / 1000d);
pointNode.node("z").set(Math.round(point.getY() * 1000d) / 1000d);
}
}
private static void writeColor(ConfigurationNode node, Color color) {
private static void writeColor(ConfigurationNode node, Color color) throws SerializationException {
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
float a = color.getAlpha() / 255f;
node.getNode("r").setValue(r);
node.getNode("g").setValue(g);
node.getNode("b").setValue(b);
node.getNode("a").setValue(a);
node.node("r").set(r);
node.node("g").set(g);
node.node("b").set(b);
node.node("a").set(a);
}
}

View File

@ -29,7 +29,8 @@
import de.bluecolored.bluemap.api.BlueMapAPI;
import de.bluecolored.bluemap.api.BlueMapMap;
import de.bluecolored.bluemap.api.marker.HtmlMarker;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
public class HtmlMarkerImpl extends MarkerImpl implements HtmlMarker {
public static final String MARKER_TYPE = "html";
@ -82,30 +83,30 @@ public synchronized void load(BlueMapAPI api, ConfigurationNode markerNode, bool
if (!overwriteChanges && hasUnsavedChanges) return;
this.hasUnsavedChanges = false;
this.html = markerNode.getNode("html").getString("");
this.anchor = readAnchor(markerNode.getNode("anchor"));
this.html = markerNode.node("html").getString("");
this.anchor = readAnchor(markerNode.node("anchor"));
}
@Override
public synchronized void save(ConfigurationNode markerNode) {
public synchronized void save(ConfigurationNode markerNode) throws SerializationException {
super.save(markerNode);
markerNode.getNode("html").setValue(this.html);
writeAnchor(markerNode.getNode("anchor"), this.anchor);
markerNode.node("html").set(this.html);
writeAnchor(markerNode.node("anchor"), this.anchor);
hasUnsavedChanges = false;
}
private static Vector2i readAnchor(ConfigurationNode node) {
return new Vector2i(
node.getNode("x").getInt(0),
node.getNode("y").getInt(0)
node.node("x").getInt(0),
node.node("y").getInt(0)
);
}
private static void writeAnchor(ConfigurationNode node, Vector2i anchor) {
node.getNode("x").setValue(anchor.getX());
node.getNode("y").setValue(anchor.getY());
private static void writeAnchor(ConfigurationNode node, Vector2i anchor) throws SerializationException {
node.node("x").set(anchor.getX());
node.node("y").set(anchor.getY());
}
}

View File

@ -25,15 +25,16 @@
package de.bluecolored.bluemap.common.api.marker;
import com.flowpowered.math.vector.Vector3d;
import com.google.common.base.Preconditions;
import de.bluecolored.bluemap.api.BlueMapAPI;
import de.bluecolored.bluemap.api.BlueMapMap;
import de.bluecolored.bluemap.api.marker.Line;
import de.bluecolored.bluemap.api.marker.LineMarker;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.awt.*;
import java.util.List;
import java.util.Objects;
public class LineMarkerImpl extends ObjectMarkerImpl implements LineMarker {
public static final String MARKER_TYPE = "line";
@ -48,7 +49,7 @@ public class LineMarkerImpl extends ObjectMarkerImpl implements LineMarker {
public LineMarkerImpl(String id, BlueMapMap map, Vector3d position, Line line) {
super(id, map, position);
Preconditions.checkNotNull(line);
Objects.requireNonNull(line);
this.line = line;
this.lineWidth = 2;
@ -69,7 +70,7 @@ public Line getLine() {
@Override
public synchronized void setLine(Line line) {
Preconditions.checkNotNull(line);
Objects.requireNonNull(line);
this.line = line;
this.hasUnsavedChanges = true;
@ -104,7 +105,7 @@ public Color getLineColor() {
@Override
public synchronized void setLineColor(Color color) {
Preconditions.checkNotNull(color);
Objects.requireNonNull(color);
this.lineColor = color;
this.hasUnsavedChanges = true;
@ -117,27 +118,26 @@ public void load(BlueMapAPI api, ConfigurationNode markerNode, boolean overwrite
if (!overwriteChanges && hasUnsavedChanges) return;
this.hasUnsavedChanges = false;
this.line = readLine(markerNode.getNode("line"));
this.depthTest = markerNode.getNode("depthTest").getBoolean(true);
this.lineWidth = markerNode.getNode("lineWidth").getInt(2);
this.lineColor = readColor(markerNode.getNode("lineColor"));
this.line = readLine(markerNode.node("line"));
this.depthTest = markerNode.node("depthTest").getBoolean(true);
this.lineWidth = markerNode.node("lineWidth").getInt(2);
this.lineColor = readColor(markerNode.node("lineColor"));
}
@Override
public void save(ConfigurationNode markerNode) {
public void save(ConfigurationNode markerNode) throws SerializationException {
super.save(markerNode);
writeLine(markerNode.getNode("line"), this.line);
markerNode.getNode("depthTest").setValue(this.depthTest);
markerNode.getNode("lineWidth").setValue(this.lineWidth);
writeColor(markerNode.getNode("lineColor"), this.lineColor);
writeLine(markerNode.node("line"), this.line);
markerNode.node("depthTest").set(this.depthTest);
markerNode.node("lineWidth").set(this.lineWidth);
writeColor(markerNode.node("lineColor"), this.lineColor);
hasUnsavedChanges = false;
}
private Line readLine(ConfigurationNode node) throws MarkerFileFormatException {
List<? extends ConfigurationNode> posNodes = node.getChildrenList();
List<? extends ConfigurationNode> posNodes = node.childrenList();
if (posNodes.size() < 3) throw new MarkerFileFormatException("Failed to read line: point-list has fewer than 2 entries!");
@ -151,11 +151,11 @@ private Line readLine(ConfigurationNode node) throws MarkerFileFormatException {
private static Vector3d readLinePos(ConfigurationNode node) throws MarkerFileFormatException {
ConfigurationNode nx, ny, nz;
nx = node.getNode("x");
ny = node.getNode("y");
nz = node.getNode("z");
nx = node.node("x");
ny = node.node("y");
nz = node.node("z");
if (nx.isVirtual() || ny.isVirtual() || nz.isVirtual()) throw new MarkerFileFormatException("Failed to read line position: Node x, y or z is not set!");
if (nx.virtual() || ny.virtual() || nz.virtual()) throw new MarkerFileFormatException("Failed to read line position: Node x, y or z is not set!");
return new Vector3d(
nx.getDouble(),
@ -166,12 +166,12 @@ private static Vector3d readLinePos(ConfigurationNode node) throws MarkerFileFor
private static Color readColor(ConfigurationNode node) throws MarkerFileFormatException {
ConfigurationNode nr, ng, nb, na;
nr = node.getNode("r");
ng = node.getNode("g");
nb = node.getNode("b");
na = node.getNode("a");
nr = node.node("r");
ng = node.node("g");
nb = node.node("b");
na = node.node("a");
if (nr.isVirtual() || ng.isVirtual() || nb.isVirtual()) throw new MarkerFileFormatException("Failed to read color: Node r,g or b is not set!");
if (nr.virtual() || ng.virtual() || nb.virtual()) throw new MarkerFileFormatException("Failed to read color: Node r,g or b is not set!");
float alpha = na.getFloat(1);
if (alpha < 0 || alpha > 1) throw new MarkerFileFormatException("Failed to read color: alpha value out of range (0-1)!");
@ -183,26 +183,26 @@ private static Color readColor(ConfigurationNode node) throws MarkerFileFormatEx
}
}
private static void writeLine(ConfigurationNode node, Line line) {
private static void writeLine(ConfigurationNode node, Line line) throws SerializationException {
for (int i = 0; i < line.getPointCount(); i++) {
ConfigurationNode pointNode = node.appendListNode();
Vector3d point = line.getPoint(i);
pointNode.getNode("x").setValue(Math.round(point.getX() * 1000d) / 1000d);
pointNode.getNode("y").setValue(Math.round(point.getY() * 1000d) / 1000d);
pointNode.getNode("z").setValue(Math.round(point.getZ() * 1000d) / 1000d);
pointNode.node("x").set(Math.round(point.getX() * 1000d) / 1000d);
pointNode.node("y").set(Math.round(point.getY() * 1000d) / 1000d);
pointNode.node("z").set(Math.round(point.getZ() * 1000d) / 1000d);
}
}
private static void writeColor(ConfigurationNode node, Color color) {
private static void writeColor(ConfigurationNode node, Color color) throws SerializationException {
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
float a = color.getAlpha() / 255f;
node.getNode("r").setValue(r);
node.getNode("g").setValue(g);
node.getNode("b").setValue(b);
node.getNode("a").setValue(a);
node.node("r").set(r);
node.node("g").set(g);
node.node("b").set(b);
node.node("a").set(a);
}
}

View File

@ -24,14 +24,13 @@
*/
package de.bluecolored.bluemap.common.api.marker;
import com.google.common.collect.Sets;
import de.bluecolored.bluemap.api.marker.MarkerAPI;
import de.bluecolored.bluemap.api.marker.MarkerSet;
import de.bluecolored.bluemap.common.api.BlueMapAPIImpl;
import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.core.util.FileUtils;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.gson.GsonConfigurationLoader;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.gson.GsonConfigurationLoader;
import java.io.File;
import java.io.IOException;
@ -50,7 +49,7 @@ public MarkerAPIImpl(BlueMapAPIImpl api, File markerFile) throws IOException {
this.markerFile = markerFile;
this.markerSets = new ConcurrentHashMap<>();
this.removedMarkerSets = Sets.newConcurrentHashSet();
this.removedMarkerSets = Collections.newSetFromMap(new ConcurrentHashMap<>());
load();
}
@ -96,11 +95,11 @@ private synchronized void load(boolean overwriteChanges) throws IOException {
Set<String> externallyRemovedSets = new HashSet<>(markerSets.keySet());
if (markerFile.exists() && markerFile.isFile()) {
GsonConfigurationLoader loader = GsonConfigurationLoader.builder().setFile(markerFile).build();
GsonConfigurationLoader loader = GsonConfigurationLoader.builder().file(markerFile).build();
ConfigurationNode node = loader.load();
for (ConfigurationNode markerSetNode : node.getNode("markerSets").getChildrenList()) {
String setId = markerSetNode.getNode("id").getString();
for (ConfigurationNode markerSetNode : node.node("markerSets").childrenList()) {
String setId = markerSetNode.node("id").getString();
if (setId == null) {
Logger.global.logDebug("Marker-API: Failed to load a markerset: No id defined!");
continue;
@ -140,11 +139,11 @@ public synchronized void save() throws IOException {
FileUtils.createFile(markerFile);
GsonConfigurationLoader loader = GsonConfigurationLoader.builder().setFile(markerFile).build();
ConfigurationNode node = loader.createEmptyNode();
GsonConfigurationLoader loader = GsonConfigurationLoader.builder().file(markerFile).build();
ConfigurationNode node = loader.createNode();
for (MarkerSetImpl set : markerSets.values()) {
set.save(node.getNode("markerSets").appendListNode());
set.save(node.node("markerSets").appendListNode());
}
loader.save(node);

View File

@ -25,12 +25,13 @@
package de.bluecolored.bluemap.common.api.marker;
import com.flowpowered.math.vector.Vector3d;
import com.google.common.base.Preconditions;
import de.bluecolored.bluemap.api.BlueMapAPI;
import de.bluecolored.bluemap.api.BlueMapMap;
import de.bluecolored.bluemap.api.marker.Marker;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.Objects;
import java.util.Optional;
public abstract class MarkerImpl implements Marker {
@ -45,9 +46,9 @@ public abstract class MarkerImpl implements Marker {
private boolean hasUnsavedChanges;
public MarkerImpl(String id, BlueMapMap map, Vector3d position) {
Preconditions.checkNotNull(id);
Preconditions.checkNotNull(map);
Preconditions.checkNotNull(position);
Objects.requireNonNull(id);
Objects.requireNonNull(map);
Objects.requireNonNull(position);
this.id = id;
this.map = map;
@ -151,46 +152,46 @@ public synchronized void load(BlueMapAPI api, ConfigurationNode markerNode, bool
hasUnsavedChanges = false;
//map
String mapId = markerNode.getNode("map").getString();
String mapId = markerNode.node("map").getString();
if (mapId == null) throw new MarkerFileFormatException("There is no map defined!");
this.map = api.getMap(mapId).orElseThrow(() -> new MarkerFileFormatException("Could not resolve map with id: " + mapId));
//position
this.postition = readPos(markerNode.getNode("position"));
this.postition = readPos(markerNode.node("position"));
//minmaxDistance
this.minDistance = markerNode.getNode("minDistance").getDouble(0);
this.maxDistance = markerNode.getNode("maxDistance").getDouble(100000);
this.minDistance = markerNode.node("minDistance").getDouble(0);
this.maxDistance = markerNode.node("maxDistance").getDouble(100000);
//label
this.label = markerNode.getNode("label").getString(this.id);
this.label = markerNode.node("label").getString(this.id);
//link
this.link = markerNode.getNode("link").getString();
this.newTab = markerNode.getNode("newTab").getBoolean(true);
this.link = markerNode.node("link").getString();
this.newTab = markerNode.node("newTab").getBoolean(true);
}
public synchronized void save(ConfigurationNode markerNode) {
markerNode.getNode("id").setValue(this.id);
markerNode.getNode("type").setValue(this.getType());
markerNode.getNode("map").setValue(this.map.getId());
writePos(markerNode.getNode("position"), this.postition);
markerNode.getNode("minDistance").setValue(Math.round(this.minDistance * 1000d) / 1000d);
markerNode.getNode("maxDistance").setValue(Math.round(this.maxDistance * 1000d) / 1000d);
markerNode.getNode("label").setValue(this.label);
markerNode.getNode("link").setValue(this.link);
markerNode.getNode("newTab").setValue(this.newTab);
public synchronized void save(ConfigurationNode markerNode) throws SerializationException {
markerNode.node("id").set(this.id);
markerNode.node("type").set(this.getType());
markerNode.node("map").set(this.map.getId());
writePos(markerNode.node("position"), this.postition);
markerNode.node("minDistance").set(Math.round(this.minDistance * 1000d) / 1000d);
markerNode.node("maxDistance").set(Math.round(this.maxDistance * 1000d) / 1000d);
markerNode.node("label").set(this.label);
markerNode.node("link").set(this.link);
markerNode.node("newTab").set(this.newTab);
hasUnsavedChanges = false;
}
private static Vector3d readPos(ConfigurationNode node) throws MarkerFileFormatException {
ConfigurationNode nx, ny, nz;
nx = node.getNode("x");
ny = node.getNode("y");
nz = node.getNode("z");
nx = node.node("x");
ny = node.node("y");
nz = node.node("z");
if (nx.isVirtual() || ny.isVirtual() || nz.isVirtual()) throw new MarkerFileFormatException("Failed to read position: One of the nodes x,y or z is missing!");
if (nx.virtual() || ny.virtual() || nz.virtual()) throw new MarkerFileFormatException("Failed to read position: One of the nodes x,y or z is missing!");
return new Vector3d(
nx.getDouble(),
@ -199,10 +200,10 @@ private static Vector3d readPos(ConfigurationNode node) throws MarkerFileFormatE
);
}
private static void writePos(ConfigurationNode node, Vector3d pos) {
node.getNode("x").setValue(Math.round(pos.getX() * 1000d) / 1000d);
node.getNode("y").setValue(Math.round(pos.getY() * 1000d) / 1000d);
node.getNode("z").setValue(Math.round(pos.getZ() * 1000d) / 1000d);
private static void writePos(ConfigurationNode node, Vector3d pos) throws SerializationException {
node.node("x").set(Math.round(pos.getX() * 1000d) / 1000d);
node.node("y").set(Math.round(pos.getY() * 1000d) / 1000d);
node.node("z").set(Math.round(pos.getZ() * 1000d) / 1000d);
}
@Override

View File

@ -25,7 +25,6 @@
package de.bluecolored.bluemap.common.api.marker;
import com.flowpowered.math.vector.Vector3d;
import com.google.common.collect.Sets;
import de.bluecolored.bluemap.api.BlueMapAPI;
import de.bluecolored.bluemap.api.BlueMapMap;
import de.bluecolored.bluemap.api.marker.Line;
@ -33,7 +32,8 @@
import de.bluecolored.bluemap.api.marker.MarkerSet;
import de.bluecolored.bluemap.api.marker.Shape;
import de.bluecolored.bluemap.core.logger.Logger;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@ -57,7 +57,7 @@ public MarkerSetImpl(String id) {
this.isDefaultHidden = false;
this.markers = new ConcurrentHashMap<>();
this.removedMarkers = Sets.newConcurrentHashSet();
this.removedMarkers = Collections.newSetFromMap(new ConcurrentHashMap<>());
this.hasUnsavedChanges = true;
}
@ -175,9 +175,9 @@ public synchronized void load(BlueMapAPI api, ConfigurationNode node, boolean ov
Line dummyLine = new Line(Vector3d.ZERO, Vector3d.ONE);
Set<String> externallyRemovedMarkers = new HashSet<>(this.markers.keySet());
for (ConfigurationNode markerNode : node.getNode("marker").getChildrenList()) {
String id = markerNode.getNode("id").getString();
String type = markerNode.getNode("type").getString();
for (ConfigurationNode markerNode : node.node("marker").childrenList()) {
String id = markerNode.node("id").getString();
String type = markerNode.node("type").getString();
if (id == null || type == null) {
Logger.global.logDebug("Marker-API: Failed to load a marker in the set '" + this.id + "': No id or type defined!");
@ -238,19 +238,19 @@ public synchronized void load(BlueMapAPI api, ConfigurationNode node, boolean ov
if (!overwriteChanges && hasUnsavedChanges) return;
hasUnsavedChanges = false;
this.label = node.getNode("label").getString(id);
this.toggleable = node.getNode("toggleable").getBoolean(true);
this.isDefaultHidden = node.getNode("defaultHide").getBoolean(false);
this.label = node.node("label").getString(id);
this.toggleable = node.node("toggleable").getBoolean(true);
this.isDefaultHidden = node.node("defaultHide").getBoolean(false);
}
public synchronized void save(ConfigurationNode node) {
node.getNode("id").setValue(this.id);
node.getNode("label").setValue(this.label);
node.getNode("toggleable").setValue(this.toggleable);
node.getNode("defaultHide").setValue(this.isDefaultHidden);
public synchronized void save(ConfigurationNode node) throws SerializationException {
node.node("id").set(this.id);
node.node("label").set(this.label);
node.node("toggleable").set(this.toggleable);
node.node("defaultHide").set(this.isDefaultHidden);
for (MarkerImpl marker : markers.values()) {
marker.save(node.getNode("marker").appendListNode());
marker.save(node.node("marker").appendListNode());
}
removedMarkers.clear();

View File

@ -28,7 +28,8 @@
import de.bluecolored.bluemap.api.BlueMapAPI;
import de.bluecolored.bluemap.api.BlueMapMap;
import de.bluecolored.bluemap.api.marker.ObjectMarker;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
public abstract class ObjectMarkerImpl extends MarkerImpl implements ObjectMarker {
@ -63,14 +64,14 @@ public void load(BlueMapAPI api, ConfigurationNode markerNode, boolean overwrite
if (!overwriteChanges && hasUnsavedChanges) return;
this.hasUnsavedChanges = false;
this.detail = markerNode.getNode("detail").getString();
this.detail = markerNode.node("detail").getString();
}
@Override
public void save(ConfigurationNode markerNode) {
public void save(ConfigurationNode markerNode) throws SerializationException {
super.save(markerNode);
if (this.detail != null) markerNode.getNode("detail").setValue(this.detail);
if (this.detail != null) markerNode.node("detail").set(this.detail);
hasUnsavedChanges = false;
}

View File

@ -30,7 +30,8 @@
import de.bluecolored.bluemap.api.BlueMapAPI;
import de.bluecolored.bluemap.api.BlueMapMap;
import de.bluecolored.bluemap.api.marker.POIMarker;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
public class POIMarkerImpl extends MarkerImpl implements POIMarker {
public static final String MARKER_TYPE = "poi";
@ -78,33 +79,33 @@ public synchronized void load(BlueMapAPI api, ConfigurationNode markerNode, bool
if (!overwriteChanges && hasUnsavedChanges) return;
this.hasUnsavedChanges = false;
this.iconAddress = markerNode.getNode("icon").getString("assets/poi.svg");
this.iconAddress = markerNode.node("icon").getString("assets/poi.svg");
ConfigurationNode anchorNode = markerNode.getNode("anchor");
if (anchorNode.isVirtual()) anchorNode = markerNode.getNode("iconAnchor"); //fallback to deprecated "iconAnchor"
ConfigurationNode anchorNode = markerNode.node("anchor");
if (anchorNode.virtual()) anchorNode = markerNode.node("iconAnchor"); //fallback to deprecated "iconAnchor"
this.anchor = readAnchor(anchorNode);
}
@Override
public synchronized void save(ConfigurationNode markerNode) {
public synchronized void save(ConfigurationNode markerNode) throws SerializationException {
super.save(markerNode);
markerNode.getNode("icon").setValue(this.iconAddress);
writeAnchor(markerNode.getNode("anchor"), this.anchor);
markerNode.node("icon").set(this.iconAddress);
writeAnchor(markerNode.node("anchor"), this.anchor);
hasUnsavedChanges = false;
}
private static Vector2i readAnchor(ConfigurationNode node) {
return new Vector2i(
node.getNode("x").getInt(0),
node.getNode("y").getInt(0)
node.node("x").getInt(0),
node.node("y").getInt(0)
);
}
private static void writeAnchor(ConfigurationNode node, Vector2i anchor) {
node.getNode("x").setValue(anchor.getX());
node.getNode("y").setValue(anchor.getY());
private static void writeAnchor(ConfigurationNode node, Vector2i anchor) throws SerializationException {
node.node("x").set(anchor.getX());
node.node("y").set(anchor.getY());
}
}

View File

@ -26,15 +26,16 @@
import com.flowpowered.math.vector.Vector2d;
import com.flowpowered.math.vector.Vector3d;
import com.google.common.base.Preconditions;
import de.bluecolored.bluemap.api.BlueMapAPI;
import de.bluecolored.bluemap.api.BlueMapMap;
import de.bluecolored.bluemap.api.marker.Shape;
import de.bluecolored.bluemap.api.marker.ShapeMarker;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.awt.*;
import java.util.List;
import java.util.Objects;
public class ShapeMarkerImpl extends ObjectMarkerImpl implements ShapeMarker {
public static final String MARKER_TYPE = "shape";
@ -50,7 +51,7 @@ public class ShapeMarkerImpl extends ObjectMarkerImpl implements ShapeMarker {
public ShapeMarkerImpl(String id, BlueMapMap map, Vector3d position, Shape shape, float shapeY) {
super(id, map, position);
Preconditions.checkNotNull(shape);
Objects.requireNonNull(shape);
this.shape = shape;
this.shapeY = shapeY;
@ -78,7 +79,7 @@ public float getShapeY() {
@Override
public synchronized void setShape(Shape shape, float shapeY) {
Preconditions.checkNotNull(shape);
Objects.requireNonNull(shape);
this.shape = shape;
this.shapeY = shapeY;
@ -114,7 +115,7 @@ public Color getLineColor() {
@Override
public synchronized void setLineColor(Color color) {
Preconditions.checkNotNull(color);
Objects.requireNonNull(color);
this.lineColor = color;
this.hasUnsavedChanges = true;
@ -127,7 +128,7 @@ public Color getFillColor() {
@Override
public synchronized void setFillColor(Color color) {
Preconditions.checkNotNull(color);
Objects.requireNonNull(color);
this.fillColor = color;
this.hasUnsavedChanges = true;
@ -140,34 +141,34 @@ public void load(BlueMapAPI api, ConfigurationNode markerNode, boolean overwrite
if (!overwriteChanges && hasUnsavedChanges) return;
this.hasUnsavedChanges = false;
this.shape = readShape(markerNode.getNode("shape"));
this.shapeY = markerNode.getNode("shapeY").getFloat(markerNode.getNode("height").getFloat(64)); // fallback to deprecated "height"
this.depthTest = markerNode.getNode("depthTest").getBoolean(true);
this.lineWidth = markerNode.getNode("lineWidth").getInt(2);
this.shape = readShape(markerNode.node("shape"));
this.shapeY = markerNode.node("shapeY").getFloat(markerNode.node("height").getFloat(64)); // fallback to deprecated "height"
this.depthTest = markerNode.node("depthTest").getBoolean(true);
this.lineWidth = markerNode.node("lineWidth").getInt(2);
ConfigurationNode lineColorNode = markerNode.getNode("lineColor");
if (lineColorNode.isVirtual()) lineColorNode = markerNode.getNode("borderColor"); // fallback to deprecated "borderColor"
ConfigurationNode lineColorNode = markerNode.node("lineColor");
if (lineColorNode.virtual()) lineColorNode = markerNode.node("borderColor"); // fallback to deprecated "borderColor"
this.lineColor = readColor(lineColorNode);
this.fillColor = readColor(markerNode.getNode("fillColor"));
this.fillColor = readColor(markerNode.node("fillColor"));
}
@Override
public void save(ConfigurationNode markerNode) {
public void save(ConfigurationNode markerNode) throws SerializationException {
super.save(markerNode);
writeShape(markerNode.getNode("shape"), this.shape);
markerNode.getNode("shapeY").setValue(Math.round(shapeY * 1000f) / 1000f);
markerNode.getNode("depthTest").setValue(this.depthTest);
markerNode.getNode("lineWidth").setValue(this.lineWidth);
writeColor(markerNode.getNode("lineColor"), this.lineColor);
writeColor(markerNode.getNode("fillColor"), this.fillColor);
writeShape(markerNode.node("shape"), this.shape);
markerNode.node("shapeY").set(Math.round(shapeY * 1000f) / 1000f);
markerNode.node("depthTest").set(this.depthTest);
markerNode.node("lineWidth").set(this.lineWidth);
writeColor(markerNode.node("lineColor"), this.lineColor);
writeColor(markerNode.node("fillColor"), this.fillColor);
hasUnsavedChanges = false;
}
private Shape readShape(ConfigurationNode node) throws MarkerFileFormatException {
List<? extends ConfigurationNode> posNodes = node.getChildrenList();
List<? extends ConfigurationNode> posNodes = node.childrenList();
if (posNodes.size() < 3) throw new MarkerFileFormatException("Failed to read shape: point-list has fewer than 3 entries!");
@ -181,10 +182,10 @@ private Shape readShape(ConfigurationNode node) throws MarkerFileFormatException
private static Vector2d readShapePos(ConfigurationNode node) throws MarkerFileFormatException {
ConfigurationNode nx, nz;
nx = node.getNode("x");
nz = node.getNode("z");
nx = node.node("x");
nz = node.node("z");
if (nx.isVirtual() || nz.isVirtual()) throw new MarkerFileFormatException("Failed to read shape position: Node x or z is not set!");
if (nx.virtual() || nz.virtual()) throw new MarkerFileFormatException("Failed to read shape position: Node x or z is not set!");
return new Vector2d(
nx.getDouble(),
@ -194,12 +195,12 @@ private static Vector2d readShapePos(ConfigurationNode node) throws MarkerFileFo
private static Color readColor(ConfigurationNode node) throws MarkerFileFormatException {
ConfigurationNode nr, ng, nb, na;
nr = node.getNode("r");
ng = node.getNode("g");
nb = node.getNode("b");
na = node.getNode("a");
nr = node.node("r");
ng = node.node("g");
nb = node.node("b");
na = node.node("a");
if (nr.isVirtual() || ng.isVirtual() || nb.isVirtual()) throw new MarkerFileFormatException("Failed to read color: Node r,g or b is not set!");
if (nr.virtual() || ng.virtual() || nb.virtual()) throw new MarkerFileFormatException("Failed to read color: Node r,g or b is not set!");
float alpha = na.getFloat(1);
if (alpha < 0 || alpha > 1) throw new MarkerFileFormatException("Failed to read color: alpha value out of range (0-1)!");
@ -211,25 +212,25 @@ private static Color readColor(ConfigurationNode node) throws MarkerFileFormatEx
}
}
private static void writeShape(ConfigurationNode node, Shape shape) {
private static void writeShape(ConfigurationNode node, Shape shape) throws SerializationException {
for (int i = 0; i < shape.getPointCount(); i++) {
ConfigurationNode pointNode = node.appendListNode();
Vector2d point = shape.getPoint(i);
pointNode.getNode("x").setValue(Math.round(point.getX() * 1000d) / 1000d);
pointNode.getNode("z").setValue(Math.round(point.getY() * 1000d) / 1000d);
pointNode.node("x").set(Math.round(point.getX() * 1000d) / 1000d);
pointNode.node("z").set(Math.round(point.getY() * 1000d) / 1000d);
}
}
private static void writeColor(ConfigurationNode node, Color color) {
private static void writeColor(ConfigurationNode node, Color color) throws SerializationException {
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
float a = color.getAlpha() / 255f;
node.getNode("r").setValue(r);
node.getNode("g").setValue(g);
node.getNode("b").setValue(b);
node.getNode("a").setValue(a);
node.node("r").set(r);
node.node("g").set(g);
node.node("b").set(b);
node.node("a").set(a);
}
}

View File

@ -24,12 +24,12 @@
*/
package de.bluecolored.bluemap.common.plugin;
import org.spongepowered.configurate.ConfigurationNode;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import ninja.leaping.configurate.ConfigurationNode;
public class PluginConfig {
private boolean liveUpdatesEnabled = false;
@ -41,23 +41,23 @@ public class PluginConfig {
public PluginConfig(ConfigurationNode node) {
//liveUpdates
liveUpdatesEnabled = node.getNode("liveUpdates").getBoolean(true);
liveUpdatesEnabled = node.node("liveUpdates").getBoolean(true);
//skinDownloadEnabled
skinDownloadEnabled = node.getNode("skinDownload").getBoolean(true);
skinDownloadEnabled = node.node("skinDownload").getBoolean(true);
//hiddenGameModes
hiddenGameModes = new ArrayList<>();
for (ConfigurationNode gameModeNode : node.getNode("hiddenGameModes").getChildrenList()) {
for (ConfigurationNode gameModeNode : node.node("hiddenGameModes").childrenList()) {
hiddenGameModes.add(gameModeNode.getString());
}
hiddenGameModes = Collections.unmodifiableCollection(hiddenGameModes);
//hideInvisible
hideInvisible = node.getNode("hideInvisible").getBoolean(true);
hideInvisible = node.node("hideInvisible").getBoolean(true);
//hideSneaking
hideSneaking = node.getNode("hideSneaking").getBoolean(false);
hideSneaking = node.node("hideSneaking").getBoolean(false);
}

View File

@ -0,0 +1,34 @@
/*
* This file is part of BlueMap, licensed under the MIT License (MIT).
*
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package de.bluecolored.bluemap.common.plugin;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
@ConfigSerializable
public class PluginStatus {
}

View File

@ -27,7 +27,6 @@
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3d;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.collect.Lists;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.ArgumentType;
@ -67,10 +66,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;
@ -315,14 +311,6 @@ private Optional<BmMap> parseMap(String mapId) {
return Optional.empty();
}
private Optional<UUID> parseUUID(String uuidString) {
try {
return Optional.of(UUID.fromString(uuidString));
} catch (IllegalArgumentException ex) {
return Optional.empty();
}
}
// --- COMMANDS ---
@ -520,7 +508,7 @@ public int debugBlockCommand(CommandContext<S> context) {
}
}
source.sendMessages(Lists.newArrayList(
source.sendMessages(Arrays.asList(
Text.of(TextColor.GOLD, "Block at you: ", TextColor.WHITE, block, TextColor.GRAY, blockIdMeta),
Text.of(TextColor.GOLD, "Block below you: ", TextColor.WHITE, blockBelow, TextColor.GRAY, blockBelowIdMeta)
));

View File

@ -1,3 +1,27 @@
/*
* This file is part of BlueMap, licensed under the MIT License (MIT).
*
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package de.bluecolored.bluemap.common.rendermanager;
import com.flowpowered.math.vector.Vector2i;

View File

@ -30,9 +30,10 @@
import de.bluecolored.bluemap.core.map.BmMap;
import de.bluecolored.bluemap.core.util.FileUtils;
import de.bluecolored.bluemap.core.util.MathUtils;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.gson.GsonConfigurationLoader;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.gson.GsonConfigurationLoader;
import org.spongepowered.configurate.loader.ConfigurationLoader;
import org.spongepowered.configurate.serialize.SerializationException;
import java.io.File;
import java.io.IOException;
@ -41,14 +42,14 @@
public class WebSettings {
private ConfigurationLoader<? extends ConfigurationNode> configLoader;
private final ConfigurationLoader<? extends ConfigurationNode> configLoader;
private ConfigurationNode rootNode;
public WebSettings(File settingsFile) throws IOException {
FileUtils.createFile(settingsFile);
configLoader = GsonConfigurationLoader.builder()
.setFile(settingsFile)
.file(settingsFile)
.build();
load();
@ -62,49 +63,49 @@ public void save() throws IOException {
configLoader.save(rootNode);
}
public void set(Object value, Object... path) {
rootNode.getNode(path).setValue(value);
public void set(Object value, Object... path) throws SerializationException {
rootNode.node(path).set(value);
}
public Object get(Object... path) {
return rootNode.getNode(path).getValue();
return rootNode.node(path).raw();
}
public String getString(Object... path) {
return rootNode.getNode(path).getString();
return rootNode.node(path).getString();
}
public int getInt(Object... path) {
return rootNode.getNode(path).getInt();
return rootNode.node(path).getInt();
}
public long getLong(Object... path) {
return rootNode.getNode(path).getLong();
return rootNode.node(path).getLong();
}
public float getFloat(Object... path) {
return rootNode.getNode(path).getFloat();
return rootNode.node(path).getFloat();
}
public double getDouble(Object... path) {
return rootNode.getNode(path).getDouble();
return rootNode.node(path).getDouble();
}
public Collection<String> getMapIds() {
return rootNode.getNode("maps").getChildrenMap().keySet().stream().map(Object::toString).collect(Collectors.toSet());
return rootNode.node("maps").childrenMap().keySet().stream().map(Object::toString).collect(Collectors.toSet());
}
public void setAllMapsEnabled(boolean enabled) {
for (ConfigurationNode mapNode : rootNode.getNode("maps").getChildrenMap().values()) {
mapNode.getNode("enabled").setValue(enabled);
public void setAllMapsEnabled(boolean enabled) throws SerializationException {
for (ConfigurationNode mapNode : rootNode.node("maps").childrenMap().values()) {
mapNode.node("enabled").set(enabled);
}
}
public void setMapEnabled(boolean enabled, String mapId) {
public void setMapEnabled(boolean enabled, String mapId) throws SerializationException {
set(enabled, "maps", mapId, "enabled");
}
public void setFrom(BmMap map) {
public void setFrom(BmMap map) throws SerializationException {
Vector2i hiresTileSize = map.getHiresModelManager().getTileGrid().getGridSize();
Vector2i gridOrigin = map.getHiresModelManager().getTileGrid().getOffset();
Vector2i lowresTileSize = map.getLowresModelManager().getTileSize();
@ -132,7 +133,7 @@ public void setFrom(BmMap map) {
set(map.getWorld().getUUID().toString(), "maps", map.getId(), "world");
}
public void setFrom(MapConfig mapConfig) {
public void setFrom(MapConfig mapConfig) throws SerializationException {
Vector2i startPos = mapConfig.getStartPos();
if (startPos != null) {
set(startPos.getX(), "maps", mapConfig.getId(), "startPos", "x");
@ -149,7 +150,7 @@ public void setFrom(MapConfig mapConfig) {
setName(mapConfig.getName(), mapConfig.getId());
}
public void setOrdinal(int ordinal, String mapId) {
public void setOrdinal(int ordinal, String mapId) throws SerializationException {
set(ordinal, "maps", mapId, "ordinal");
}
@ -157,7 +158,7 @@ public int getOrdinal(String mapId) {
return getInt("maps", mapId, "ordinal");
}
public void setName(String name, String mapId) {
public void setName(String name, String mapId) throws SerializationException {
set(name, "maps", mapId, "name");
}

View File

@ -1,12 +1,12 @@
dependencies {
compile 'com.github.ben-manes.caffeine:caffeine:2.8.5'
compile 'com.google.code.gson:gson:2.8.0'
compile 'org.apache.commons:commons-lang3:3.6'
compile group: 'commons-io', name: 'commons-io', version: '2.5'
compile 'com.flowpowered:flow-math:1.0.3'
compile 'org.spongepowered:configurate-hocon:3.7.1'
compile 'org.spongepowered:configurate-gson:3.7.1'
compile 'com.github.Querz:NBT:4.0'
api 'com.github.ben-manes.caffeine:caffeine:2.8.5'
api 'com.google.code.gson:gson:2.8.0'
api 'org.apache.commons:commons-lang3:3.6'
api group: 'commons-io', name: 'commons-io', version: '2.5'
api 'com.flowpowered:flow-math:1.0.3'
api 'org.spongepowered:configurate-hocon:4.1.1'
api 'org.spongepowered:configurate-gson:4.1.1'
api 'com.github.Querz:NBT:4.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
}
@ -18,6 +18,7 @@ test {
processResources {
from(sourceSets.main.resources.srcDirs) {
include 'de/bluecolored/bluemap/version.json'
duplicatesStrategy = DuplicatesStrategy.WARN
expand (
version: project.version

View File

@ -25,7 +25,7 @@
package de.bluecolored.bluemap.core;
import de.bluecolored.bluemap.core.logger.Logger;
import ninja.leaping.configurate.gson.GsonConfigurationLoader;
import org.spongepowered.configurate.gson.GsonConfigurationLoader;
import java.io.IOException;
import java.util.concurrent.ForkJoinPool;
@ -36,7 +36,7 @@ public class BlueMap {
static {
String version = "DEV";
try {
version = GsonConfigurationLoader.builder().setURL(BlueMap.class.getResource("/de/bluecolored/bluemap/version.json")).build().load().getNode("version").getString("DEV");
version = GsonConfigurationLoader.builder().url(BlueMap.class.getResource("/de/bluecolored/bluemap/version.json")).build().load().node("version").getString("DEV");
} catch (IOException ex) {
Logger.global.logError("Failed to load version.json from resources!", ex);
}

View File

@ -24,21 +24,21 @@
*/
package de.bluecolored.bluemap.core.config;
import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.core.mca.mapping.BiomeMapper;
import de.bluecolored.bluemap.core.world.Biome;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.loader.ConfigurationLoader;
import java.io.IOException;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.core.mca.mapping.BiomeMapper;
import de.bluecolored.bluemap.core.world.Biome;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.loader.ConfigurationLoader;
public class BiomeConfig implements BiomeMapper {
private ConfigurationLoader<? extends ConfigurationNode> autopoulationConfigLoader;
private Map<Integer, Biome> biomes;
private final ConfigurationLoader<? extends ConfigurationNode> autopoulationConfigLoader;
private final Map<Integer, Biome> biomes;
public BiomeConfig(ConfigurationNode node) {
this(node, null);
@ -49,7 +49,7 @@ public BiomeConfig(ConfigurationNode node, ConfigurationLoader<? extends Configu
biomes = new ConcurrentHashMap<>(200, 0.5f, 8);
for (Entry<Object, ? extends ConfigurationNode> e : node.getChildrenMap().entrySet()){
for (Entry<Object, ? extends ConfigurationNode> e : node.childrenMap().entrySet()){
String id = e.getKey().toString();
Biome biome = Biome.create(id, e.getValue());
biomes.put(biome.getNumeralId(), biome);
@ -68,7 +68,7 @@ public Biome get(int id) {
synchronized (autopoulationConfigLoader) {
try {
ConfigurationNode node = autopoulationConfigLoader.load();
node.getNode("unknown:" + id).getNode("id").setValue(id);
node.node("unknown:" + id).node("id").set(id);
autopoulationConfigLoader.save(node);
} catch (IOException ex) {
Logger.global.noFloodError("biomeconf-autopopulate-ioex", "Failed to auto-populate BiomeConfig!", ex);

View File

@ -24,12 +24,11 @@
*/
package de.bluecolored.bluemap.core.config;
import com.google.common.base.Preconditions;
import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.core.mca.mapping.BlockIdMapper;
import de.bluecolored.bluemap.core.world.BlockState;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.loader.ConfigurationLoader;
import java.io.IOException;
import java.util.Map;
@ -57,7 +56,7 @@ public BlockIdConfig(ConfigurationNode node, ConfigurationLoader<? extends Confi
this.lock = new ReentrantReadWriteLock();
for (Entry<Object, ? extends ConfigurationNode> e : node.getChildrenMap().entrySet()){
for (Entry<Object, ? extends ConfigurationNode> e : node.childrenMap().entrySet()){
String key = e.getKey().toString();
String value = e.getValue().getString();
@ -119,7 +118,7 @@ public BlockState get(int numeralId, int meta) {
if (autopoulationConfigLoader != null) {
try {
ConfigurationNode node = autopoulationConfigLoader.load();
node.getNode(numeralId + ":" + meta).setValue(state.toString());
node.node(numeralId + ":" + meta).set(state.toString());
autopoulationConfigLoader.save(node);
} catch (IOException ex) {
Logger.global.noFloodError("blockidconf-autopopulate-ioex", "Failed to auto-populate BlockIdConfig!", ex);
@ -165,12 +164,11 @@ public BlockState get(String id, int numeralId, int meta) {
}
idMappings.put(idmeta, state);
Preconditions.checkArgument(numeralMappings.put(numidmeta, state) == null);
if (autopoulationConfigLoader != null) {
try {
ConfigurationNode node = autopoulationConfigLoader.load();
node.getNode(id + ":" + meta).setValue(state.toString());
node.node(id + ":" + meta).set(state.toString());
autopoulationConfigLoader.save(node);
} catch (IOException ex) {
Logger.global.noFloodError("blockidconf-autopopulate-ioex", "Failed to auto-populate BlockIdConfig!", ex);

View File

@ -24,15 +24,8 @@
*/
package de.bluecolored.bluemap.core.config;
import java.io.IOException;
import java.util.Map.Entry;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Multimaps;
import de.bluecolored.bluemap.core.BlueMap;
import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.core.mca.mapping.BlockPropertiesMapper;
@ -41,39 +34,47 @@
import de.bluecolored.bluemap.core.resourcepack.TransformedBlockModelResource;
import de.bluecolored.bluemap.core.world.BlockProperties;
import de.bluecolored.bluemap.core.world.BlockState;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.loader.ConfigurationLoader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
public class BlockPropertiesConfig implements BlockPropertiesMapper {
private ConfigurationLoader<? extends ConfigurationNode> autopoulationConfigLoader;
private final ConfigurationLoader<? extends ConfigurationNode> autopoulationConfigLoader;
private Multimap<String, BlockStateMapping<BlockProperties>> mappings;
private LoadingCache<BlockState, BlockProperties> mappingCache;
private final Map<String, List<BlockStateMapping<BlockProperties>>> mappings;
private final LoadingCache<BlockState, BlockProperties> mappingCache;
private ResourcePack resourcePack = null;
private final ResourcePack resourcePack;
public BlockPropertiesConfig(ConfigurationNode node, ResourcePack resourcePack) throws IOException {
public BlockPropertiesConfig(ConfigurationNode node, ResourcePack resourcePack) {
this(node, resourcePack, null);
}
public BlockPropertiesConfig(ConfigurationNode node, ResourcePack resourcePack, ConfigurationLoader<? extends ConfigurationNode> autopoulationConfigLoader) throws IOException {
public BlockPropertiesConfig(ConfigurationNode node, ResourcePack resourcePack, ConfigurationLoader<? extends ConfigurationNode> autopoulationConfigLoader) {
this.resourcePack = resourcePack;
this.autopoulationConfigLoader = autopoulationConfigLoader;
mappings = Multimaps.synchronizedListMultimap(MultimapBuilder.hashKeys().arrayListValues().build());
mappings = new ConcurrentHashMap<>();
for (Entry<Object, ? extends ConfigurationNode> e : node.getChildrenMap().entrySet()){
for (Entry<Object, ? extends ConfigurationNode> e : node.childrenMap().entrySet()){
String key = e.getKey().toString();
try {
BlockState bsKey = BlockState.fromString(key);
BlockProperties bsValue = new BlockProperties(
e.getValue().getNode("culling").getBoolean(true),
e.getValue().getNode("occluding").getBoolean(true),
e.getValue().getNode("flammable").getBoolean(false)
e.getValue().node("culling").getBoolean(true),
e.getValue().node("occluding").getBoolean(true),
e.getValue().node("flammable").getBoolean(false)
);
BlockStateMapping<BlockProperties> mapping = new BlockStateMapping<>(bsKey, bsValue);
mappings.put(bsKey.getFullId(), mapping);
mappings.computeIfAbsent(bsKey.getFullId(), k -> new ArrayList<>()).add(mapping);
} catch (IllegalArgumentException ex) {
Logger.global.logWarning("Loading BlockPropertiesConfig: Failed to parse BlockState from key '" + key + "'");
}
@ -82,7 +83,7 @@ public BlockPropertiesConfig(ConfigurationNode node, ResourcePack resourcePack,
mappingCache = Caffeine.newBuilder()
.executor(BlueMap.THREAD_POOL)
.maximumSize(10000)
.build(key -> mapNoCache(key));
.build(this::mapNoCache);
}
@Override
@ -91,7 +92,7 @@ public BlockProperties get(BlockState from){
}
private BlockProperties mapNoCache(BlockState bs){
for (BlockStateMapping<BlockProperties> bm : mappings.get(bs.getFullId())){
for (BlockStateMapping<BlockProperties> bm : mappings.getOrDefault(bs.getFullId(), Collections.emptyList())){
if (bm.fitsTo(bs)){
return bm.getMapping();
}
@ -114,15 +115,15 @@ private BlockProperties mapNoCache(BlockState bs){
} catch (NoSuchResourceException ignore) {} //ignoring this because it will be logged later again if we try to render that block
}
mappings.put(bs.getFullId(), new BlockStateMapping<BlockProperties>(new BlockState(bs.getFullId()), generated));
mappings.computeIfAbsent(bs.getFullId(), k -> new ArrayList<>()).add(new BlockStateMapping<>(new BlockState(bs.getFullId()), generated));
if (autopoulationConfigLoader != null) {
synchronized (autopoulationConfigLoader) {
try {
ConfigurationNode node = autopoulationConfigLoader.load();
ConfigurationNode bpNode = node.getNode(bs.getFullId());
bpNode.getNode("culling").setValue(generated.isCulling());
bpNode.getNode("occluding").setValue(generated.isOccluding());
bpNode.getNode("flammable").setValue(generated.isFlammable());
ConfigurationNode bpNode = node.node(bs.getFullId());
bpNode.node("culling").set(generated.isCulling());
bpNode.node("occluding").set(generated.isOccluding());
bpNode.node("flammable").set(generated.isFlammable());
autopoulationConfigLoader.save(node);
} catch (IOException ex) {
Logger.global.noFloodError("blockpropsconf-autopopulate-ioex", "Failed to auto-populate BlockPropertiesConfig!", ex);

View File

@ -24,16 +24,17 @@
*/
package de.bluecolored.bluemap.core.config;
import com.google.common.base.Preconditions;
import de.bluecolored.bluemap.core.BlueMap;
import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.core.resourcepack.ResourcePack;
import de.bluecolored.bluemap.core.resourcepack.ResourcePack.Resource;
import de.bluecolored.bluemap.core.util.FileUtils;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.gson.GsonConfigurationLoader;
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import de.bluecolored.bluemap.core.util.Preconditions;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.gson.GsonConfigurationLoader;
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
import org.spongepowered.configurate.loader.ConfigurationLoader;
import java.io.*;
import java.net.URL;
@ -41,6 +42,7 @@
import java.nio.file.Files;
import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@ -96,7 +98,7 @@ public ConfigurationNode loadOrCreate(File configFile, URL defaultConfig, URL de
} else {
//create empty config
ConfigurationLoader<? extends ConfigurationNode> loader = getLoader(configFile);
configNode = loader.createEmptyNode();
configNode = loader.createNode();
//save to create file
if (generateEmptyConfig) loader.save(configNode);
@ -109,7 +111,7 @@ public ConfigurationNode loadOrCreate(File configFile, URL defaultConfig, URL de
//populate missing values with default values
if (defaultValues != null) {
ConfigurationNode defaultValuesNode = getLoader(defaultValues).load();
configNode.mergeValuesFrom(defaultValuesNode);
configNode.mergeFrom(defaultValuesNode);
}
return configNode;
@ -196,7 +198,7 @@ private ConfigurationNode joinFromResourcePack(ResourcePack resourcePack, String
try {
ConfigurationNode node = getLoader(configFileName, resource.read()).load();
if (joinedNode == null) joinedNode = node;
else joinedNode.mergeValuesFrom(node);
else joinedNode.mergeFrom(node);
} catch (IOException ex) {
Logger.global.logWarning("Failed to load an additional " + configFileName + " from the resource-pack! " + ex);
}
@ -204,7 +206,7 @@ private ConfigurationNode joinFromResourcePack(ResourcePack resourcePack, String
if (joinedNode == null) return defaultConfig;
joinedNode.mergeValuesFrom(defaultConfig);
joinedNode.mergeFrom(defaultConfig);
return joinedNode;
}
@ -212,22 +214,22 @@ private ConfigurationNode joinFromResourcePack(ResourcePack resourcePack, String
private ConfigurationLoader<? extends ConfigurationNode> getLoader(String filename, InputStream is){
BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
if (filename.endsWith(".json")) return GsonConfigurationLoader.builder().setSource(() -> reader).build();
else return HoconConfigurationLoader.builder().setSource(() -> reader).build();
if (filename.endsWith(".json")) return GsonConfigurationLoader.builder().source(() -> reader).build();
else return HoconConfigurationLoader.builder().source(() -> reader).build();
}
private ConfigurationLoader<? extends ConfigurationNode> getLoader(URL url){
if (url.getFile().endsWith(".json")) return GsonConfigurationLoader.builder().setURL(url).build();
else return HoconConfigurationLoader.builder().setURL(url).build();
if (url.getFile().endsWith(".json")) return GsonConfigurationLoader.builder().url(url).build();
else return HoconConfigurationLoader.builder().url(url).build();
}
private ConfigurationLoader<? extends ConfigurationNode> getLoader(File file){
if (file.getName().endsWith(".json")) return GsonConfigurationLoader.builder().setFile(file).build();
else return HoconConfigurationLoader.builder().setFile(file).build();
if (file.getName().endsWith(".json")) return GsonConfigurationLoader.builder().file(file).build();
else return HoconConfigurationLoader.builder().file(file).build();
}
public static File toFolder(String pathString) throws IOException {
Preconditions.checkNotNull(pathString);
Objects.requireNonNull(pathString);
File file = new File(pathString);
if (file.exists() && !file.isDirectory()) throw new IOException("Invalid configuration: Path '" + file.getAbsolutePath() + "' is a file (should be a directory)");

View File

@ -24,7 +24,7 @@
*/
package de.bluecolored.bluemap.core.config;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import java.io.File;
import java.io.IOException;
@ -40,19 +40,19 @@ public class CoreConfig {
public CoreConfig(ConfigurationNode node) throws IOException {
//accept-download
downloadAccepted = node.getNode("accept-download").getBoolean(false);
downloadAccepted = node.node("accept-download").getBoolean(false);
//renderThreadCount
int processors = Runtime.getRuntime().availableProcessors();
renderThreadCount = node.getNode("renderThreadCount").getInt(0);
renderThreadCount = node.node("renderThreadCount").getInt(0);
if (renderThreadCount <= 0) renderThreadCount = processors + renderThreadCount;
if (renderThreadCount <= 0) renderThreadCount = 1;
//metrics
metricsEnabled = node.getNode("metrics").getBoolean(false);
metricsEnabled = node.node("metrics").getBoolean(false);
//data
dataFolder = ConfigManager.toFolder(node.getNode("data").getString("data"));
dataFolder = ConfigManager.toFolder(node.node("data").getString("data"));
}

View File

@ -29,7 +29,7 @@
import de.bluecolored.bluemap.core.map.MapSettings;
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
import de.bluecolored.bluemap.core.util.ConfigUtils;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import java.io.IOException;
import java.util.regex.Pattern;
@ -61,53 +61,53 @@ public class MapConfig implements MapSettings {
public MapConfig(ConfigurationNode node) throws IOException {
//id
this.id = node.getNode("id").getString("");
this.id = node.node("id").getString("");
if (id.isEmpty()) throw new IOException("Invalid configuration: Node maps[?].id is not defined");
if (!VALID_ID_PATTERN.matcher(id).matches()) throw new IOException("Invalid configuration: Node maps[?].id '" + id + "' has invalid characters in it");
//name
this.name = node.getNode("name").getString(id);
this.name = node.node("name").getString(id);
//world
this.world = node.getNode("world").getString("");
this.world = node.node("world").getString("");
if (world.isEmpty()) throw new IOException("Invalid configuration: Node maps[?].world is not defined");
//startPos
if (!node.getNode("startPos").isVirtual()) this.startPos = ConfigUtils.readVector2i(node.getNode("startPos"));
if (!node.node("startPos").virtual()) this.startPos = ConfigUtils.readVector2i(node.node("startPos"));
//skyColor
if (!node.getNode("skyColor").isVirtual()) this.skyColor = ConfigUtils.readColorInt(node.getNode("skyColor"));
if (!node.node("skyColor").virtual()) this.skyColor = ConfigUtils.readColorInt(node.node("skyColor"));
else this.skyColor = 0x7dabff;
//ambientLight
this.ambientLight = node.getNode("ambientLight").getFloat(0f);
this.ambientLight = node.node("ambientLight").getFloat(0f);
//renderCaves
this.renderCaves = node.getNode("renderCaves").getBoolean(false);
this.renderCaves = node.node("renderCaves").getBoolean(false);
//bounds
int minX = node.getNode("minX").getInt(MapSettings.super.getMin().getX());
int maxX = node.getNode("maxX").getInt(MapSettings.super.getMax().getX());
int minZ = node.getNode("minZ").getInt(MapSettings.super.getMin().getZ());
int maxZ = node.getNode("maxZ").getInt(MapSettings.super.getMax().getZ());
int minY = node.getNode("minY").getInt(MapSettings.super.getMin().getY());
int maxY = node.getNode("maxY").getInt(MapSettings.super.getMax().getY());
int minX = node.node("minX").getInt(MapSettings.super.getMin().getX());
int maxX = node.node("maxX").getInt(MapSettings.super.getMax().getX());
int minZ = node.node("minZ").getInt(MapSettings.super.getMin().getZ());
int maxZ = node.node("maxZ").getInt(MapSettings.super.getMax().getZ());
int minY = node.node("minY").getInt(MapSettings.super.getMin().getY());
int maxY = node.node("maxY").getInt(MapSettings.super.getMax().getY());
this.min = new Vector3i(minX, minY, minZ);
this.max = new Vector3i(maxX, maxY, maxZ);
//renderEdges
this.renderEdges = node.getNode("renderEdges").getBoolean(true);
this.renderEdges = node.node("renderEdges").getBoolean(true);
//useCompression
this.useGzip = node.getNode("useCompression").getBoolean(true);
this.useGzip = node.node("useCompression").getBoolean(true);
//ignoreMissingLightData
this.ignoreMissingLightData = node.getNode("ignoreMissingLightData").getBoolean(false);
this.ignoreMissingLightData = node.node("ignoreMissingLightData").getBoolean(false);
//tile-settings
this.hiresTileSize = node.getNode("hires", "tileSize").getInt(32);
this.lowresPointsPerHiresTile = node.getNode("lowres", "pointsPerHiresTile").getInt(4);
this.lowresPointsPerLowresTile = node.getNode("lowres", "pointsPerLowresTile").getInt(50);
this.hiresTileSize = node.node("hires", "tileSize").getInt(32);
this.lowresPointsPerHiresTile = node.node("lowres", "pointsPerHiresTile").getInt(4);
this.lowresPointsPerLowresTile = node.node("lowres", "pointsPerLowresTile").getInt(50);
//check valid tile configuration values
double blocksPerPoint = (double) this.hiresTileSize / (double) this.lowresPointsPerHiresTile;

View File

@ -24,7 +24,7 @@
*/
package de.bluecolored.bluemap.core.config;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import java.io.File;
import java.io.IOException;
@ -40,16 +40,16 @@ public class RenderConfig {
public RenderConfig(ConfigurationNode node) throws IOException {
//webroot
String webRootString = node.getNode("webroot").getString();
String webRootString = node.node("webroot").getString();
if (webRootString == null) throw new IOException("Invalid configuration: Node webroot is not defined");
webRoot = ConfigManager.toFolder(webRootString);
//cookies
useCookies = node.getNode("useCookies").getBoolean(true);
useCookies = node.node("useCookies").getBoolean(true);
//maps
mapConfigs = new ArrayList<>();
for (ConfigurationNode mapConfigNode : node.getNode("maps").getChildrenList()) {
for (ConfigurationNode mapConfigNode : node.node("maps").childrenList()) {
mapConfigs.add(new MapConfig(mapConfigNode));
}

View File

@ -24,7 +24,7 @@
*/
package de.bluecolored.bluemap.core.config;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import java.io.File;
import java.io.IOException;
@ -43,16 +43,16 @@ public class WebServerConfig {
public WebServerConfig(ConfigurationNode node) throws IOException {
//enabled
enabled = node.getNode("enabled").getBoolean(false);
enabled = node.node("enabled").getBoolean(false);
if (enabled) {
//webroot
String webRootString = node.getNode("webroot").getString();
String webRootString = node.node("webroot").getString();
if (webRootString == null) throw new IOException("Invalid configuration: Node webroot is not defined");
webRoot = ConfigManager.toFolder(webRootString);
//ip
String bindAddressString = node.getNode("ip").getString("");
String bindAddressString = node.node("ip").getString("");
if (bindAddressString.isEmpty() || bindAddressString.equals("0.0.0.0") || bindAddressString.equals("::0")) {
bindAddress = new InetSocketAddress(0).getAddress(); // 0.0.0.0
} else if (bindAddressString.equals("#getLocalHost")) {
@ -62,10 +62,10 @@ public WebServerConfig(ConfigurationNode node) throws IOException {
}
//port
port = node.getNode("port").getInt(8100);
port = node.node("port").getInt(8100);
//maxConnectionCount
maxConnections = node.getNode("maxConnectionCount").getInt(100);
maxConnections = node.node("maxConnectionCount").getInt(100);
}
}

View File

@ -24,18 +24,14 @@
*/
package de.bluecolored.bluemap.core.map.hires.blockmodel;
import java.util.HashSet;
import com.flowpowered.math.matrix.Matrix3f;
import com.flowpowered.math.vector.Vector2f;
import com.flowpowered.math.vector.Vector3f;
import com.flowpowered.math.vector.Vector4f;
import com.google.common.collect.Sets;
import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
import de.bluecolored.bluemap.core.model.ExtendedFace;
import de.bluecolored.bluemap.core.model.ExtendedModel;
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
import de.bluecolored.bluemap.core.resourcepack.BlockColorCalculator;
import de.bluecolored.bluemap.core.resourcepack.BlockModelResource;
import de.bluecolored.bluemap.core.resourcepack.Texture;
@ -44,18 +40,21 @@
import de.bluecolored.bluemap.core.world.Block;
import de.bluecolored.bluemap.core.world.BlockState;
import java.util.Arrays;
import java.util.HashSet;
/**
* A model builder for all liquid blocks
*/
public class LiquidModelBuilder {
private static final HashSet<String> DEFAULT_WATERLOGGED_BLOCK_IDS = Sets.newHashSet(
private static final HashSet<String> DEFAULT_WATERLOGGED_BLOCK_IDS = new HashSet<>(Arrays.asList(
"minecraft:seagrass",
"minecraft:tall_seagrass",
"minecraft:kelp",
"minecraft:kelp_plant",
"minecraft:bubble_column"
);
));
private BlockState liquidBlockState;
private Block block;

View File

@ -28,8 +28,6 @@
import com.flowpowered.math.vector.Vector3i;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import de.bluecolored.bluemap.core.BlueMap;
import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.logger.Logger;
@ -68,7 +66,7 @@ public class MCAWorld implements World {
private BlockPropertiesMapper blockPropertiesMapper;
private BiomeMapper biomeMapper;
private final Multimap<String, BlockStateExtension> blockStateExtensions;
private final Map<String, List<BlockStateExtension>> blockStateExtensions;
private boolean ignoreMissingLightData;
@ -99,7 +97,7 @@ private MCAWorld(
this.forgeBlockMappings = new HashMap<>();
this.blockStateExtensions = MultimapBuilder.hashKeys().arrayListValues().build();
this.blockStateExtensions = new HashMap<>();
registerBlockStateExtension(new SnowyExtension(minecraftVersion));
registerBlockStateExtension(new StairShapeExtension());
registerBlockStateExtension(new FireExtension());
@ -162,7 +160,7 @@ private BlockState getExtendedBlockState(MCAChunk chunk, Vector3i pos) {
BlockState blockState = chunk.getBlockState(pos);
if (chunk instanceof ChunkAnvil112) { // only use extensions if old format chunk (1.12) in the new format block-states are saved with extensions
for (BlockStateExtension ext : blockStateExtensions.get(blockState.getFullId())) {
for (BlockStateExtension ext : blockStateExtensions.getOrDefault(blockState.getFullId(), Collections.emptyList())) {
blockState = ext.extend(this, pos, blockState);
}
}
@ -313,7 +311,7 @@ private File getMCAFile(int regionX, int regionZ) {
private void registerBlockStateExtension(BlockStateExtension extension) {
for (String id : extension.getAffectedBlockIds()) {
this.blockStateExtensions.put(id, extension);
this.blockStateExtensions.computeIfAbsent(id, t -> new ArrayList<>()).add(extension);
}
}

View File

@ -24,18 +24,18 @@
*/
package de.bluecolored.bluemap.core.mca.extensions;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.collect.Sets;
import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.mca.MCAWorld;
import de.bluecolored.bluemap.core.util.Direction;
import de.bluecolored.bluemap.core.world.BlockState;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
public class DoorExtension implements BlockStateExtension {
private final Set<String> affectedBlockIds;
@ -43,7 +43,7 @@ public class DoorExtension implements BlockStateExtension {
public DoorExtension(MinecraftVersion version) {
switch (version) {
case MC_1_12:
affectedBlockIds = Sets.newHashSet(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:wooden_door",
"minecraft:iron_door",
"minecraft:spruce_door",
@ -51,10 +51,10 @@ public DoorExtension(MinecraftVersion version) {
"minecraft:jungle_door",
"minecraft:acacia_door",
"minecraft:dark_oak_door"
);
));
break;
default:
affectedBlockIds = Sets.newHashSet(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:oak_door",
"minecraft:iron_door",
"minecraft:spruce_door",
@ -62,7 +62,7 @@ public DoorExtension(MinecraftVersion version) {
"minecraft:jungle_door",
"minecraft:acacia_door",
"minecraft:dark_oak_door"
);
));
break;
}
}

View File

@ -24,21 +24,21 @@
*/
package de.bluecolored.bluemap.core.mca.extensions;
import java.util.Set;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.collect.Sets;
import de.bluecolored.bluemap.core.mca.MCAWorld;
import de.bluecolored.bluemap.core.util.Direction;
import de.bluecolored.bluemap.core.world.BlockState;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class DoubleChestExtension implements BlockStateExtension {
private static final Set<String> AFFECTED_BLOCK_IDS = Sets.newHashSet(
private static final Set<String> AFFECTED_BLOCK_IDS = new HashSet<>(Arrays.asList(
"minecraft:chest",
"minecraft:trapped_chest"
);
));
@Override
public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) {

View File

@ -24,17 +24,17 @@
*/
package de.bluecolored.bluemap.core.mca.extensions;
import java.util.Objects;
import java.util.Set;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.collect.Sets;
import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.mca.MCAWorld;
import de.bluecolored.bluemap.core.util.Direction;
import de.bluecolored.bluemap.core.world.BlockState;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
public class DoublePlantExtension implements BlockStateExtension {
private final Set<String> affectedBlockIds;
@ -42,19 +42,19 @@ public class DoublePlantExtension implements BlockStateExtension {
public DoublePlantExtension(MinecraftVersion version) {
switch (version) {
case MC_1_12:
affectedBlockIds = Sets.newHashSet(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:double_plant"
);
));
break;
default:
affectedBlockIds = Sets.newHashSet(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:sunflower",
"minecraft:lilac",
"minecraft:tall_grass",
"minecraft:large_fern",
"minecraft:rose_bush",
"minecraft:peony"
);
));
break;
}
}

View File

@ -24,20 +24,20 @@
*/
package de.bluecolored.bluemap.core.mca.extensions;
import java.util.Set;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.collect.Sets;
import de.bluecolored.bluemap.core.mca.MCAWorld;
import de.bluecolored.bluemap.core.util.Direction;
import de.bluecolored.bluemap.core.world.BlockState;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public class FireExtension implements BlockStateExtension {
private static final Set<String> AFFECTED_BLOCK_IDS = Sets.newHashSet(
private static final Set<String> AFFECTED_BLOCK_IDS = new HashSet<>(Collections.singletonList(
"minecraft:fire"
);
));
@Override
public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) {

View File

@ -24,14 +24,13 @@
*/
package de.bluecolored.bluemap.core.mca.extensions;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import com.google.common.collect.Sets;
public class GlassPaneConnectExtension extends ConnectSameOrFullBlockExtension {
private static final HashSet<String> AFFECTED_BLOCK_IDS = Sets.newHashSet(
private static final HashSet<String> AFFECTED_BLOCK_IDS = new HashSet<>(Arrays.asList(
"minecraft:glass_pane",
"minecraft:white_stained_glass_pane",
"minecraft:orange_stained_glass_pane",
@ -49,7 +48,7 @@ public class GlassPaneConnectExtension extends ConnectSameOrFullBlockExtension {
"minecraft:red_stained_glass_pane",
"minecraft:black_stained_glass_pane",
"minecraft:iron_bars"
);
));
@Override
public Set<String> getAffectedBlockIds() {

View File

@ -24,16 +24,16 @@
*/
package de.bluecolored.bluemap.core.mca.extensions;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import com.google.common.collect.Sets;
public class NetherFenceConnectExtension extends ConnectSameOrFullBlockExtension {
private static final HashSet<String> AFFECTED_BLOCK_IDS = Sets.newHashSet(
private static final HashSet<String> AFFECTED_BLOCK_IDS = new HashSet<>(Collections.singletonList(
"minecraft:nether_brick_fence"
);
));
@Override
public Set<String> getAffectedBlockIds() {

View File

@ -24,23 +24,24 @@
*/
package de.bluecolored.bluemap.core.mca.extensions;
import java.util.Set;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.collect.Sets;
import de.bluecolored.bluemap.core.mca.MCAWorld;
import de.bluecolored.bluemap.core.util.Direction;
import de.bluecolored.bluemap.core.world.BlockState;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public class RedstoneExtension implements BlockStateExtension {
private static final Set<String> AFFECTED_BLOCK_IDS = Sets.newHashSet(
private static final Set<String> AFFECTED_BLOCK_IDS = new HashSet<>(Collections.singletonList(
"minecraft:redstone_wire"
);
));
private static final Set<String> CONNECTIBLE = Sets.newHashSet(
private static final Set<String> CONNECTIBLE = new HashSet<>(Arrays.asList(
"minecraft:redstone_wire",
"minecraft:redstone_wall_torch",
"minecraft:redstone_torch",
@ -52,7 +53,7 @@ public class RedstoneExtension implements BlockStateExtension {
"minecraft:oak_pressure_plate",
"minecraft:light_weighted_pressure_plate",
"minecraft:heavy_weighted_pressure_plate"
);
));
@Override
public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) {

View File

@ -24,15 +24,15 @@
*/
package de.bluecolored.bluemap.core.mca.extensions;
import java.util.Set;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.collect.Sets;
import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.mca.MCAWorld;
import de.bluecolored.bluemap.core.world.BlockState;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class SnowyExtension implements BlockStateExtension {
private final Set<String> affectedBlockIds;
@ -43,18 +43,18 @@ public class SnowyExtension implements BlockStateExtension {
public SnowyExtension(MinecraftVersion version) {
switch (version) {
case MC_1_12:
affectedBlockIds = Sets.newHashSet(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:grass",
"minecraft:mycelium"
);
));
snowLayerId = "minecraft:snow_layer";
snowBlockId = "minecraft:snow";
break;
default:
affectedBlockIds = Sets.newHashSet(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:grass_block",
"minecraft:podzol"
);
));
snowLayerId = "minecraft:snow";
snowBlockId = "minecraft:snow_block";
break;

View File

@ -24,18 +24,18 @@
*/
package de.bluecolored.bluemap.core.mca.extensions;
import java.util.Set;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.collect.Sets;
import de.bluecolored.bluemap.core.mca.MCAWorld;
import de.bluecolored.bluemap.core.util.Direction;
import de.bluecolored.bluemap.core.world.BlockState;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class StairShapeExtension implements BlockStateExtension {
private static final Set<String> AFFECTED_BLOCK_IDS = Sets.newHashSet(
private static final Set<String> AFFECTED_BLOCK_IDS = new HashSet<>(Arrays.asList(
"minecraft:oak_stairs",
"minecraft:cobblestone_stairs",
"minecraft:brick_stairs",
@ -50,7 +50,7 @@ public class StairShapeExtension implements BlockStateExtension {
"minecraft:dark_oak_stairs",
"minecraft:red_sandstone_stairs",
"minecraft:purpur_stairs"
);
));
@Override
public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) {

View File

@ -24,16 +24,15 @@
*/
package de.bluecolored.bluemap.core.mca.extensions;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import com.google.common.collect.Sets;
public class TripwireConnectExtension extends ConnectExtension {
private static final HashSet<String> AFFECTED_BLOCK_IDS = Sets.newHashSet(
private static final HashSet<String> AFFECTED_BLOCK_IDS = new HashSet<>(Collections.singletonList(
"minecraft:tripwire"
);
));
@Override
public Set<String> getAffectedBlockIds() {

View File

@ -24,23 +24,22 @@
*/
package de.bluecolored.bluemap.core.mca.extensions;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.collect.Sets;
import de.bluecolored.bluemap.core.mca.MCAWorld;
import de.bluecolored.bluemap.core.util.Direction;
import de.bluecolored.bluemap.core.world.BlockState;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
public class WallConnectExtension extends ConnectSameOrFullBlockExtension {
private static final HashSet<String> AFFECTED_BLOCK_IDS = Sets.newHashSet(
private static final HashSet<String> AFFECTED_BLOCK_IDS = new HashSet<>(Arrays.asList(
"minecraft:cobblestone_wall",
"minecraft:mossy_cobblestone_wall"
);
));
@Override
public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) {

View File

@ -24,12 +24,12 @@
*/
package de.bluecolored.bluemap.core.mca.extensions;
import java.util.Set;
import com.google.common.collect.Sets;
import de.bluecolored.bluemap.core.MinecraftVersion;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class WoodenFenceConnectExtension extends ConnectSameOrFullBlockExtension {
private final Set<String> affectedBlockIds;
@ -37,24 +37,24 @@ public class WoodenFenceConnectExtension extends ConnectSameOrFullBlockExtension
public WoodenFenceConnectExtension(MinecraftVersion version) {
switch (version) {
case MC_1_12:
affectedBlockIds = Sets.newHashSet(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:fence",
"minecraft:spruce_fence",
"minecraft:birch_fence",
"minecraft:jungle_fence",
"minecraft:dark_oak_fence",
"minecraft:acacia_fence"
);
));
break;
default:
affectedBlockIds = Sets.newHashSet(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:oak_fence",
"minecraft:spruce_fence",
"minecraft:birch_fence",
"minecraft:jungle_fence",
"minecraft:dark_oak_fence",
"minecraft:acacia_fence"
);
));
break;
}
}

View File

@ -34,11 +34,10 @@
import de.bluecolored.bluemap.core.world.Biome;
import de.bluecolored.bluemap.core.world.Block;
import de.bluecolored.bluemap.core.world.World;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@ -50,7 +49,7 @@ public class BlockColorCalculator {
private BufferedImage foliageMap;
private BufferedImage grassMap;
private Map<String, Function<Block, Vector3f>> blockColorMap;
private final Map<String, Function<Block, Vector3f>> blockColorMap;
public BlockColorCalculator(BufferedImage foliageMap, BufferedImage grassMap) {
this.foliageMap = foliageMap;
@ -59,12 +58,12 @@ public BlockColorCalculator(BufferedImage foliageMap, BufferedImage grassMap) {
this.blockColorMap = new HashMap<>();
}
public void loadColorConfig(ConfigurationNode colorConfig) throws IOException {
public void loadColorConfig(ConfigurationNode colorConfig) {
blockColorMap.clear();
for (Entry<Object, ? extends ConfigurationNode> entry : colorConfig.getChildrenMap().entrySet()){
for (Entry<Object, ? extends ConfigurationNode> entry : colorConfig.childrenMap().entrySet()){
String key = entry.getKey().toString();
String value = entry.getValue().getString();
String value = entry.getValue().getString("");
Function<Block, Vector3f> colorFunction;
switch (value) {

View File

@ -30,8 +30,8 @@
import de.bluecolored.bluemap.core.resourcepack.fileaccess.FileAccess;
import de.bluecolored.bluemap.core.util.Axis;
import de.bluecolored.bluemap.core.util.Direction;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.gson.GsonConfigurationLoader;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.gson.GsonConfigurationLoader;
import java.io.*;
import java.nio.charset.StandardCharsets;
@ -250,22 +250,22 @@ private BlockModelResource buildNoReset(String modelPath, boolean renderElements
InputStream fileIn = sourcesAccess.readFile(modelPath);
ConfigurationNode config = GsonConfigurationLoader.builder()
.setSource(() -> new BufferedReader(new InputStreamReader(fileIn, StandardCharsets.UTF_8)))
.source(() -> new BufferedReader(new InputStreamReader(fileIn, StandardCharsets.UTF_8)))
.build()
.load();
for (Entry<Object, ? extends ConfigurationNode> entry : config.getNode("textures").getChildrenMap().entrySet()) {
for (Entry<Object, ? extends ConfigurationNode> entry : config.node("textures").childrenMap().entrySet()) {
if (entry.getKey().equals(JSON_COMMENT)) continue;
String key = entry.getKey().toString();
String value = entry.getValue().getString(null);
String value = entry.getValue().getString();
if (("#" + key).equals(value)) continue; // skip direct loop
textures.putIfAbsent(key, value);
}
String parentPath = config.getNode("parent").getString();
String parentPath = config.node("parent").getString();
if (parentPath != null) {
if (parentPath.startsWith("builtin")) {
switch (parentPath) {
@ -276,7 +276,7 @@ private BlockModelResource buildNoReset(String modelPath, boolean renderElements
} else {
try {
parentPath = ResourcePack.namespacedToAbsoluteResourcePath(parentPath, "models") + ".json";
blockModel = this.buildNoReset(parentPath, renderElements && config.getNode("elements").isVirtual(), topModelPath);
blockModel = this.buildNoReset(parentPath, renderElements && config.node("elements").virtual(), topModelPath);
} catch (IOException ex) {
throw new ParseResourceException("Failed to load parent model " + parentPath + " of model " + topModelPath, ex);
}
@ -284,7 +284,7 @@ private BlockModelResource buildNoReset(String modelPath, boolean renderElements
}
if (renderElements) {
for (ConfigurationNode elementNode : config.getNode("elements").getChildrenList()) {
for (ConfigurationNode elementNode : config.node("elements").childrenList()) {
blockModel.elements.add(buildElement(blockModel, elementNode, topModelPath));
}
}
@ -334,24 +334,24 @@ private BlockModelResource buildNoReset(String modelPath, boolean renderElements
private Element buildElement(BlockModelResource model, ConfigurationNode node, String topModelPath) throws ParseResourceException {
Element element = model.new Element();
element.from = readVector3f(node.getNode("from"));
element.to = readVector3f(node.getNode("to"));
element.from = readVector3f(node.node("from"));
element.to = readVector3f(node.node("to"));
element.shade = node.getNode("shade").getBoolean(true);
element.shade = node.node("shade").getBoolean(true);
boolean fullElement = element.from.equals(FULL_CUBE_FROM) && element.to.equals(FULL_CUBE_TO);
if (!node.getNode("rotation").isVirtual()) {
element.rotation.angle = node.getNode("rotation", "angle").getFloat(0);
element.rotation.axis = Axis.fromString(node.getNode("rotation", "axis").getString("x"));
if (!node.getNode("rotation", "origin").isVirtual()) element.rotation.origin = readVector3f(node.getNode("rotation", "origin"));
element.rotation.rescale = node.getNode("rotation", "rescale").getBoolean(false);
if (!node.node("rotation").virtual()) {
element.rotation.angle = node.node("rotation", "angle").getFloat(0);
element.rotation.axis = Axis.fromString(node.node("rotation", "axis").getString("x"));
if (!node.node("rotation", "origin").virtual()) element.rotation.origin = readVector3f(node.node("rotation", "origin"));
element.rotation.rescale = node.node("rotation", "rescale").getBoolean(false);
}
boolean allDirs = true;
for (Direction direction : Direction.values()) {
ConfigurationNode faceNode = node.getNode("faces", direction.name().toLowerCase());
if (!faceNode.isVirtual()) {
ConfigurationNode faceNode = node.node("faces", direction.name().toLowerCase());
if (!faceNode.virtual()) {
try {
Face face = buildFace(element, direction, faceNode);
element.faces.put(direction, face);
@ -372,13 +372,13 @@ private Face buildFace(Element element, Direction direction, ConfigurationNode n
try {
Face face = element.new Face(direction);
if (!node.getNode("uv").isVirtual()) face.uv = readVector4f(node.getNode("uv"));
face.texture = getTexture(node.getNode("texture").getString(""));
face.tinted = node.getNode("tintindex").getInt(-1) >= 0;
face.rotation = node.getNode("rotation").getInt(0);
if (!node.node("uv").virtual()) face.uv = readVector4f(node.node("uv"));
face.texture = getTexture(node.node("texture").getString(""));
face.tinted = node.node("tintindex").getInt(-1) >= 0;
face.rotation = node.node("rotation").getInt(0);
if (!node.getNode("cullface").isVirtual()) {
String dirString = node.getNode("cullface").getString("");
if (!node.node("cullface").virtual()) {
String dirString = node.node("cullface").getString("");
if (dirString.equals("bottom")) dirString = "down";
if (dirString.equals("top")) dirString = "up";
@ -389,14 +389,14 @@ private Face buildFace(Element element, Direction direction, ConfigurationNode n
return face;
} catch (FileNotFoundException ex) {
throw new ParseResourceException("There is no texture with the path: " + node.getNode("texture").getString(), ex);
throw new ParseResourceException("There is no texture with the path: " + node.node("texture").getString(), ex);
} catch (NoSuchElementException ex) {
throw new ParseResourceException("Texture key '" + node.getNode("texture").getString() + "' has no texture assigned!", ex);
throw new ParseResourceException("Texture key '" + node.node("texture").getString() + "' has no texture assigned!", ex);
}
}
private Vector3f readVector3f(ConfigurationNode node) throws ParseResourceException {
List<? extends ConfigurationNode> nodeList = node.getChildrenList();
List<? extends ConfigurationNode> nodeList = node.childrenList();
if (nodeList.size() < 3) throw new ParseResourceException("Failed to load Vector3: Not enough values in list-node!");
return new Vector3f(
@ -407,7 +407,7 @@ private Vector3f readVector3f(ConfigurationNode node) throws ParseResourceExcept
}
private Vector4f readVector4f(ConfigurationNode node) throws ParseResourceException {
List<? extends ConfigurationNode> nodeList = node.getChildrenList();
List<? extends ConfigurationNode> nodeList = node.childrenList();
if (nodeList.size() < 4) throw new ParseResourceException("Failed to load Vector4: Not enough values in list-node!");
return new Vector4f(

View File

@ -31,8 +31,8 @@
import de.bluecolored.bluemap.core.resourcepack.fileaccess.FileAccess;
import de.bluecolored.bluemap.core.util.MathUtils;
import de.bluecolored.bluemap.core.world.BlockState;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.gson.GsonConfigurationLoader;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.gson.GsonConfigurationLoader;
import org.apache.commons.lang3.StringUtils;
import java.io.BufferedReader;
@ -45,8 +45,8 @@
public class BlockStateResource {
private List<Variant> variants = new ArrayList<>(0);
private Collection<Variant> multipart = new ArrayList<>(0);
private final List<Variant> variants = new ArrayList<>(0);
private final Collection<Variant> multipart = new ArrayList<>(0);
private BlockStateResource() {
}
@ -90,7 +90,7 @@ public Collection<TransformedBlockModelResource> getModels(BlockState blockState
return models;
}
private class Variant {
private static class Variant {
private PropertyCondition condition = PropertyCondition.all();
private Collection<Weighted<TransformedBlockModelResource>> models = new ArrayList<>();
@ -127,8 +127,8 @@ public void updateTotalWeight() {
private static class Weighted<T> {
private T value;
private double weight;
private final T value;
private final double weight;
public Weighted(T value, double weight) {
this.value = value;
@ -157,18 +157,18 @@ public BlockStateResource build(String blockstateFile) throws IOException {
InputStream fileIn = sourcesAccess.readFile(blockstateFile);
ConfigurationNode config = GsonConfigurationLoader.builder()
.setSource(() -> new BufferedReader(new InputStreamReader(fileIn, StandardCharsets.UTF_8)))
.source(() -> new BufferedReader(new InputStreamReader(fileIn, StandardCharsets.UTF_8)))
.build()
.load();
if (!config.getNode("forge_marker").isVirtual()) {
if (!config.node("forge_marker").virtual()) {
return buildForge(config, blockstateFile);
}
BlockStateResource blockState = new BlockStateResource();
// create variants
for (Entry<Object, ? extends ConfigurationNode> entry : config.getNode("variants").getChildrenMap().entrySet()) {
for (Entry<Object, ? extends ConfigurationNode> entry : config.node("variants").childrenMap().entrySet()) {
if (entry.getKey().equals(JSON_COMMENT)) continue;
try {
@ -178,7 +178,7 @@ public BlockStateResource build(String blockstateFile) throws IOException {
//some exceptions in 1.12 resource packs that we ignore
if (conditionString.equals("all") || conditionString.equals("map")) continue;
Variant variant = blockState.new Variant();
Variant variant = new Variant();
variant.condition = parseConditionString(conditionString);
variant.models = loadModels(transformedModelNode, blockstateFile, null);
@ -192,14 +192,14 @@ public BlockStateResource build(String blockstateFile) throws IOException {
}
// create multipart
for (ConfigurationNode partNode : config.getNode("multipart").getChildrenList()) {
for (ConfigurationNode partNode : config.node("multipart").childrenList()) {
try {
Variant variant = blockState.new Variant();
ConfigurationNode whenNode = partNode.getNode("when");
if (!whenNode.isVirtual()) {
Variant variant = new Variant();
ConfigurationNode whenNode = partNode.node("when");
if (!whenNode.virtual()) {
variant.condition = parseCondition(whenNode);
}
variant.models = loadModels(partNode.getNode("apply"), blockstateFile, null);
variant.models = loadModels(partNode.node("apply"), blockstateFile, null);
variant.updateTotalWeight();
variant.checkValid();
@ -217,7 +217,7 @@ private Collection<Weighted<TransformedBlockModelResource>> loadModels(Configura
Collection<Weighted<TransformedBlockModelResource>> models = new ArrayList<>();
if (node.isList()) {
for (ConfigurationNode modelNode : node.getChildrenList()) {
for (ConfigurationNode modelNode : node.childrenList()) {
try {
models.add(loadModel(modelNode, overrideTextures));
} catch (ParseResourceException ex) {
@ -236,7 +236,7 @@ private Collection<Weighted<TransformedBlockModelResource>> loadModels(Configura
}
private Weighted<TransformedBlockModelResource> loadModel(ConfigurationNode node, Map<String, String> overrideTextures) throws ParseResourceException {
String namespacedModelPath = node.getNode("model").getString();
String namespacedModelPath = node.node("model").getString();
if (namespacedModelPath == null)
throw new ParseResourceException("No model defined!");
@ -264,33 +264,33 @@ private Weighted<TransformedBlockModelResource> loadModel(ConfigurationNode node
resourcePack.blockModelResources.put(modelPath, model);
}
Vector2f rotation = new Vector2f(node.getNode("x").getFloat(0), node.getNode("y").getFloat(0));
boolean uvLock = node.getNode("uvlock").getBoolean(false);
Vector2f rotation = new Vector2f(node.node("x").getFloat(0), node.node("y").getFloat(0));
boolean uvLock = node.node("uvlock").getBoolean(false);
TransformedBlockModelResource transformedModel = new TransformedBlockModelResource(rotation, uvLock, model);
return new Weighted<TransformedBlockModelResource>(transformedModel, node.getNode("weight").getDouble(1d));
return new Weighted<>(transformedModel, node.node("weight").getDouble(1d));
}
private PropertyCondition parseCondition(ConfigurationNode conditionNode) {
List<PropertyCondition> andConditions = new ArrayList<>();
for (Entry<Object, ? extends ConfigurationNode> entry : conditionNode.getChildrenMap().entrySet()) {
for (Entry<Object, ? extends ConfigurationNode> entry : conditionNode.childrenMap().entrySet()) {
String key = entry.getKey().toString();
if (key.equals(JSON_COMMENT)) continue;
if (key.equals("OR")) {
List<PropertyCondition> orConditions = new ArrayList<>();
for (ConfigurationNode orConditionNode : entry.getValue().getChildrenList()) {
for (ConfigurationNode orConditionNode : entry.getValue().childrenList()) {
orConditions.add(parseCondition(orConditionNode));
}
andConditions.add(
PropertyCondition.or(orConditions.toArray(new PropertyCondition[orConditions.size()])));
PropertyCondition.or(orConditions.toArray(new PropertyCondition[0])));
} else {
String[] values = StringUtils.split(entry.getValue().getString(""), '|');
andConditions.add(PropertyCondition.property(key, values));
}
}
return PropertyCondition.and(andConditions.toArray(new PropertyCondition[andConditions.size()]));
return PropertyCondition.and(andConditions.toArray(new PropertyCondition[0]));
}
private PropertyCondition parseConditionString(String conditionString) throws IllegalArgumentException {
@ -311,24 +311,24 @@ private PropertyCondition parseConditionString(String conditionString) throws Il
} else if (conditions.size() == 1) {
condition = conditions.get(0);
} else {
condition = PropertyCondition.and(conditions.toArray(new PropertyCondition[conditions.size()]));
condition = PropertyCondition.and(conditions.toArray(new PropertyCondition[0]));
}
return condition;
}
private BlockStateResource buildForge(ConfigurationNode config, String blockstateFile) {
ConfigurationNode modelDefaults = config.getNode("defaults");
ConfigurationNode modelDefaults = config.node("defaults");
List<ForgeVariant> variants = new ArrayList<>();
for (Entry<Object, ? extends ConfigurationNode> entry : config.getNode("variants").getChildrenMap().entrySet()) {
for (Entry<Object, ? extends ConfigurationNode> entry : config.node("variants").childrenMap().entrySet()) {
if (entry.getKey().equals(JSON_COMMENT)) continue;
if (isForgeStraightVariant(entry.getValue())) continue;
// create variants for single property
List<ForgeVariant> propertyVariants = new ArrayList<>();
String key = entry.getKey().toString();
for (Entry<Object, ? extends ConfigurationNode> value : entry.getValue().getChildrenMap().entrySet()) {
for (Entry<Object, ? extends ConfigurationNode> value : entry.getValue().childrenMap().entrySet()) {
if (value.getKey().equals(JSON_COMMENT)) continue;
ForgeVariant variant = new ForgeVariant();
@ -355,26 +355,26 @@ private BlockStateResource buildForge(ConfigurationNode config, String blockstat
//create all possible property-variants
BlockStateResource blockState = new BlockStateResource();
for (ForgeVariant forgeVariant : variants) {
Variant variant = blockState.new Variant();
Variant variant = new Variant();
ConfigurationNode modelNode = forgeVariant.node.mergeValuesFrom(modelDefaults);
ConfigurationNode modelNode = forgeVariant.node.mergeFrom(modelDefaults);
Map<String, String> textures = new HashMap<>();
for (Entry<Object, ? extends ConfigurationNode> entry : modelNode.getNode("textures").getChildrenMap().entrySet()) {
for (Entry<Object, ? extends ConfigurationNode> entry : modelNode.node("textures").childrenMap().entrySet()) {
if (entry.getKey().equals(JSON_COMMENT)) continue;
textures.putIfAbsent(entry.getKey().toString(), entry.getValue().getString(null));
textures.putIfAbsent(entry.getKey().toString(), entry.getValue().getString());
}
List<PropertyCondition> conditions = new ArrayList<>(forgeVariant.properties.size());
for (Entry<String, String> property : forgeVariant.properties.entrySet()) {
conditions.add(PropertyCondition.property(property.getKey(), property.getValue()));
}
variant.condition = PropertyCondition.and(conditions.toArray(new PropertyCondition[conditions.size()]));
variant.condition = PropertyCondition.and(conditions.toArray(new PropertyCondition[0]));
variant.models.addAll(loadModels(modelNode, blockstateFile, textures));
for (Entry<Object, ? extends ConfigurationNode> entry : modelNode.getNode("submodel").getChildrenMap().entrySet()) {
for (Entry<Object, ? extends ConfigurationNode> entry : modelNode.node("submodel").childrenMap().entrySet()) {
if (entry.getKey().equals(JSON_COMMENT)) continue;
variant.models.addAll(loadModels(entry.getValue(), blockstateFile, textures));
@ -392,22 +392,22 @@ private BlockStateResource buildForge(ConfigurationNode config, String blockstat
}
//create default straight variant
ConfigurationNode normalNode = config.getNode("variants", "normal");
if (normalNode.isVirtual() || isForgeStraightVariant(normalNode)) {
normalNode.mergeValuesFrom(modelDefaults);
ConfigurationNode normalNode = config.node("variants", "normal");
if (normalNode.virtual() || isForgeStraightVariant(normalNode)) {
normalNode.mergeFrom(modelDefaults);
Map<String, String> textures = new HashMap<>();
for (Entry<Object, ? extends ConfigurationNode> entry : normalNode.getNode("textures").getChildrenMap().entrySet()) {
for (Entry<Object, ? extends ConfigurationNode> entry : normalNode.node("textures").childrenMap().entrySet()) {
if (entry.getKey().equals(JSON_COMMENT)) continue;
textures.putIfAbsent(entry.getKey().toString(), entry.getValue().getString(null));
textures.putIfAbsent(entry.getKey().toString(), entry.getValue().getString());
}
Variant variant = blockState.new Variant();
Variant variant = new Variant();
variant.condition = PropertyCondition.all();
variant.models.addAll(loadModels(normalNode, blockstateFile, textures));
for (Entry<Object, ? extends ConfigurationNode> entry : normalNode.getNode("submodel").getChildrenMap().entrySet()) {
for (Entry<Object, ? extends ConfigurationNode> entry : normalNode.node("submodel").childrenMap().entrySet()) {
if (entry.getKey().equals(JSON_COMMENT)) continue;
variant.models.addAll(loadModels(entry.getValue(), blockstateFile, textures));
@ -431,7 +431,7 @@ private boolean isForgeStraightVariant(ConfigurationNode node) {
if (node.isList())
return true;
for (Entry<Object, ? extends ConfigurationNode> entry : node.getChildrenMap().entrySet()) {
for (Entry<Object, ? extends ConfigurationNode> entry : node.childrenMap().entrySet()) {
if (entry.getKey().equals(JSON_COMMENT)) continue;
if (!entry.getValue().isMap()) return true;
}
@ -441,7 +441,7 @@ private boolean isForgeStraightVariant(ConfigurationNode node) {
private static class ForgeVariant {
public Map<String, String> properties = new HashMap<>();
public ConfigurationNode node = GsonConfigurationLoader.builder().build().createEmptyNode();
public ConfigurationNode node = GsonConfigurationLoader.builder().build().createNode();
public ForgeVariant createMerge(ForgeVariant other) {
ForgeVariant merge = new ForgeVariant();
@ -449,8 +449,8 @@ public ForgeVariant createMerge(ForgeVariant other) {
merge.properties.putAll(this.properties);
merge.properties.putAll(other.properties);
merge.node.mergeValuesFrom(this.node);
merge.node.mergeValuesFrom(other.node);
merge.node.mergeFrom(this.node);
merge.node.mergeFrom(other.node);
return merge;
}
@ -463,6 +463,8 @@ private static void logParseError(String message, Throwable throwable) {
if (errorMessage == null) errorMessage = throwable.toString();
Logger.global.logDebug(" > " + errorMessage);
//Logger.global.logError("DETAIL: ", throwable);
throwable = throwable.getCause();
}
}

View File

@ -24,22 +24,22 @@
*/
package de.bluecolored.bluemap.core.resourcepack;
import com.google.common.base.Preconditions;
import de.bluecolored.bluemap.core.util.Preconditions;
import de.bluecolored.bluemap.core.world.BlockState;
@FunctionalInterface
public interface PropertyCondition {
static final PropertyCondition MATCH_ALL = new All();
static final PropertyCondition MATCH_NONE = new None();
PropertyCondition MATCH_ALL = new All();
PropertyCondition MATCH_NONE = new None();
boolean matches(BlockState state);
public class Property implements PropertyCondition {
class Property implements PropertyCondition {
private String key;
private String value;
private final String key;
private final String value;
private Property (String key, String value) {
this.key = key.toLowerCase();
@ -57,7 +57,7 @@ public boolean matches(BlockState state) {
class And implements PropertyCondition {
private PropertyCondition[] conditions;
private final PropertyCondition[] conditions;
private And (PropertyCondition... conditions) {
Preconditions.checkArgument(conditions.length > 0, "Must be at least one condition!");
@ -77,7 +77,7 @@ public boolean matches(BlockState state) {
class Or implements PropertyCondition {
private PropertyCondition[] conditions;
private final PropertyCondition[] conditions;
private Or (PropertyCondition... conditions) {
Preconditions.checkArgument(conditions.length > 0, "Must be at least one condition!");

View File

@ -24,23 +24,6 @@
*/
package de.bluecolored.bluemap.core.resourcepack;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import javax.imageio.ImageIO;
import org.apache.commons.io.output.ByteArrayOutputStream;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.core.resourcepack.BlockStateResource.Builder;
@ -49,6 +32,12 @@
import de.bluecolored.bluemap.core.resourcepack.fileaccess.CombinedFileAccess;
import de.bluecolored.bluemap.core.resourcepack.fileaccess.FileAccess;
import de.bluecolored.bluemap.core.world.BlockState;
import org.apache.commons.io.output.ByteArrayOutputStream;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.*;
/**
* Represents all resources (BlockStates / BlockModels and Textures) that are loaded and used to generate map-models.
@ -62,18 +51,18 @@ public class ResourcePack {
"biomes.json"
};
private MinecraftVersion minecraftVersion;
private final MinecraftVersion minecraftVersion;
protected Map<String, BlockStateResource> blockStateResources;
protected Map<String, BlockModelResource> blockModelResources;
protected TextureGallery textures;
private BlockColorCalculator blockColorCalculator;
private final BlockColorCalculator blockColorCalculator;
private BufferedImage foliageMap;
private BufferedImage grassMap;
private Multimap<String, Resource> configs;
private Map<String, List<Resource>> configs;
public ResourcePack(MinecraftVersion minecraftVersion) {
this.minecraftVersion = minecraftVersion;
@ -86,14 +75,14 @@ public ResourcePack(MinecraftVersion minecraftVersion) {
grassMap = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
grassMap.setRGB(0, 0, 0xFF00FF00);
blockColorCalculator = new BlockColorCalculator(foliageMap, grassMap);
configs = MultimapBuilder.hashKeys().arrayListValues().build();
configs = new HashMap<>();
}
/**
* Returns all config-files found in the namespaces of the ResourcePack with that filename
*/
public Collection<Resource> getConfigAdditions(String configFileName){
return configs.get(configFileName);
return configs.getOrDefault(configFileName, Collections.emptyList());
}
/**
@ -121,7 +110,7 @@ public void saveTextureFile(File file) throws IOException {
* @param sources The list of {@link File} sources. Each can be a folder or any zip-compressed file. (E.g. .zip or .jar)
*/
public void load(Collection<File> sources) throws IOException, InterruptedException {
load(sources.toArray(new File[sources.size()]));
load(sources.toArray(new File[0]));
}
/**
@ -134,10 +123,9 @@ public void load(Collection<File> sources) throws IOException, InterruptedExcept
*/
public void load(File... sources) throws InterruptedException {
try (CombinedFileAccess combinedSources = new CombinedFileAccess()){
for (int i = 0; i < sources.length; i++) {
for (File file : sources) {
if (Thread.interrupted()) throw new InterruptedException();
File file = sources[i];
try {
combinedSources.addFileAccess(FileAccess.of(file));
} catch (IOException e) {
@ -179,8 +167,9 @@ public void load(File... sources) throws InterruptedException {
//load configs
for (String configName : CONFIG_FILES) {
try {
Resource config = new Resource(sourcesAccess.readFile("assets/" + namespace + "/" + configName));
configs.put(configName, config);
Resource config = new Resource(sourcesAccess.readFile(
"assets/" + namespace + "/" + configName));
configs.computeIfAbsent(configName, t -> new ArrayList<>()).add(config);
} catch (FileNotFoundException ignore) {
} catch (IOException ex) {
Logger.global.logError("Failed to load config for " + namespace + ": " + configName, ex);
@ -251,9 +240,9 @@ protected static String namespacedToAbsoluteResourcePath(String namespacedPath,
/**
* Caches a full InputStream in a byte-array that can be read later
*/
public class Resource {
public static class Resource {
private byte[] data;
private final byte[] data;
public Resource(InputStream data) throws FileNotFoundException, IOException {
try (ByteArrayOutputStream bout = new ByteArrayOutputStream()) {

View File

@ -27,14 +27,14 @@
*/
package de.bluecolored.bluemap.core.threejs;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import de.bluecolored.bluemap.core.util.Preconditions;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.google.common.base.Preconditions;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
/**
* Represents a ThreeJS BufferAttribute
*/

View File

@ -25,7 +25,8 @@
package de.bluecolored.bluemap.core.util;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.base.Preconditions;
import java.util.Objects;
public enum Axis {
@ -44,7 +45,7 @@ public Vector3i toVector(){
}
public static Axis fromString(String name){
Preconditions.checkNotNull(name);
Objects.requireNonNull(name);
return valueOf(name.toUpperCase());
}

View File

@ -24,23 +24,20 @@
*/
package de.bluecolored.bluemap.core.util;
import com.flowpowered.math.vector.*;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.NodePath;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.List;
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3f;
import com.flowpowered.math.vector.Vector3i;
import com.flowpowered.math.vector.Vector4f;
import com.flowpowered.math.vector.Vector4i;
import ninja.leaping.configurate.ConfigurationNode;
public class ConfigUtils {
private ConfigUtils(){}
public static Vector2i readVector2i(ConfigurationNode vectorNode){
if (vectorNode.isList()){
List<? extends ConfigurationNode> list = vectorNode.getChildrenList();
List<? extends ConfigurationNode> list = vectorNode.childrenList();
return new Vector2i(
list.get(0).getInt(),
list.get(1).getInt()
@ -48,14 +45,14 @@ public static Vector2i readVector2i(ConfigurationNode vectorNode){
}
return new Vector2i(
vectorNode.getNode("x").getInt(),
vectorNode.getNode("y").getInt()
vectorNode.node("x").getInt(),
vectorNode.node("y").getInt()
);
}
public static Vector3i readVector3i(ConfigurationNode vectorNode){
if (vectorNode.isList()){
List<? extends ConfigurationNode> list = vectorNode.getChildrenList();
List<? extends ConfigurationNode> list = vectorNode.childrenList();
return new Vector3i(
list.get(0).getInt(),
list.get(1).getInt(),
@ -64,15 +61,15 @@ public static Vector3i readVector3i(ConfigurationNode vectorNode){
}
return new Vector3i(
vectorNode.getNode("x").getInt(),
vectorNode.getNode("y").getInt(),
vectorNode.getNode("z").getInt()
vectorNode.node("x").getInt(),
vectorNode.node("y").getInt(),
vectorNode.node("z").getInt()
);
}
public static Vector3f readVector3f(ConfigurationNode vectorNode){
if (vectorNode.isList()){
List<? extends ConfigurationNode> list = vectorNode.getChildrenList();
List<? extends ConfigurationNode> list = vectorNode.childrenList();
return new Vector3f(
list.get(0).getFloat(),
list.get(1).getFloat(),
@ -81,15 +78,15 @@ public static Vector3f readVector3f(ConfigurationNode vectorNode){
}
return new Vector3f(
vectorNode.getNode("x").getFloat(),
vectorNode.getNode("y").getFloat(),
vectorNode.getNode("z").getFloat()
vectorNode.node("x").getFloat(),
vectorNode.node("y").getFloat(),
vectorNode.node("z").getFloat()
);
}
public static Vector4i readVector4i(ConfigurationNode vectorNode){
if (vectorNode.isList()){
List<? extends ConfigurationNode> list = vectorNode.getChildrenList();
List<? extends ConfigurationNode> list = vectorNode.childrenList();
return new Vector4i(
list.get(0).getInt(),
list.get(1).getInt(),
@ -99,16 +96,16 @@ public static Vector4i readVector4i(ConfigurationNode vectorNode){
}
return new Vector4i(
vectorNode.getNode("x").getInt(),
vectorNode.getNode("y").getInt(),
vectorNode.getNode("z").getInt(),
vectorNode.getNode("w").getInt()
vectorNode.node("x").getInt(),
vectorNode.node("y").getInt(),
vectorNode.node("z").getInt(),
vectorNode.node("w").getInt()
);
}
public static Vector4f readVector4f(ConfigurationNode vectorNode){
if (vectorNode.isList()){
List<? extends ConfigurationNode> list = vectorNode.getChildrenList();
List<? extends ConfigurationNode> list = vectorNode.childrenList();
return new Vector4f(
list.get(0).getFloat(),
list.get(1).getFloat(),
@ -118,18 +115,18 @@ public static Vector4f readVector4f(ConfigurationNode vectorNode){
}
return new Vector4f(
vectorNode.getNode("x").getFloat(),
vectorNode.getNode("y").getFloat(),
vectorNode.getNode("z").getFloat(),
vectorNode.getNode("w").getFloat()
vectorNode.node("x").getFloat(),
vectorNode.node("y").getFloat(),
vectorNode.node("z").getFloat(),
vectorNode.node("w").getFloat()
);
}
public static void writeVector4f(ConfigurationNode vectorNode, Vector4f v){
vectorNode.appendListNode().setValue(v.getX());
vectorNode.appendListNode().setValue(v.getY());
vectorNode.appendListNode().setValue(v.getZ());
vectorNode.appendListNode().setValue(v.getW());
public static void writeVector4f(ConfigurationNode vectorNode, Vector4f v) throws SerializationException {
vectorNode.appendListNode().set(v.getX());
vectorNode.appendListNode().set(v.getY());
vectorNode.appendListNode().set(v.getZ());
vectorNode.appendListNode().set(v.getW());
}
/**
@ -139,7 +136,7 @@ public static void writeVector4f(ConfigurationNode vectorNode, Vector4f v){
* @throws NumberFormatException If the value is not formatted correctly or if there is no value present.
*/
public static int readColorInt(ConfigurationNode node) throws NumberFormatException {
Object value = node.getValue();
Object value = node.raw();
if (value == null) throw new NumberFormatException("No value!");
@ -161,10 +158,10 @@ public static int readColorInt(ConfigurationNode node) throws NumberFormatExcept
}
public static String nodePathToString(ConfigurationNode node) {
Object[] keys = node.getPath();
String[] stringKeys = new String[keys.length];
for (int i = 0; i < keys.length; i++) {
stringKeys[i] = keys[i].toString();
NodePath keys = node.path();
String[] stringKeys = new String[keys.size()];
for (int i = 0; i < keys.size(); i++) {
stringKeys[i] = keys.get(i).toString();
}
return String.join(".", stringKeys);
}

View File

@ -25,7 +25,9 @@
package de.bluecolored.bluemap.core.util;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.base.Preconditions;
import java.util.Objects;
public enum Direction {
@ -90,7 +92,7 @@ public Axis getAxis() {
}
public static Direction fromString(String name){
Preconditions.checkNotNull(name);
Objects.requireNonNull(name);
return valueOf(name.toUpperCase());
}

View File

@ -0,0 +1,37 @@
/*
* This file is part of BlueMap, licensed under the MIT License (MIT).
*
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package de.bluecolored.bluemap.core.util;
public class Preconditions {
public static void checkArgument(boolean argument) throws IllegalArgumentException {
if (!argument) throw new IllegalArgumentException();
}
public static void checkArgument(boolean argument, String message) throws IllegalArgumentException {
if (!argument) throw new IllegalArgumentException(message);
}
}

View File

@ -26,11 +26,10 @@
import com.flowpowered.math.vector.Vector3f;
import com.flowpowered.math.vector.Vector4f;
import com.google.common.base.MoreObjects;
import de.bluecolored.bluemap.core.util.ConfigUtils;
import de.bluecolored.bluemap.core.util.MathUtils;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode;
public class Biome {
@ -94,27 +93,27 @@ public static Biome create(String id, ConfigurationNode node) {
Biome biome = new Biome();
biome.id = id;
biome.numeralId = node.getNode("id").getInt(biome.numeralId);
biome.humidity = node.getNode("humidity").getFloat(biome.humidity);
biome.temp = node.getNode("temp").getFloat(biome.temp);
try { biome.waterColor = MathUtils.color3FromInt(ConfigUtils.readColorInt(node.getNode("watercolor"))); } catch (NumberFormatException ignored) {}
try { biome.overlayFoliageColor = MathUtils.color4FromInt(ConfigUtils.readColorInt(node.getNode("foliagecolor"))); } catch (NumberFormatException ignored) {}
try { biome.overlayGrassColor = MathUtils.color4FromInt(ConfigUtils.readColorInt(node.getNode("grasscolor"))); } catch (NumberFormatException ignored) {}
biome.numeralId = node.node("id").getInt(biome.numeralId);
biome.humidity = node.node("humidity").getFloat(biome.humidity);
biome.temp = node.node("temp").getFloat(biome.temp);
try { biome.waterColor = MathUtils.color3FromInt(ConfigUtils.readColorInt(node.node("watercolor"))); } catch (NumberFormatException ignored) {}
try { biome.overlayFoliageColor = MathUtils.color4FromInt(ConfigUtils.readColorInt(node.node("foliagecolor"))); } catch (NumberFormatException ignored) {}
try { biome.overlayGrassColor = MathUtils.color4FromInt(ConfigUtils.readColorInt(node.node("grasscolor"))); } catch (NumberFormatException ignored) {}
return biome;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("id", getId())
.add("numeralId", getNumeralId())
.add("humidity", getHumidity())
.add("temp", getTemp())
.add("waterColor", getWaterColor())
.add("overlayFoliageColor", getOverlayFoliageColor())
.add("overlayGrassColor", getOverlayGrassColor())
.toString();
return "Biome{" +
"id='" + id + '\'' +
", numeralId=" + numeralId +
", humidity=" + humidity +
", temp=" + temp +
", waterColor=" + waterColor +
", overlayFoliageColor=" + overlayFoliageColor +
", overlayGrassColor=" + overlayGrassColor +
'}';
}
}

View File

@ -25,8 +25,6 @@
package de.bluecolored.bluemap.core.world;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.base.MoreObjects;
import de.bluecolored.bluemap.core.util.Direction;
public class Block {
@ -163,13 +161,13 @@ public void setPos(Vector3i pos) {
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("pos", getPosition())
.add("biome", getBiome())
.add("blocklight", getBlockLightLevel())
.add("sunlight", getSunLightLevel())
.add("state", getBlockState())
.toString();
return "Block{" +
"blockState=" + blockState +
", biome=" + biome +
", pos=" + pos +
", sunLight=" + sunLight +
", blockLight=" + blockLight +
'}';
}
}

View File

@ -1,6 +1,7 @@
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '5.1.0'
id 'java-library'
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'com.github.hierynomus.license' version '0.15.0'
}
@ -36,6 +37,7 @@ allprojects {
}
apply plugin: 'java'
apply plugin: 'java-library'
group = 'de.bluecolored.bluemap'
version = coreVersion

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -1,6 +1,6 @@
dependencies {
compile group: 'commons-cli', name: 'commons-cli', version: '1.4'
compile project(':BlueMapCommon')
implementation group: 'commons-cli', name: 'commons-cli', version: '1.4'
implementation project(':BlueMapCommon')
}
jar {
@ -10,14 +10,14 @@ jar {
}
build.dependsOn shadowJar {
destinationDir = file '../../build/release'
archiveFileName = "BlueMap-${version}-cli.jar"
destinationDirectory = file '../../build/release'
archiveFileName.set("BlueMap-${archiveVersion.get()}-cli.jar")
//relocate 'com.flowpowered.math', 'de.bluecolored.shadow.flowpowered.math' //DON'T relocate this, because the API depends on it
relocate 'com.google', 'de.bluecolored.shadow.google'
relocate 'com.typesafe', 'de.bluecolored.shadow.typesafe'
relocate 'net.querz.nbt', 'de.bluecolored.shadow.querz.nbt'
relocate 'ninja.leaping.configurate', 'de.bluecolored.shadow.ninja.leaping.configurate'
relocate 'org.spongepowered.configurate', 'de.bluecolored.shadow.configurate'
relocate 'org.apache', 'de.bluecolored.shadow.apache'
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
relocate 'org.aopalliance', 'de.bluecolored.shadow.aopalliance'
@ -26,4 +26,5 @@ build.dependsOn shadowJar {
relocate 'com.mojang.brigadier', 'de.bluecolored.shadow.mojang.brigadier'
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
relocate 'org.codehaus', 'de.bluecolored.shadow.codehaus'
relocate 'io.leangen.geantyref', 'de.bluecolored.shadow.geantyref'
}

View File

@ -1,11 +1,11 @@
import net.fabricmc.loom.task.RemapJarTask
plugins {
id 'fabric-loom' version '0.4-SNAPSHOT'
id 'fabric-loom' version '0.6-SNAPSHOT'
}
configurations {
compile.extendsFrom shadowInclude
implementation.extendsFrom shadowInclude
}
dependencies {
@ -43,7 +43,7 @@ shadowJar {
//relocate 'com.flowpowered.math', 'de.bluecolored.shadow.flowpowered.math' //DON'T relocate this, because the API depends on it
relocate 'com.typesafe.config', 'de.bluecolored.shadow.typesafe.config'
relocate 'net.querz.nbt', 'de.bluecolored.shadow.querz.nbt'
relocate 'ninja.leaping.configurate', 'de.bluecolored.shadow.ninja.leaping.configurate'
relocate 'org.spongepowered.configurate', 'de.bluecolored.shadow.configurate'
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
relocate 'com.google.errorprone', 'de.bluecolored.shadow.google.errorprone'
relocate 'org.aopalliance', 'de.bluecolored.shadow.aopalliance'
@ -51,18 +51,19 @@ shadowJar {
relocate 'com.google.inject', 'de.bluecolored.shadow.google.inject'
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
relocate 'org.codehaus', 'de.bluecolored.shadow.codehaus'
relocate 'io.leangen.geantyref', 'de.bluecolored.shadow.geantyref'
}
task ramappedShadowJar(type: RemapJarTask) {
destinationDir = file '../../build/release'
destinationDirectory = file '../../build/release'
dependsOn tasks.shadowJar
input = tasks.shadowJar.archivePath
addNestedDependencies = true
archiveName = "BlueMap-${version}-fabric-1.15.2.jar"
input.set(tasks.shadowJar.archiveFile.get())
addNestedDependencies.set(true)
archiveFileName.set("BlueMap-${archiveVersion.get()}-fabric-1.15.2.jar")
}
build.dependsOn ramappedShadowJar
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
archiveClassifier.set("sources")
from sourceSets.main.allSource
}

View File

@ -1,11 +1,11 @@
import net.fabricmc.loom.task.RemapJarTask
plugins {
id 'fabric-loom' version '0.4-SNAPSHOT'
id 'fabric-loom' version '0.6-SNAPSHOT'
}
configurations {
compile.extendsFrom shadowInclude
implementation.extendsFrom shadowInclude
}
dependencies {
@ -43,7 +43,7 @@ shadowJar {
//relocate 'com.flowpowered.math', 'de.bluecolored.shadow.flowpowered.math' //DON'T relocate this, because the API depends on it
relocate 'com.typesafe.config', 'de.bluecolored.shadow.typesafe.config'
relocate 'net.querz.nbt', 'de.bluecolored.shadow.querz.nbt'
relocate 'ninja.leaping.configurate', 'de.bluecolored.shadow.ninja.leaping.configurate'
relocate 'org.spongepowered.configurate', 'de.bluecolored.shadow.configurate'
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
relocate 'com.google.errorprone', 'de.bluecolored.shadow.google.errorprone'
relocate 'org.aopalliance', 'de.bluecolored.shadow.aopalliance'
@ -51,18 +51,19 @@ shadowJar {
relocate 'com.google.inject', 'de.bluecolored.shadow.google.inject'
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
relocate 'org.codehaus', 'de.bluecolored.shadow.codehaus'
relocate 'io.leangen.geantyref', 'de.bluecolored.shadow.geantyref'
}
task ramappedShadowJar(type: RemapJarTask) {
destinationDir = file '../../build/release'
destinationDirectory = file '../../build/release'
dependsOn tasks.shadowJar
input = tasks.shadowJar.archivePath
addNestedDependencies = true
archiveName = "BlueMap-${version}-fabric-1.16.1.jar"
input.set(tasks.shadowJar.archiveFile.get())
addNestedDependencies.set(true)
archiveFileName.set("BlueMap-${archiveVersion.get()}-fabric-1.16.1.jar")
}
build.dependsOn ramappedShadowJar
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
archiveClassifier.set("sources")
from sourceSets.main.allSource
}

View File

@ -1,11 +1,11 @@
import net.fabricmc.loom.task.RemapJarTask
plugins {
id 'fabric-loom' version '0.4-SNAPSHOT'
id 'fabric-loom' version '0.6-SNAPSHOT'
}
configurations {
compile.extendsFrom shadowInclude
implementation.extendsFrom shadowInclude
}
dependencies {
@ -43,7 +43,7 @@ shadowJar {
//relocate 'com.flowpowered.math', 'de.bluecolored.shadow.flowpowered.math' //DON'T relocate this, because the API depends on it
relocate 'com.typesafe.config', 'de.bluecolored.shadow.typesafe.config'
relocate 'net.querz.nbt', 'de.bluecolored.shadow.querz.nbt'
relocate 'ninja.leaping.configurate', 'de.bluecolored.shadow.ninja.leaping.configurate'
relocate 'org.spongepowered.configurate', 'de.bluecolored.shadow.configurate'
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
relocate 'com.google.errorprone', 'de.bluecolored.shadow.google.errorprone'
relocate 'org.aopalliance', 'de.bluecolored.shadow.aopalliance'
@ -51,18 +51,19 @@ shadowJar {
relocate 'com.google.inject', 'de.bluecolored.shadow.google.inject'
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
relocate 'org.codehaus', 'de.bluecolored.shadow.codehaus'
relocate 'io.leangen.geantyref', 'de.bluecolored.shadow.geantyref'
}
task ramappedShadowJar(type: RemapJarTask) {
destinationDir = file '../../build/release'
destinationDirectory = file '../../build/release'
dependsOn tasks.shadowJar
input = tasks.shadowJar.archivePath
addNestedDependencies = true
archiveName = "BlueMap-${version}-fabric-1.16.4.jar"
input.set(tasks.shadowJar.archiveFile.get())
addNestedDependencies.set(true)
archiveFileName.set("BlueMap-${archiveVersion.get()}-fabric-1.16.4.jar")
}
build.dependsOn ramappedShadowJar
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
archiveClassifier.set("sources")
from sourceSets.main.allSource
}

View File

@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
}
}
@ -16,7 +16,7 @@ minecraft {
}
configurations {
compile.extendsFrom include
implementation.extendsFrom include
}
dependencies {
@ -33,15 +33,15 @@ dependencies {
}
build.dependsOn shadowJar {
destinationDir = file '../../build/release'
archiveFileName = "BlueMap-${version}-forge-1.14.4.jar"
destinationDirectory = file '../../build/release'
archiveFileName.set("BlueMap-${archiveVersion.get()}-forge-1.14.4.jar")
configurations = [project.configurations.include]
//relocate 'com.flowpowered.math', 'de.bluecolored.shadow.flowpowered.math' //DON'T relocate this, because the API depends on it
relocate 'com.typesafe.config', 'de.bluecolored.shadow.typesafe.config'
relocate 'net.querz.nbt', 'de.bluecolored.shadow.querz.nbt'
relocate 'ninja.leaping.configurate', 'de.bluecolored.shadow.ninja.leaping.configurate'
relocate 'org.spongepowered.configurate', 'de.bluecolored.shadow.configurate'
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
relocate 'com.google.errorprone', 'de.bluecolored.shadow.google.errorprone'
relocate 'org.aopalliance', 'de.bluecolored.shadow.aopalliance'
@ -49,11 +49,13 @@ build.dependsOn shadowJar {
relocate 'com.google.inject', 'de.bluecolored.shadow.google.inject'
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
relocate 'org.codehaus', 'de.bluecolored.shadow.codehaus'
relocate 'io.leangen.geantyref', 'de.bluecolored.shadow.geantyref'
}
processResources {
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info','META-INF/mods.toml'
duplicatesStrategy = DuplicatesStrategy.WARN
expand (
version: project.version

View File

@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
}
}
@ -16,7 +16,7 @@ minecraft {
}
configurations {
compile.extendsFrom include
implementation.extendsFrom include
}
dependencies {
@ -33,15 +33,15 @@ dependencies {
}
build.dependsOn shadowJar {
destinationDir = file '../../build/release'
archiveFileName = "BlueMap-${version}-forge-1.15.2.jar"
destinationDirectory = file '../../build/release'
archiveFileName.set("BlueMap-${archiveVersion.get()}-forge-1.15.2.jar")
configurations = [project.configurations.include]
//relocate 'com.flowpowered.math', 'de.bluecolored.shadow.flowpowered.math' //DON'T relocate this, because the API depends on it
relocate 'com.typesafe.config', 'de.bluecolored.shadow.typesafe.config'
relocate 'net.querz.nbt', 'de.bluecolored.shadow.querz.nbt'
relocate 'ninja.leaping.configurate', 'de.bluecolored.shadow.ninja.leaping.configurate'
relocate 'org.spongepowered.configurate', 'de.bluecolored.shadow.configurate'
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
relocate 'com.google.errorprone', 'de.bluecolored.shadow.google.errorprone'
relocate 'org.aopalliance', 'de.bluecolored.shadow.aopalliance'
@ -49,11 +49,13 @@ build.dependsOn shadowJar {
relocate 'com.google.inject', 'de.bluecolored.shadow.google.inject'
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
relocate 'org.codehaus', 'de.bluecolored.shadow.codehaus'
relocate 'io.leangen.geantyref', 'de.bluecolored.shadow.geantyref'
}
processResources {
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info','META-INF/mods.toml'
duplicatesStrategy = DuplicatesStrategy.WARN
expand (
version: project.version

View File

@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
}
}
@ -16,7 +16,7 @@ minecraft {
}
configurations {
compile.extendsFrom include
implementation.extendsFrom include
}
dependencies {
@ -33,15 +33,15 @@ dependencies {
}
build.dependsOn shadowJar {
destinationDir = file '../../build/release'
archiveFileName = "BlueMap-${version}-forge-1.16.4.jar"
destinationDirectory = file '../../build/release'
archiveFileName.set("BlueMap-${archiveVersion.get()}-forge-1.16.4.jar")
configurations = [project.configurations.include]
//relocate 'com.flowpowered.math', 'de.bluecolored.shadow.flowpowered.math' //DON'T relocate this, because the API depends on it
relocate 'com.typesafe.config', 'de.bluecolored.shadow.typesafe.config'
relocate 'net.querz.nbt', 'de.bluecolored.shadow.querz.nbt'
relocate 'ninja.leaping.configurate', 'de.bluecolored.shadow.ninja.leaping.configurate'
relocate 'org.spongepowered.configurate', 'de.bluecolored.shadow.configurate'
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
relocate 'com.google.errorprone', 'de.bluecolored.shadow.google.errorprone'
relocate 'org.aopalliance', 'de.bluecolored.shadow.aopalliance'
@ -49,11 +49,13 @@ build.dependsOn shadowJar {
relocate 'com.google.inject', 'de.bluecolored.shadow.google.inject'
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
relocate 'org.codehaus', 'de.bluecolored.shadow.codehaus'
relocate 'io.leangen.geantyref', 'de.bluecolored.shadow.geantyref'
}
processResources {
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info','META-INF/mods.toml'
duplicatesStrategy = DuplicatesStrategy.WARN
expand (
version: project.version

View File

@ -11,9 +11,9 @@ repositories {
dependencies {
shadow "org.spigotmc:spigot-api:1.13-R0.1-SNAPSHOT"
compile group: 'org.bstats', name: 'bstats-bukkit-lite', version: '1.5'
implementation group: 'org.bstats', name: 'bstats-bukkit-lite', version: '1.5'
compile (project(':BlueMapCommon')) {
implementation (project(':BlueMapCommon')) {
//exclude dependencies provided by bukkit
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'com.google.code.gson', module: 'gson'
@ -21,13 +21,13 @@ dependencies {
}
build.dependsOn shadowJar {
destinationDir = file '../../build/release'
archiveFileName = "BlueMap-${version}-spigot.jar"
destinationDirectory = file '../../build/release'
archiveFileName.set("BlueMap-${archiveVersion.get()}-spigot.jar")
//relocate 'com.flowpowered.math', 'de.bluecolored.shadow.flowpowered.math' //DON'T relocate this, because the API depends on it
relocate 'com.typesafe.config', 'de.bluecolored.shadow.typesafe.config'
relocate 'net.querz.nbt', 'de.bluecolored.shadow.querz.nbt'
relocate 'ninja.leaping.configurate', 'de.bluecolored.shadow.ninja.leaping.configurate'
relocate 'org.spongepowered.configurate', 'de.bluecolored.shadow.configurate'
relocate 'org.apache.commons.io', 'de.bluecolored.shadow.apache.commons.io'
relocate 'org.apache.commons.lang3', 'de.bluecolored.shadow.apache.commons.lang3'
relocate 'org.bstats.bukkit', 'de.bluecolored.shadow.bstats.bukkit'
@ -39,11 +39,13 @@ build.dependsOn shadowJar {
relocate 'com.google.inject', 'de.bluecolored.shadow.google.inject'
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
relocate 'org.codehaus', 'de.bluecolored.shadow.codehaus'
relocate 'io.leangen.geantyref', 'de.bluecolored.shadow.geantyref'
}
processResources {
from(sourceSets.main.resources.srcDirs) {
include 'plugin.yml'
duplicatesStrategy = DuplicatesStrategy.WARN
expand (
version: project.version

View File

@ -1,9 +1,9 @@
dependencies {
shadow "org.spongepowered:spongeapi:7.3.0"
compile group: 'org.bstats', name: 'bstats-sponge-lite', version: '1.5'
implementation group: 'org.bstats', name: 'bstats-sponge-lite', version: '1.5'
compile (project(':BlueMapCommon')) {
implementation (project(':BlueMapCommon')) {
//exclude dependencies provided by sponge
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'com.google.code.gson', module: 'gson'
@ -15,24 +15,26 @@ dependencies {
}
build.dependsOn shadowJar {
destinationDir = file '../../build/release'
archiveFileName = "BlueMap-${version}-sponge-7.3.0.jar"
destinationDirectory = file '../../build/release'
archiveFileName.set("BlueMap-${archiveVersion.get()}-sponge-7.3.0.jar")
relocate 'net.querz.nbt', 'de.bluecolored.shadow.querz.nbt'
relocate 'org.apache.commons.io', 'de.bluecolored.shadow.apache.commons.io'
relocate 'com.mojang.brigadier', 'de.bluecolored.shadow.mojang.brigadier'
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
relocate 'com.google.errorprone', 'de.bluecolored.shadow.google.errorprone'
relocate 'ninja.leaping.configurate', 'de.bluecolored.shadow.ninja.leaping.configurate'
relocate 'org.spongepowered.configurate', 'de.bluecolored.shadow.configurate'
relocate 'org.aopalliance', 'de.bluecolored.shadow.aopalliance'
relocate 'com.typesafe.config', 'de.bluecolored.shadow.typesafe.config'
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
relocate 'org.codehaus', 'de.bluecolored.shadow.codehaus'
relocate 'io.leangen.geantyref', 'de.bluecolored.shadow.geantyref'
}
processResources {
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
duplicatesStrategy = DuplicatesStrategy.WARN
expand (
version: project.version