mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-02-21 15:01:29 +01:00
Merge branch 'mc/1.13' into mc/1.12
This commit is contained in:
commit
d3828bcbfd
@ -1 +1 @@
|
||||
Subproject commit 51ea1fe8d1e48eeeeb5e71af9e3d12c371214d89
|
||||
Subproject commit eeb0c99c8bee69513ec8b25bb2dea8a3370f7423
|
@ -25,6 +25,7 @@
|
||||
package de.bluecolored.bluemap.common.api;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Path;
|
||||
@ -35,16 +36,19 @@
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import de.bluecolored.bluemap.api.BlueMapAPI;
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapWorld;
|
||||
import de.bluecolored.bluemap.api.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.BlueMapWorld;
|
||||
import de.bluecolored.bluemap.common.MapType;
|
||||
import de.bluecolored.bluemap.common.api.marker.MarkerAPIImpl;
|
||||
import de.bluecolored.bluemap.common.api.render.RenderAPIImpl;
|
||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
||||
import de.bluecolored.bluemap.core.BlueMap;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.world.World;
|
||||
|
||||
public class BlueMapAPIImpl extends BlueMapAPI {
|
||||
@ -105,11 +109,16 @@ public String createImage(BufferedImage image, String path) throws IOException {
|
||||
|
||||
Path imagePath;
|
||||
if (webDataRoot.startsWith(webRoot)) {
|
||||
imagePath = webDataRoot.resolve(Paths.get(IMAGE_ROOT_PATH, path.replace("/", separator))).toAbsolutePath();
|
||||
imagePath = webDataRoot.resolve(Paths.get(IMAGE_ROOT_PATH, path.replace("/", separator) + ".png")).toAbsolutePath();
|
||||
} else {
|
||||
imagePath = webRoot.resolve("assets").resolve(Paths.get(IMAGE_ROOT_PATH, path.replace("/", separator))).toAbsolutePath();
|
||||
imagePath = webRoot.resolve("assets").resolve(Paths.get(IMAGE_ROOT_PATH, path.replace("/", separator) + ".png")).toAbsolutePath();
|
||||
}
|
||||
|
||||
File imageFile = imagePath.toFile();
|
||||
imageFile.getParentFile().mkdirs();
|
||||
imageFile.delete();
|
||||
imageFile.createNewFile();
|
||||
|
||||
if (!ImageIO.write(image, "png", imagePath.toFile()))
|
||||
throw new IOException("The format 'png' is not supported!");
|
||||
|
||||
@ -148,11 +157,19 @@ public BlueMapMapImpl getMapForId(String mapId) {
|
||||
}
|
||||
|
||||
public void register() {
|
||||
BlueMapAPI.registerInstance(this);
|
||||
try {
|
||||
BlueMapAPI.registerInstance(this);
|
||||
} catch (ExecutionException ex) {
|
||||
Logger.global.logError("BlueMapAPI: A BlueMapAPIListener threw an exception (onEnable)!", ex.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
BlueMapAPI.unregisterInstance(this);
|
||||
try {
|
||||
BlueMapAPI.unregisterInstance(this);
|
||||
} catch (ExecutionException ex) {
|
||||
Logger.global.logError("BlueMapAPI: A BlueMapAPIListener threw an exception (onDisable)!", ex.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.BlueMapMap;
|
||||
import de.bluecolored.bluemap.common.MapType;
|
||||
|
||||
public class BlueMapMapImpl implements BlueMapMap {
|
||||
|
@ -30,8 +30,8 @@
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapWorld;
|
||||
import de.bluecolored.bluemap.api.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.BlueMapWorld;
|
||||
import de.bluecolored.bluemap.core.world.World;
|
||||
|
||||
public class BlueMapWorldImpl implements BlueMapWorld {
|
||||
@ -48,8 +48,7 @@ protected BlueMapWorldImpl(BlueMapAPIImpl api, World delegate) {
|
||||
|
||||
@Override
|
||||
public Path getSaveFolder() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return delegate.getSaveFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,7 +29,6 @@
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -95,8 +94,10 @@ public synchronized boolean removeMarkerSet(String id) {
|
||||
|
||||
@Override
|
||||
public synchronized void load() throws IOException {
|
||||
this.removedMarkerSets.clear();
|
||||
|
||||
load(true);
|
||||
}
|
||||
|
||||
private synchronized void load(boolean overwriteChanges) throws IOException {
|
||||
if (!markerFile.exists()) {
|
||||
markerFile.getParentFile().mkdirs();
|
||||
markerFile.createNewFile();
|
||||
@ -108,55 +109,51 @@ public synchronized void load() throws IOException {
|
||||
Set<String> externallyRemovedSets = new HashSet<>(markerSets.keySet());
|
||||
for (ConfigurationNode markerSetNode : node.getNode("markerSets").getChildrenList()) {
|
||||
String setId = markerSetNode.getNode("id").getString();
|
||||
if (setId == null) continue;
|
||||
|
||||
externallyRemovedSets.remove(setId);
|
||||
MarkerSetImpl set = markerSets.get(setId);
|
||||
|
||||
if (set == null) {
|
||||
set = new MarkerSetImpl(setId);
|
||||
if (setId == null) {
|
||||
Logger.global.logDebug("Marker-API: Failed to load a markerset: No id defined!");
|
||||
continue;
|
||||
}
|
||||
|
||||
externallyRemovedSets.remove(setId);
|
||||
if (!overwriteChanges && removedMarkerSets.contains(setId)) continue;
|
||||
|
||||
MarkerSetImpl set = markerSets.get(setId);
|
||||
|
||||
try {
|
||||
set.load(api, markerSetNode);
|
||||
if (set == null) {
|
||||
set = new MarkerSetImpl(setId);
|
||||
set.load(api, markerSetNode, true);
|
||||
} else {
|
||||
set.load(api, markerSetNode, overwriteChanges);
|
||||
}
|
||||
markerSets.put(setId, set);
|
||||
} catch (MarkerFileFormatException ex) {
|
||||
Logger.global.logDebug("Marker-API: Failed to load marker-set '" + setId + ": " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
for (String setId : externallyRemovedSets) {
|
||||
markerSets.remove(setId);
|
||||
if (overwriteChanges) {
|
||||
for (String setId : externallyRemovedSets) {
|
||||
markerSets.remove(setId);
|
||||
}
|
||||
|
||||
removedMarkerSets.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void save() throws IOException {
|
||||
if (!markerFile.exists()) {
|
||||
markerFile.getParentFile().mkdirs();
|
||||
markerFile.createNewFile();
|
||||
}
|
||||
load(false);
|
||||
|
||||
GsonConfigurationLoader loader = GsonConfigurationLoader.builder().setFile(markerFile).build();
|
||||
ConfigurationNode node = loader.load();
|
||||
ConfigurationNode node = loader.createEmptyNode();
|
||||
|
||||
List<? extends ConfigurationNode> markerList = node.getNode("markerSets").getChildrenList();
|
||||
node.removeChild("markerSets");
|
||||
|
||||
Set<String> newMarkers = new HashSet<>(markerSets.keySet());
|
||||
for (ConfigurationNode markerSetNode : markerList) {
|
||||
String setId = markerSetNode.getNode("id").getString();
|
||||
if (setId == null) continue;
|
||||
if (removedMarkerSets.contains(setId)) continue;
|
||||
|
||||
newMarkers.remove(setId);
|
||||
MarkerSetImpl set = markerSets.get(setId);
|
||||
|
||||
if (set != null) set.save(markerSetNode, false);
|
||||
|
||||
node.getNode("markerSets").getAppendedNode().mergeValuesFrom(markerSetNode);
|
||||
for (MarkerSetImpl set : markerSets.values()) {
|
||||
set.save(node.getNode("markerSets").getAppendedNode());
|
||||
}
|
||||
|
||||
loader.save(node);
|
||||
|
||||
removedMarkerSets.clear();
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,8 @@
|
||||
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 de.bluecolored.bluemap.api.renderer.BlueMapMap;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
public abstract class MarkerImpl implements Marker {
|
||||
@ -147,8 +147,9 @@ public synchronized void removeLink() {
|
||||
this.hasUnsavedChanges = true;
|
||||
}
|
||||
|
||||
public synchronized void load(BlueMapAPI api, ConfigurationNode markerNode) throws MarkerFileFormatException {
|
||||
this.hasUnsavedChanges = false;
|
||||
public synchronized void load(BlueMapAPI api, ConfigurationNode markerNode, boolean overwriteChanges) throws MarkerFileFormatException {
|
||||
if (!overwriteChanges && hasUnsavedChanges) return;
|
||||
hasUnsavedChanges = false;
|
||||
|
||||
//map
|
||||
String mapId = markerNode.getNode("map").getString();
|
||||
@ -170,9 +171,7 @@ public synchronized void load(BlueMapAPI api, ConfigurationNode markerNode) thro
|
||||
this.newTab = markerNode.getNode("newTab").getBoolean(true);
|
||||
}
|
||||
|
||||
public synchronized void save(ConfigurationNode markerNode, boolean force) {
|
||||
if (!force && !hasUnsavedChanges) return;
|
||||
|
||||
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());
|
||||
|
@ -27,7 +27,6 @@
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -37,10 +36,10 @@
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import de.bluecolored.bluemap.api.BlueMapAPI;
|
||||
import de.bluecolored.bluemap.api.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.marker.Marker;
|
||||
import de.bluecolored.bluemap.api.marker.MarkerSet;
|
||||
import de.bluecolored.bluemap.api.marker.Shape;
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapMap;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
@ -145,87 +144,76 @@ public synchronized boolean removeMarker(String id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized void load(BlueMapAPI api, ConfigurationNode node) throws MarkerFileFormatException {
|
||||
this.hasUnsavedChanges = false;
|
||||
this.removedMarkers.clear();
|
||||
|
||||
this.label = node.getNode("label").getString(id);
|
||||
this.toggleable = node.getNode("toggleable").getBoolean(true);
|
||||
this.isDefaultHidden = node.getNode("defaultHide").getBoolean(false);
|
||||
|
||||
public synchronized void load(BlueMapAPI api, ConfigurationNode node, boolean overwriteChanges) throws MarkerFileFormatException {
|
||||
BlueMapMap dummyMap = api.getMaps().iterator().next();
|
||||
Shape dummyShape = Shape.createRect(0d, 0d, 1d, 1d);
|
||||
Set<String> externallyRemovedMarkers = new HashSet<>(this.markers.keySet());
|
||||
|
||||
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();
|
||||
|
||||
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!");
|
||||
continue;
|
||||
}
|
||||
|
||||
externallyRemovedMarkers.remove(id);
|
||||
if (!overwriteChanges && removedMarkers.contains(id)) continue;
|
||||
|
||||
MarkerImpl marker = markers.get(id);
|
||||
externallyRemovedMarkers.remove(id);
|
||||
|
||||
if (marker == null || !marker.getType().equals(type)) {
|
||||
switch (type) {
|
||||
case POIMarkerImpl.MARKER_TYPE:
|
||||
marker = new POIMarkerImpl(id, dummyMap, Vector3d.ZERO);
|
||||
break;
|
||||
case ShapeMarkerImpl.MARKER_TYPE:
|
||||
marker = new ShapeMarkerImpl(id, dummyMap, Vector3d.ZERO, dummyShape, 0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
marker.load(api, markerNode);
|
||||
if (marker == null || !marker.getType().equals(type)) {
|
||||
switch (type) {
|
||||
case POIMarkerImpl.MARKER_TYPE:
|
||||
marker = new POIMarkerImpl(id, dummyMap, Vector3d.ZERO);
|
||||
break;
|
||||
case ShapeMarkerImpl.MARKER_TYPE:
|
||||
marker = new ShapeMarkerImpl(id, dummyMap, Vector3d.ZERO, dummyShape, 0f);
|
||||
break;
|
||||
default:
|
||||
Logger.global.logDebug("Marker-API: Failed to load marker '" + id + "' in the set '" + this.id + "': Unknown marker-type '" + type + "'!");
|
||||
continue;
|
||||
}
|
||||
|
||||
marker.load(api, markerNode, true);
|
||||
} else {
|
||||
marker.load(api, markerNode, overwriteChanges);
|
||||
}
|
||||
markers.put(id, marker);
|
||||
} catch (MarkerFileFormatException ex) {
|
||||
Logger.global.logDebug("Marker-API: Failed to load marker '" + id + "' in the set '" + this.id + "': " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
for (String id : externallyRemovedMarkers) {
|
||||
markers.remove(id);
|
||||
if (overwriteChanges) {
|
||||
for (String id : externallyRemovedMarkers) {
|
||||
markers.remove(id);
|
||||
}
|
||||
|
||||
this.removedMarkers.clear();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public synchronized void save(ConfigurationNode node, boolean force) {
|
||||
List<? extends ConfigurationNode> markerList = node.getNode("marker").getChildrenList();
|
||||
node.removeChild("marker");
|
||||
|
||||
Set<String> newMarkers = new HashSet<>(markers.keySet());
|
||||
for (ConfigurationNode markerNode : markerList) {
|
||||
String id = markerNode.getNode("id").getString();
|
||||
if (id == null) continue;
|
||||
if (removedMarkers.contains(id)) continue;
|
||||
|
||||
newMarkers.remove(id);
|
||||
MarkerImpl marker = markers.get(id);
|
||||
|
||||
if (marker != null) marker.save(markerNode, false);
|
||||
|
||||
node.getNode("marker").getAppendedNode().mergeValuesFrom(markerNode);
|
||||
}
|
||||
|
||||
for (String markerId : newMarkers) {
|
||||
MarkerImpl marker = markers.get(markerId);
|
||||
if (marker == null) continue;
|
||||
|
||||
marker.save(node.getNode("marker").getAppendedNode(), true);
|
||||
}
|
||||
|
||||
removedMarkers.clear();
|
||||
|
||||
if (!force && !hasUnsavedChanges) return;
|
||||
|
||||
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);
|
||||
|
||||
for (MarkerImpl marker : markers.values()) {
|
||||
marker.save(node.getNode("marker").getAppendedNode());
|
||||
}
|
||||
|
||||
removedMarkers.clear();
|
||||
this.hasUnsavedChanges = false;
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,8 @@
|
||||
import com.flowpowered.math.vector.Vector3d;
|
||||
|
||||
import de.bluecolored.bluemap.api.BlueMapAPI;
|
||||
import de.bluecolored.bluemap.api.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.marker.POIMarker;
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapMap;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
public class POIMarkerImpl extends MarkerImpl implements POIMarker {
|
||||
@ -72,9 +72,10 @@ public synchronized void setIcon(String iconAddress, Vector2i anchor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void load(BlueMapAPI api, ConfigurationNode markerNode) throws MarkerFileFormatException {
|
||||
super.load(api, markerNode);
|
||||
public synchronized void load(BlueMapAPI api, ConfigurationNode markerNode, boolean overwriteChanges) throws MarkerFileFormatException {
|
||||
super.load(api, markerNode, overwriteChanges);
|
||||
|
||||
if (!overwriteChanges && hasUnsavedChanges) return;
|
||||
this.hasUnsavedChanges = false;
|
||||
|
||||
this.iconAddress = markerNode.getNode("icon").getString("assets/poi.svg");
|
||||
@ -82,11 +83,9 @@ public synchronized void load(BlueMapAPI api, ConfigurationNode markerNode) thro
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void save(ConfigurationNode markerNode, boolean force) {
|
||||
super.save(markerNode, force);
|
||||
public synchronized void save(ConfigurationNode markerNode) {
|
||||
super.save(markerNode);
|
||||
|
||||
if (!force && !hasUnsavedChanges) return;
|
||||
|
||||
markerNode.getNode("icon").setValue(this.iconAddress);
|
||||
writeAnchor(markerNode.getNode("iconAnchor"), this.anchor);
|
||||
|
||||
|
@ -32,9 +32,9 @@
|
||||
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 de.bluecolored.bluemap.api.renderer.BlueMapMap;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
public class ShapeMarkerImpl extends MarkerImpl implements ShapeMarker {
|
||||
@ -53,6 +53,8 @@ public ShapeMarkerImpl(String id, BlueMapMap map, Vector3d position, Shape shape
|
||||
|
||||
this.shape = shape;
|
||||
this.height = height;
|
||||
this.borderColor = new Color(255, 0, 0, 200);
|
||||
this.fillColor = new Color(200, 0, 0, 100);
|
||||
|
||||
this.hasUnsavedChanges = true;
|
||||
}
|
||||
@ -108,20 +110,21 @@ public synchronized void setFillColor(Color color) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(BlueMapAPI api, ConfigurationNode markerNode) throws MarkerFileFormatException {
|
||||
super.load(api, markerNode);
|
||||
public void load(BlueMapAPI api, ConfigurationNode markerNode, boolean overwriteChanges) throws MarkerFileFormatException {
|
||||
super.load(api, markerNode, overwriteChanges);
|
||||
|
||||
this.shape = readShape(markerNode.getNode("icon"));
|
||||
if (!overwriteChanges && hasUnsavedChanges) return;
|
||||
this.hasUnsavedChanges = false;
|
||||
|
||||
this.shape = readShape(markerNode.getNode("shape"));
|
||||
this.height = markerNode.getNode("height").getFloat(64);
|
||||
this.borderColor = readColor(markerNode.getNode("borderColor"));
|
||||
this.fillColor = readColor(markerNode.getNode("fillColor"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(ConfigurationNode markerNode, boolean force) {
|
||||
super.save(markerNode, force);
|
||||
|
||||
if (!force && !hasUnsavedChanges) return;
|
||||
public void save(ConfigurationNode markerNode) {
|
||||
super.save(markerNode);
|
||||
|
||||
writeShape(markerNode.getNode("shape"), this.shape);
|
||||
markerNode.getNode("height").setValue(Math.round(height * 1000f) / 1000f);
|
||||
|
@ -22,23 +22,25 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package de.bluecolored.bluemap.common.api;
|
||||
package de.bluecolored.bluemap.common.api.render;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.renderer.RenderAPI;
|
||||
import de.bluecolored.bluemap.common.RenderManager;
|
||||
import de.bluecolored.bluemap.common.api.BlueMapAPIImpl;
|
||||
import de.bluecolored.bluemap.common.api.BlueMapMapImpl;
|
||||
|
||||
public class RenderAPIImpl implements RenderAPI {
|
||||
|
||||
private BlueMapAPIImpl api;
|
||||
private RenderManager renderManager;
|
||||
|
||||
protected RenderAPIImpl(BlueMapAPIImpl api, RenderManager renderManager) {
|
||||
public RenderAPIImpl(BlueMapAPIImpl api, RenderManager renderManager) {
|
||||
this.api = api;
|
||||
this.renderManager = renderManager;
|
||||
}
|
@ -312,6 +312,11 @@ public String getName() {
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getSaveFolder() {
|
||||
return worldFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSeaLevel() {
|
||||
|
@ -25,6 +25,7 @@
|
||||
package de.bluecolored.bluemap.core.world;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
@ -54,6 +55,11 @@ public String getName() {
|
||||
return world.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getSaveFolder() {
|
||||
return world.getSaveFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return world.getUUID();
|
||||
|
@ -25,6 +25,7 @@
|
||||
package de.bluecolored.bluemap.core.world;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
@ -45,6 +46,8 @@ public interface World {
|
||||
|
||||
UUID getUUID();
|
||||
|
||||
Path getSaveFolder();
|
||||
|
||||
int getSeaLevel();
|
||||
|
||||
Vector3i getSpawnPoint();
|
||||
|
@ -32,7 +32,7 @@ export default class ShapeMarker extends Marker {
|
||||
let shape = new Shape(points);
|
||||
let fillGeo = new ShapeBufferGeometry(shape, 1);
|
||||
fillGeo.rotateX(Math.PI * 0.5);
|
||||
fillGeo.translate(0, this.height + 0.0072, 0);
|
||||
fillGeo.translate(0, this.height + 0.0172, 0);
|
||||
let fillMaterial = new MeshBasicMaterial({
|
||||
color: this.fillColor.rgb,
|
||||
opacity: this.fillColor.a,
|
||||
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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.sponge;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.flowpowered.math.vector.Vector3d;
|
||||
|
||||
import de.bluecolored.bluemap.api.BlueMapAPI;
|
||||
import de.bluecolored.bluemap.api.BlueMapAPIListener;
|
||||
import de.bluecolored.bluemap.api.marker.MarkerAPI;
|
||||
import de.bluecolored.bluemap.api.marker.MarkerSet;
|
||||
import de.bluecolored.bluemap.api.marker.POIMarker;
|
||||
import de.bluecolored.bluemap.api.marker.Shape;
|
||||
|
||||
public class BlueMapIntegration implements BlueMapAPIListener {
|
||||
|
||||
@Override
|
||||
public void onEnable(BlueMapAPI blueMapApi) {
|
||||
|
||||
BufferedImage testIcon = new BufferedImage(50, 50, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = testIcon.getGraphics();
|
||||
g.setColor(Color.GREEN);
|
||||
g.fillOval(10, 15, 5, 10);
|
||||
|
||||
String icon = "";
|
||||
try {
|
||||
icon = blueMapApi.createImage(testIcon, "test/icon");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
MarkerAPI markerApi = blueMapApi.getMarkerAPI();
|
||||
|
||||
MarkerSet set = markerApi.createMarkerSet("testmarker");
|
||||
set.setLabel("Testmarker");
|
||||
set.setDefaultHidden(true);
|
||||
|
||||
markerApi.save();
|
||||
markerApi.load();
|
||||
|
||||
set.createShapeMarker("shape1", blueMapApi.getMap("world").get(), Vector3d.from(0, 70.023487, -5.23432542), Shape.createCircle(0, -5, 100, 20), 70);
|
||||
|
||||
MarkerAPI markerApi2 = blueMapApi.getMarkerAPI();
|
||||
|
||||
markerApi.save();
|
||||
|
||||
markerApi2.createMarkerSet("testmarker").createPOIMarker("poi1", blueMapApi.getMap("world").get(), Vector3d.from(10, 70.023487, -5.234322));
|
||||
markerApi2.save();
|
||||
|
||||
markerApi.load();
|
||||
((POIMarker) markerApi.getMarkerSet("testmarker").get().getMarker("poi1").get()).setIcon(icon, 10, 15);
|
||||
|
||||
markerApi.save();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -41,6 +41,7 @@
|
||||
import org.spongepowered.api.scheduler.SpongeExecutorService;
|
||||
import org.spongepowered.api.world.storage.WorldProperties;
|
||||
|
||||
import de.bluecolored.bluemap.api.BlueMapAPI;
|
||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
||||
import de.bluecolored.bluemap.common.plugin.serverinterface.ServerEventListener;
|
||||
import de.bluecolored.bluemap.common.plugin.serverinterface.ServerInterface;
|
||||
@ -72,6 +73,8 @@ public class SpongePlugin implements ServerInterface {
|
||||
public SpongePlugin(org.slf4j.Logger logger) {
|
||||
Logger.global = new Slf4jLogger(logger);
|
||||
|
||||
BlueMapAPI.registerListener(new BlueMapIntegration());
|
||||
|
||||
this.bluemap = new Plugin("sponge", this);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user