Compare commits

..

No commits in common. "master" and "v2.3.0" have entirely different histories.

26 changed files with 118 additions and 342 deletions

View File

@ -6,16 +6,14 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0 # needed for versioning
- name: Set up Java
uses: actions/setup-java@v4
- name: Set up Java 11
uses: actions/setup-java@v1
with:
distribution: 'temurin'
java-version: 16
cache: 'gradle'
java-version: 11
- name: Build with Gradle
run: ./gradlew clean build test
- uses: actions/upload-artifact@v2-preview

View File

@ -1,27 +0,0 @@
name: Publish
on:
workflow_dispatch:
push:
tags:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # needed for versioning
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 16
cache: 'gradle'
- name: Build with Gradle
run: ./gradlew publish
env:
BLUECOLORED_USERNAME: ${{ secrets.BLUECOLORED_USERNAME }}
BLUECOLORED_PASSWORD: ${{ secrets.BLUECOLORED_PASSWORD }}

View File

@ -33,20 +33,17 @@ val lastVersion = lastTag.substring(1) // remove the leading 'v'
val commits = "git rev-list --count $lastTag..HEAD".runCommand()
println("Git hash: $gitHash" + if (clean) "" else " (dirty)")
group = "de.bluecolored.bluemap"
group = "de.bluecolored.bluemap.api"
version = lastVersion +
(if (commits == "0") "" else "-$commits") +
(if (clean) "" else "-dirty")
println("Version: $version")
val javaTarget = 16
val javaTarget = 11
java {
sourceCompatibility = JavaVersion.toVersion(javaTarget)
targetCompatibility = JavaVersion.toVersion(javaTarget)
withSourcesJar()
withJavadocJar()
}
repositories {
@ -85,12 +82,8 @@ tasks.javadoc {
options {
(this as? StandardJavadocDocletOptions)?.apply {
links(
"https://docs.oracle.com/en/java/javase/16/docs/api/",
"https://javadoc.io/doc/com.flowpowered/flow-math/1.0.3/",
"https://javadoc.io/doc/com.google.code.gson/gson/2.8.0/",
"https://docs.oracle.com/javase/8/docs/api/"
)
addStringOption("Xdoclint:none", "-quiet")
addBooleanOption("html5", true)
}
}
}
@ -108,20 +101,6 @@ tasks.processResources {
}
publishing {
repositories {
maven {
name = "bluecolored"
val releasesRepoUrl = "https://repo.bluecolored.de/releases"
val snapshotsRepoUrl = "https://repo.bluecolored.de/snapshots"
url = uri(if (version == lastVersion) releasesRepoUrl else snapshotsRepoUrl)
credentials {
username = project.findProperty("bluecoloredUsername") as String? ?: System.getenv("BLUECOLORED_USERNAME")
password = project.findProperty("bluecoloredPassword") as String? ?: System.getenv("BLUECOLORED_PASSWORD")
}
}
}
publications {
create<MavenPublication>("maven") {
groupId = project.group.toString()

View File

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

View File

@ -35,20 +35,20 @@ import java.util.Optional;
/**
* A storage that is able to hold any "asset"-data for a map. For example images, icons, scripts or json-files.
*/
@SuppressWarnings("unused")
public interface AssetStorage {
/**
* Writes a new asset into this storage, overwriting any existent assets with the same name.<br>
* Use the returned {@link OutputStream} to write the asset-data. The asset will be added to the storage as soon as that stream
* gets closed!<br>
* <br>
* gets closed!
* <p>
* Example:
* <pre>
* try (OutputStream out = assetStorage.writeAsset("image.png")) {
* ImageIO.write(image, "png", out);
* }
* </pre>
* </p>
* @param name The (unique) name for this asset
* @return An {@link OutputStream} that should be used to write the asset and closed once!
* @throws IOException when the underlying storage rises an IOException
@ -57,8 +57,8 @@ public interface AssetStorage {
/**
* Reads an asset from this storage.<br>
* Use the returned {@link InputStream} to read the asset-data.<br>
* <br>
* Use the returned {@link InputStream} to read the asset-data.
* <p>
* Example:
* <pre>
* Optional&lt;InputStream&gt; optIn = assetStorage.readAsset("image.png");
@ -68,6 +68,7 @@ public interface AssetStorage {
* }
* }
* </pre>
* </p>
* @param name The name of the asset that should be read from the storage.
* @return An {@link Optional} with an {@link InputStream} when the asset is found, from which the asset can be read.
* Or an empty optional if there is no asset with this name.

View File

@ -27,8 +27,8 @@ package de.bluecolored.bluemap.api;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import de.bluecolored.bluemap.api.debug.DebugDump;
import de.bluecolored.bluemap.api.plugin.Plugin;
import org.jetbrains.annotations.ApiStatus;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -43,7 +43,6 @@ import java.util.function.Consumer;
* An API to control the running instance of BlueMap.
* <p>This API is thread-save, so you <b>can</b> use it async, off the main-server-thread, to save performance!</p>
*/
@SuppressWarnings({"unused", "UnusedReturnValue"})
public abstract class BlueMapAPI {
@SuppressWarnings("unused")
@ -59,7 +58,6 @@ public abstract class BlueMapAPI {
gitHash = element.get("git-hash").getAsString();
} catch (Exception ex) {
System.err.println("Failed to load version from resources!");
//noinspection CallToPrintStackTrace
ex.printStackTrace();
}
}
@ -73,37 +71,42 @@ public abstract class BlueMapAPI {
private static BlueMapAPI instance;
private static final LinkedHashSet<Consumer<BlueMapAPI>> onEnableConsumers = new LinkedHashSet<>();
private static final LinkedHashSet<Consumer<BlueMapAPI>> onDisableConsumers = new LinkedHashSet<>();
private static final Collection<Consumer<BlueMapAPI>> onEnableConsumers = new HashSet<>(2);
private static final Collection<Consumer<BlueMapAPI>> onDisableConsumers = new HashSet<>(2);
/**
* Getter for the {@link RenderManager}.
* @return the {@link RenderManager}
*/
@DebugDump
public abstract RenderManager getRenderManager();
/**
* Getter for the {@link WebApp}.
* @return the {@link WebApp}
*/
@DebugDump
public abstract WebApp getWebApp();
/**
* Getter for the {@link Plugin}
* @return the {@link Plugin}
*/
@DebugDump
public abstract Plugin getPlugin();
/**
* Getter for all {@link BlueMapMap}s loaded by BlueMap.
* @return an unmodifiable collection of all loaded {@link BlueMapMap}s
*/
@DebugDump
public abstract Collection<BlueMapMap> getMaps();
/**
* Getter for all {@link BlueMapWorld}s loaded by BlueMap.
* @return an unmodifiable collection of all loaded {@link BlueMapWorld}s
*/
@DebugDump
public abstract Collection<BlueMapWorld> getWorlds();
/**
@ -134,12 +137,14 @@ public abstract class BlueMapAPI {
* Getter for the installed BlueMap version
* @return the version-string
*/
@DebugDump
public abstract String getBlueMapVersion();
/**
* Getter for the installed BlueMapAPI version
* @return the version-string
*/
@DebugDump
public String getAPIVersion() {
return VERSION;
}
@ -158,7 +163,6 @@ public abstract class BlueMapAPI {
* <p><b>The {@link Consumer} can be called multiple times if BlueMap disables and enables again, e.g. if BlueMap gets reloaded!</b></p>
* <p><i>(Note: The consumer will likely be called asynchronously, <b>not</b> on the server-thread!)</i></p>
* <p>Remember to unregister the consumer when you no longer need it using {@link #unregisterListener(Consumer)}.</p>
* <p>The {@link Consumer}s are guaranteed to be called in the order they were registered in.</p>
* @param consumer the {@link Consumer}
*/
public static synchronized void onEnable(Consumer<BlueMapAPI> consumer) {
@ -172,7 +176,6 @@ public abstract class BlueMapAPI {
* <p><b>The {@link Consumer} can be called multiple times if BlueMap disables and enables again, e.g. if BlueMap gets reloaded!</b></p>
* <p><i>(Note: The consumer will likely be called asynchronously, <b>not</b> on the server-thread!)</i></p>
* <p>Remember to unregister the consumer when you no longer need it using {@link #unregisterListener(Consumer)}.</p>
* <p>The {@link Consumer}s are guaranteed to be called in the order they were registered in.</p>
* @param consumer the {@link Consumer}
*/
public static synchronized void onDisable(Consumer<BlueMapAPI> consumer) {
@ -194,33 +197,39 @@ public abstract class BlueMapAPI {
* @return <code>true</code> if the instance has been registered, <code>false</code> if there already was an instance registered
* @throws ExecutionException if a listener threw an exception during the registration
*/
@ApiStatus.Internal
protected static synchronized boolean registerInstance(BlueMapAPI instance) throws Exception {
protected static synchronized boolean registerInstance(BlueMapAPI instance) throws ExecutionException {
if (BlueMapAPI.instance != null) return false;
BlueMapAPI.instance = instance;
List<Exception> thrownExceptions = new ArrayList<>(0);
List<Throwable> thrownExceptions = new ArrayList<>(0);
for (Consumer<BlueMapAPI> listener : BlueMapAPI.onEnableConsumers) {
try {
listener.accept(BlueMapAPI.instance);
} catch (Exception ex) {
} catch (Throwable ex) {
thrownExceptions.add(ex);
}
}
return throwAsOne(thrownExceptions);
if (!thrownExceptions.isEmpty()) {
ExecutionException ex = new ExecutionException(thrownExceptions.get(0));
for (int i = 1; i < thrownExceptions.size(); i++) {
ex.addSuppressed(thrownExceptions.get(i));
}
throw ex;
}
return true;
}
/**
* Used by BlueMap to unregister the API and call the listeners properly.
* @param instance the {@link BlueMapAPI} instance
* @return <code>true</code> if the instance was unregistered, <code>false</code> if there was no or another instance registered
* @return <code>true</code> if the instance was unregistered, <code>false</code> if there was no or an other instance registered
* @throws ExecutionException if a listener threw an exception during the un-registration
*/
@ApiStatus.Internal
protected static synchronized boolean unregisterInstance(BlueMapAPI instance) throws Exception {
protected static synchronized boolean unregisterInstance(BlueMapAPI instance) throws ExecutionException {
if (BlueMapAPI.instance != instance) return false;
List<Exception> thrownExceptions = new ArrayList<>(0);
@ -235,12 +244,8 @@ public abstract class BlueMapAPI {
BlueMapAPI.instance = null;
return throwAsOne(thrownExceptions);
}
private static boolean throwAsOne(List<Exception> thrownExceptions) throws Exception {
if (!thrownExceptions.isEmpty()) {
Exception ex = thrownExceptions.get(0);
ExecutionException ex = new ExecutionException(thrownExceptions.get(0));
for (int i = 1; i < thrownExceptions.size(); i++) {
ex.addSuppressed(thrownExceptions.get(i));
}

View File

@ -27,8 +27,8 @@ package de.bluecolored.bluemap.api;
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3d;
import com.flowpowered.math.vector.Vector3i;
import de.bluecolored.bluemap.api.debug.DebugDump;
import de.bluecolored.bluemap.api.markers.MarkerSet;
import org.jetbrains.annotations.ApiStatus;
import java.util.Map;
import java.util.function.Predicate;
@ -37,25 +37,27 @@ import java.util.function.Predicate;
* This class represents a map that is rendered by BlueMap of a specific world ({@link BlueMapWorld}).
* Each map belongs to a map configured in BlueMap's configuration file (in the <code>maps: []</code> list).
*/
@SuppressWarnings("unused")
public interface BlueMapMap {
/**
* Returns this maps id, this is equal to the id configured in bluemap's config for this map.
* @return the id of this map
*/
@DebugDump
String getId();
/**
* Returns this maps display-name, this is equal to the name configured in bluemap's config for this map.
* @return the name of this map
*/
@DebugDump
String getName();
/**
* Getter for the {@link BlueMapWorld} of this map.
* @return the {@link BlueMapWorld} of this map
*/
@DebugDump
BlueMapWorld getWorld();
/**
@ -64,6 +66,7 @@ public interface BlueMapMap {
* is displaying this map. E.g. these assets are also available in server-networks.
* @return the {@link AssetStorage} of this map
*/
@DebugDump
AssetStorage getAssetStorage();
/**
@ -71,12 +74,14 @@ public interface BlueMapMap {
* Changing this map will change the {@link MarkerSet}s and markers displayed on the web-app for this map.
* @return a {@link Map} of {@link MarkerSet}s.
*/
@DebugDump
Map<String, MarkerSet> getMarkerSets();
/**
* Getter for the size of all tiles on this map in blocks.
* @return the tile-size in blocks
*/
@DebugDump
Vector2i getTileSize();
/**
@ -84,6 +89,7 @@ public interface BlueMapMap {
* E.g. an offset of (2|-1) would mean that the tile (0|0) has block (2|0|-1) at it's min-corner.
* @return the tile-offset in blocks
*/
@DebugDump
Vector2i getTileOffset();
/**
@ -93,7 +99,6 @@ public interface BlueMapMap {
* <p>Any previously set filters will get overwritten with the new one. You can get the current filter using {@link #getTileFilter()} and combine them if you wish.</p>
* @param filter The filter that will be used from now on.
*/
@ApiStatus.Experimental
void setTileFilter(Predicate<Vector2i> filter);
/**
@ -110,9 +115,8 @@ public interface BlueMapMap {
boolean isFrozen();
/**
* Returns the currently set TileFilter. The default TileFilter is equivalent to <code>t -&gt; true</code>.
* Returns the currently set TileFilter. The default TileFilter is equivalent to <code>t -> true</code>.
*/
@ApiStatus.Experimental
Predicate<Vector2i> getTileFilter();
/**

View File

@ -24,6 +24,8 @@
*/
package de.bluecolored.bluemap.api;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.nio.file.Path;
import java.util.Collection;
@ -36,21 +38,21 @@ public interface BlueMapWorld {
* Getter for the id of this world.
* @return the id of this world
*/
@DebugDump
String getId();
/**
* Getter for the {@link Path} of this world's save-files.<br>
* (To be exact: the parent-folder of the regions-folder used for rendering)
* Getter for the {@link Path} of this world's save-files (folder). This matches the folder configured in bluemap's config for this map ( <code>world:</code> ).
* @return the save-folder of this world.
* @deprecated Getting the save-folder of a world is no longer supported. As it is not guaranteed that every world has a save-folder.
*/
@Deprecated
@DebugDump
Path getSaveFolder();
/**
* Getter for all {@link BlueMapMap}s for this world
* @return an unmodifiable {@link Collection} of all {@link BlueMapMap}s for this world
*/
@DebugDump
Collection<BlueMapMap> getMaps();
}

View File

@ -110,7 +110,7 @@ public class ContentTypeRegistry {
}
/**
* Registers a new file-suffix =&gt; content-type mapping to this registry.
* Registers a new file-suffix => content-type mapping to this registry.
* @param fileSuffix The type-suffix of a file-name
* @param contentType The content-type string
*/

View File

@ -25,13 +25,14 @@
package de.bluecolored.bluemap.api;
import com.flowpowered.math.vector.Vector2i;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.io.IOException;
import java.util.Collection;
/**
* The {@link RenderManager} is used to schedule tile-renders and process them on a number of different threads.
*/
@SuppressWarnings("unused")
public interface RenderManager {
/**
@ -66,25 +67,29 @@ public interface RenderManager {
* An update-task will be scheduled right after the purge, to get the map up-to-date again.
* @param map the map to be purged
* @return true if a new task has been scheduled, false if not (usually because there is already an update-task for this map scheduled)
* @throws IOException if an IOException occurs while trying to create the task.
*/
boolean scheduleMapPurgeTask(BlueMapMap map);
boolean scheduleMapPurgeTask(BlueMapMap map) throws IOException;
/**
* Getter for the current size of the render-queue.
* @return the current size of the render-queue
*/
@DebugDump
int renderQueueSize();
/**
* Getter for the current count of render threads.
* @return the count of render threads
*/
@DebugDump
int renderThreadCount();
/**
* Whether this {@link RenderManager} is currently running or stopped.
* @return <code>true</code> if this renderer is running
*/
@DebugDump
boolean isRunning();
/**

View File

@ -24,7 +24,7 @@
*/
package de.bluecolored.bluemap.api;
import org.jetbrains.annotations.ApiStatus;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.awt.image.BufferedImage;
import java.io.IOException;
@ -33,13 +33,13 @@ import java.util.Map;
import java.util.UUID;
import java.util.function.Consumer;
@SuppressWarnings("unused")
public interface WebApp {
/**
* Getter for the configured web-root folder
* @return The {@link Path} of the web-root folder
*/
@DebugDump
Path getWebRoot();
/**
@ -47,7 +47,6 @@ public interface WebApp {
* @param player the UUID of the player
* @param visible true if the player-marker should be visible, false if it should be hidden
*/
@ApiStatus.Experimental
void setPlayerVisibility(UUID player, boolean visible);
/**
@ -55,7 +54,6 @@ public interface WebApp {
* @see #setPlayerVisibility(UUID, boolean)
* @param player the UUID of the player
*/
@ApiStatus.Experimental
boolean getPlayerVisibility(UUID player);
/**
@ -63,14 +61,15 @@ public interface WebApp {
* This method should only be used inside the {@link Consumer} that got registered <i>(before bluemap loaded,
* pre server-start!)</i> to {@link BlueMapAPI#onEnable(Consumer)}.<br>
* Invoking this method at any other time is not supported.<br>
* Style-registrations are <b>not persistent</b>, register your style each time bluemap enables!<br>
* <br>
* Style-registrations are <b>not persistent</b>, register your style each time bluemap enables!
* <p>
* Example:
* <pre>
* BlueMapAPI.onEnable(api -&gt; {
* BlueMapAPI.onEnable(api -> {
* api.getWebApp().registerStyle("js/my-custom-style.css");
* });
* </pre>
* </p>
* @param url The (relative) URL that links to the style.css file. The {@link #getWebRoot()}-method can be used to
* create the custom file in the correct location and make it available to the web-app.
*/
@ -81,14 +80,15 @@ public interface WebApp {
* This method should only be used inside the {@link Consumer} that got registered <i>(before bluemap loaded,
* pre server-start!)</i> to {@link BlueMapAPI#onEnable(Consumer)}.<br>
* Invoking this method at any other time is not supported.<br>
* Script-registrations are <b>not persistent</b>, register your script each time bluemap enables!<br>
* <br>
* Script-registrations are <b>not persistent</b>, register your script each time bluemap enables!
* <p>
* Example:
* <pre>
* BlueMapAPI.onEnable(api -&gt; {
* BlueMapAPI.onEnable(api -> {
* api.getWebApp().registerScript("js/my-custom-script.js");
* });
* </pre>
* </p>
* @param url The (relative) URL that links to the script.js file. The {@link #getWebRoot()}-method can be used to
* create the custom file in the correct location and make it available to the web-app.
*/

View File

@ -30,7 +30,8 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @deprecated not implemented, unused
* Marks a class, field or method to be included in detail in a possible state-dump.
* E.g. triggered by <code>/bluemap debug dump</code>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({
@ -38,7 +39,6 @@ import java.lang.annotation.Target;
ElementType.FIELD,
ElementType.TYPE
})
@Deprecated(forRemoval = true)
public @interface DebugDump {
String value() default "";

View File

@ -49,9 +49,8 @@ public final class MarkerGson {
.setLenient()
.create();
private MarkerGson() {
throw new UnsupportedOperationException("Utility class");
}
/* This class can not be instantiated. */
private MarkerGson() {}
public static GsonBuilder addAdapters(GsonBuilder builder) {
return builder
@ -236,8 +235,8 @@ public final class MarkerGson {
}
out.beginObject();
out.name("x"); writeRounded(out, value.getX());
out.name(useZ ? "z" : "y"); writeRounded(out, value.getY());
out.name("x"); out.value(value.getX());
out.name(useZ ? "z" : "y"); out.value(value.getY());
out.endObject();
}
@ -263,13 +262,6 @@ public final class MarkerGson {
return new Vector2d(x, y);
}
private void writeRounded(JsonWriter json, double value) throws IOException {
// rounding and remove ".0" to save string space
double d = Math.round(value * 10000d) / 10000d;
if (d == (long) d) json.value((long) d);
else json.value(d);
}
}
static class Vector3dAdapter extends TypeAdapter<Vector3d> {
@ -282,9 +274,9 @@ public final class MarkerGson {
}
out.beginObject();
out.name("x"); writeRounded(out, value.getX());
out.name("y"); writeRounded(out, value.getY());
out.name("z"); writeRounded(out, value.getZ());
out.name("x"); out.value(value.getX());
out.name("y"); out.value(value.getY());
out.name("z"); out.value(value.getZ());
out.endObject();
}
@ -310,13 +302,6 @@ public final class MarkerGson {
return new Vector3d(x, y, z);
}
private void writeRounded(JsonWriter json, double value) throws IOException {
// rounding and remove ".0" to save string space
double d = Math.round(value * 10000d) / 10000d;
if (d == (long) d) json.value((long) d);
else json.value(d);
}
}
static class Vector2iAdapter extends TypeAdapter<Vector2i> {

View File

@ -25,6 +25,7 @@
package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
/**
* @see HtmlMarker
@ -33,6 +34,7 @@ import com.flowpowered.math.vector.Vector3d;
* @see ExtrudeMarker
* @see LineMarker
*/
@DebugDump
public abstract class DistanceRangedMarker extends Marker {
private double minDistance, maxDistance;

View File

@ -26,20 +26,17 @@ package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector2d;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import de.bluecolored.bluemap.api.math.Color;
import de.bluecolored.bluemap.api.math.Shape;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;
@SuppressWarnings("FieldMayBeFinal")
@DebugDump
public class ExtrudeMarker extends ObjectMarker {
private static final Shape DEFAULT_SHAPE = Shape.createRect(0, 0, 1, 1);
private Shape shape;
private Collection<Shape> holes = new ArrayList<>();
private float shapeMinY, shapeMaxY;
private boolean depthTest = true;
private int lineWidth = 2;
@ -141,15 +138,6 @@ public class ExtrudeMarker extends ObjectMarker {
this.shapeMaxY = maxY;
}
/**
* Getter for the <b>mutable</b> collection of holes in this {@link ExtrudeMarker}.
* <p>Any shape in this collection will be a hole in the main {@link Shape} of this marker</p>
* @return A <b>mutable</b> collection of hole-shapes
*/
public Collection<Shape> getHoles() {
return holes;
}
/**
* Sets the position of this {@link ExtrudeMarker} to the center of the {@link Shape} (it's bounding box).
* <p><i>(Invoke this after changing the {@link Shape} to make sure the markers position gets updated as well)</i></p>
@ -284,7 +272,6 @@ public class ExtrudeMarker extends ObjectMarker {
Shape shape;
float shapeMinY, shapeMaxY;
Collection<Shape> holes = new ArrayList<>();
Boolean depthTest;
Integer lineWidth;
Color lineColor;
@ -307,25 +294,6 @@ public class ExtrudeMarker extends ObjectMarker {
return this;
}
/**
* <b>Adds</b> some hole-{@link Shape}s.
* @param holes the additional holes
* @return this builder for chaining
*/
public Builder holes(Shape... holes) {
this.holes.addAll(Arrays.asList(holes));
return this;
}
/**
* Removes all hole-shapes from this Builder.
* @return this builder for chaining
*/
public Builder clearHoles() {
this.holes.clear();
return this;
}
/**
* Sets the position of the {@link ExtrudeMarker} to the center of the {@link Shape} (it's bounding box).
* @return this builder for chaining
@ -393,7 +361,6 @@ public class ExtrudeMarker extends ObjectMarker {
shapeMinY,
shapeMaxY
);
marker.getHoles().addAll(holes);
if (depthTest != null) marker.setDepthTestEnabled(depthTest);
if (lineWidth != null) marker.setLineWidth(lineWidth);
if (lineColor != null) marker.setLineColor(lineColor);

View File

@ -27,6 +27,7 @@ package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.util.*;
@ -34,6 +35,7 @@ import java.util.*;
* A marker that is a html-element placed somewhere on the map.
*/
@SuppressWarnings("FieldMayBeFinal")
@DebugDump
public class HtmlMarker extends DistanceRangedMarker implements ElementMarker {
private Set<String> classes = new HashSet<>();

View File

@ -25,11 +25,13 @@
package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import de.bluecolored.bluemap.api.math.Color;
import de.bluecolored.bluemap.api.math.Line;
import java.util.Objects;
@DebugDump
public class LineMarker extends ObjectMarker {
private static final Line DEFAULT_LINE = new Line(Vector3d.ZERO, Vector3d.ONE);

View File

@ -25,6 +25,7 @@
package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.util.Objects;
@ -37,20 +38,17 @@ import java.util.Objects;
* @see ExtrudeMarker
* @see LineMarker
*/
@DebugDump
public abstract class Marker {
private final String type;
private String label;
private Vector3d position;
private int sorting;
private boolean listed;
public Marker(String type, String label, Vector3d position) {
this.type = Objects.requireNonNull(type, "type cannot be null");
this.label = Objects.requireNonNull(label, "label cannot be null");
this.position = Objects.requireNonNull(position, "position cannot be null");
this.sorting = 0;
this.listed = true;
}
/**
@ -109,46 +107,6 @@ public abstract class Marker {
setPosition(new Vector3d(x, y, z));
}
/**
* Returns the sorting-value that will be used by the webapp to sort the markers ("default"-sorting).<br>
* A lower value makes the marker sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple markers have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @return this markers sorting-value
*/
public int getSorting() {
return sorting;
}
/**
* Sets the sorting-value that will be used by the webapp to sort the markers ("default"-sorting).<br>
* A lower value makes the marker sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple markers have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @param sorting the new sorting-value for this marker
*/
public void setSorting(int sorting) {
this.sorting = sorting;
}
/**
* This value defines whether the marker will be listed (true) in markers and lists by the webapp (additionally to being
* displayed on the map) or not (false).
* @return whether the marker will be listed or not
*/
public boolean isListed() {
return listed;
}
/**
* Defines whether the marker will be listed (true) in markers and lists by the webapp (additionally to being
* displayed on the map) or not (false).
* @param listed whether the marker will be listed or not
*/
public void setListed(boolean listed) {
this.listed = listed;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@ -173,8 +131,6 @@ public abstract class Marker {
String label;
Vector3d position;
Integer sorting;
Boolean listed;
/**
* Sets the label of the {@link Marker}.
@ -208,28 +164,6 @@ public abstract class Marker {
return position(new Vector3d(x, y, z));
}
/**
* Sets the sorting-value that will be used by the webapp to sort the markers ("default"-sorting).<br>
* A lower value makes the marker sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple markers have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @param sorting the new sorting-value for this marker
*/
public B sorting(Integer sorting) {
this.sorting = sorting;
return self();
}
/**
* Defines whether the marker will be listed (true) in markers and lists by the webapp (additionally to being
* displayed on the map) or not (false).
* @param listed whether the marker will be listed or not
*/
public B listed(Boolean listed) {
this.listed = listed;
return self();
}
/**
* Creates a new {@link Marker} with the current builder-settings
* @return The new {@link Marker}-instance
@ -239,8 +173,6 @@ public abstract class Marker {
T build(T marker) {
if (label != null) marker.setLabel(label);
if (position != null) marker.setPosition(position);
if (sorting != null) marker.setSorting(sorting);
if (listed != null) marker.setListed(listed);
return marker;
}

View File

@ -24,6 +24,8 @@
*/
package de.bluecolored.bluemap.api.markers;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
@ -31,11 +33,11 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* A set of {@link Marker}s that are displayed on the maps in the web-app.
*/
@DebugDump
public class MarkerSet {
private String label;
private boolean toggleable, defaultHidden;
private int sorting;
private final ConcurrentHashMap<String, Marker> markers;
/**
@ -54,7 +56,10 @@ public class MarkerSet {
* @see #setLabel(String)
*/
public MarkerSet(String label) {
this(label, true, false);
this.label = Objects.requireNonNull(label);
this.toggleable = true;
this.defaultHidden = false;
this.markers = new ConcurrentHashMap<>();
}
/**
@ -72,7 +77,6 @@ public class MarkerSet {
this.label = Objects.requireNonNull(label);
this.toggleable = toggleable;
this.defaultHidden = defaultHidden;
this.sorting = 0;
this.markers = new ConcurrentHashMap<>();
}
@ -145,28 +149,6 @@ public class MarkerSet {
this.defaultHidden = defaultHidden;
}
/**
* Returns the sorting-value that will be used by the webapp to sort the marker-sets.<br>
* A lower value makes the marker-set sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple marker-sets have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @return This marker-sets sorting-value
*/
public int getSorting() {
return sorting;
}
/**
* Sets the sorting-value that will be used by the webapp to sort the marker-sets ("default"-sorting).<br>
* A lower value makes the marker-set sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple marker-sets have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @param sorting the new sorting-value for this marker-set
*/
public void setSorting(int sorting) {
this.sorting = sorting;
}
/**
* Getter for a (modifiable) {@link Map} of all {@link Marker}s in this {@link MarkerSet}.
* The keys of the map are the id's of the {@link Marker}s.
@ -238,7 +220,6 @@ public class MarkerSet {
private String label;
private Boolean toggleable, defaultHidden;
private Integer sorting;
/**
* Sets the label of the {@link MarkerSet}.
@ -281,18 +262,6 @@ public class MarkerSet {
return this;
}
/**
* Sets the sorting-value that will be used by the webapp to sort the marker-sets ("default"-sorting).<br>
* A lower value makes the marker-set sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple marker-sets have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @param sorting the new sorting-value for this marker-set
*/
public Builder sorting(Integer sorting) {
this.sorting = sorting;
return this;
}
/**
* Creates a new {@link MarkerSet} with the current builder-settings.<br>
* The minimum required settings to build this marker-set are:
@ -307,7 +276,6 @@ public class MarkerSet {
);
if (toggleable != null) markerSet.setToggleable(toggleable);
if (defaultHidden != null) markerSet.setDefaultHidden(defaultHidden);
if (sorting != null) markerSet.setSorting(sorting);
return markerSet;
}

View File

@ -25,6 +25,7 @@
package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
@ -35,6 +36,7 @@ import java.util.Optional;
* @see ExtrudeMarker
* @see LineMarker
*/
@DebugDump
public abstract class ObjectMarker extends DistanceRangedMarker implements DetailMarker {
private String detail;

View File

@ -27,10 +27,12 @@ package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.BlueMapMap;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.util.*;
@SuppressWarnings("FieldMayBeFinal")
@DebugDump
public class POIMarker extends DistanceRangedMarker implements DetailMarker, ElementMarker {
private Set<String> classes = new HashSet<>();

View File

@ -27,20 +27,17 @@ package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector2d;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import de.bluecolored.bluemap.api.math.Color;
import de.bluecolored.bluemap.api.math.Shape;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;
@SuppressWarnings("FieldMayBeFinal")
@DebugDump
public class ShapeMarker extends ObjectMarker {
private static final Shape DEFAULT_SHAPE = Shape.createRect(0, 0, 1, 1);
private Shape shape;
private Collection<Shape> holes = new ArrayList<>();
private float shapeY;
private boolean depthTest = true;
private int lineWidth = 2;
@ -52,7 +49,7 @@ public class ShapeMarker extends ObjectMarker {
*/
@SuppressWarnings("unused")
private ShapeMarker() {
this("", DEFAULT_SHAPE, 0);
this("shape", DEFAULT_SHAPE, 0);
}
/**
@ -122,15 +119,6 @@ public class ShapeMarker extends ObjectMarker {
this.shapeY = y;
}
/**
* Getter for the <b>mutable</b> collection of holes in this {@link ShapeMarker}.
* <p>Any shape in this collection will be a hole in the main {@link Shape} of this marker</p>
* @return A <b>mutable</b> collection of hole-shapes
*/
public Collection<Shape> getHoles() {
return holes;
}
/**
* Sets the position of this {@link ShapeMarker} to the center of the {@link Shape} (it's bounding box).
* <p><i>(Invoke this after changing the {@link Shape} to make sure the markers position gets updated as well)</i></p>
@ -262,7 +250,6 @@ public class ShapeMarker extends ObjectMarker {
Shape shape;
float shapeY;
Collection<Shape> holes = new ArrayList<>();
Boolean depthTest;
Integer lineWidth;
Color lineColor;
@ -282,25 +269,6 @@ public class ShapeMarker extends ObjectMarker {
return this;
}
/**
* <b>Adds</b> some hole-{@link Shape}s.
* @param holes the additional holes
* @return this builder for chaining
*/
public Builder holes(Shape... holes) {
this.holes.addAll(Arrays.asList(holes));
return this;
}
/**
* Removes all hole-shapes from this Builder.
* @return this builder for chaining
*/
public Builder clearHoles() {
this.holes.clear();
return this;
}
/**
* Sets the position of the {@link ShapeMarker} to the center of the {@link Shape} (it's bounding box).
* @return this builder for chaining
@ -366,7 +334,6 @@ public class ShapeMarker extends ObjectMarker {
checkNotNull(shape, "shape"),
shapeY
);
marker.getHoles().addAll(holes);
if (depthTest != null) marker.setDepthTestEnabled(depthTest);
if (lineWidth != null) marker.setLineWidth(lineWidth);
if (lineColor != null) marker.setLineColor(lineColor);

View File

@ -24,8 +24,11 @@
*/
package de.bluecolored.bluemap.api.math;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.util.Objects;
@DebugDump
public class Color {
private final int r, g, b;
@ -125,8 +128,7 @@ public class Color {
return a;
}
private static int parseColorString(String value) {
String val = value;
private static int parseColorString(String val) {
if (val.charAt(0) == '#') {
val = val.substring(1);
if (val.length() == 3) val = val + "f";
@ -134,7 +136,7 @@ public class Color {
val.charAt(0) + val.charAt(0) + val.charAt(1) + val.charAt(1) +
val.charAt(2) + val.charAt(2) + val.charAt(3) + val.charAt(3);
if (val.length() == 6) val = val + "ff";
if (val.length() != 8) throw new NumberFormatException("Invalid color format: '" + value + "'!");
if (val.length() != 8) throw new NumberFormatException("Invalid color format!");
val = val.substring(6, 8) + val.substring(0, 6); // move alpha to front
return Integer.parseUnsignedInt(val, 16);
}
@ -164,13 +166,4 @@ public class Color {
return result;
}
@Override
public String toString() {
return "Color{" +
"r=" + r +
", g=" + g +
", b=" + b +
", a=" + a +
'}';
}
}

View File

@ -25,6 +25,7 @@
package de.bluecolored.bluemap.api.math;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@ -35,6 +36,7 @@ import java.util.List;
/**
* A line consisting of 2 or more {@link Vector3d}-points.
*/
@DebugDump
public class Line {
private final Vector3d[] points;
@ -158,16 +160,6 @@ public class Line {
return this;
}
/**
* Adds multiple points to the end of line.
* @param points the points to be added.
* @return this builder for chaining
*/
public Builder addPoints(Collection<Vector3d> points) {
this.points.addAll(points);
return this;
}
/**
* Builds a new {@link Line} with the points set in this builder.<br>
* There need to be at least 2 points to build a {@link Line}.

View File

@ -25,6 +25,7 @@
package de.bluecolored.bluemap.api.math;
import com.flowpowered.math.vector.Vector2d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@ -35,6 +36,7 @@ import java.util.List;
/**
* A shape consisting of 3 or more {@link Vector2d}-points on a plane.
*/
@DebugDump
public class Shape {
private final Vector2d[] points;
@ -246,16 +248,6 @@ public class Shape {
return this;
}
/**
* Adds multiple points to the end of line.
* @param points the points to be added.
* @return this builder for chaining
*/
public Builder addPoints(Collection<Vector2d> points) {
this.points.addAll(points);
return this;
}
/**
* Builds a new {@link Shape} with the points set in this builder.<br>
* There need to be at least 3 points to build a {@link Shape}.

View File

@ -24,13 +24,15 @@
*/
package de.bluecolored.bluemap.api.plugin;
@SuppressWarnings("unused")
import de.bluecolored.bluemap.api.debug.DebugDump;
public interface Plugin {
/**
* Get the {@link SkinProvider} that bluemap is using to fetch player-skins
* @return the {@link SkinProvider} instance bluemap is using
*/
@DebugDump
SkinProvider getSkinProvider();
/**
@ -44,6 +46,7 @@ public interface Plugin {
* for the Player-Markers
* @return The {@link PlayerIconFactory} bluemap uses to convert skins into player-marker icons
*/
@DebugDump
PlayerIconFactory getPlayerMarkerIconFactory();
/**