diff --git a/build.gradle.kts b/build.gradle.kts index 866286e..9c4cf50 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -85,13 +85,12 @@ tasks.javadoc { options { (this as? StandardJavadocDocletOptions)?.apply { links( - "https://docs.oracle.com/javase/8/docs/api/", + "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/", ) addStringOption("Xdoclint:none", "-quiet") - if (JavaVersion.current().isJava9Compatible) - addBooleanOption("html5", true) + addBooleanOption("html5", true) } } } diff --git a/src/main/java/de/bluecolored/bluemap/api/AssetStorage.java b/src/main/java/de/bluecolored/bluemap/api/AssetStorage.java index a5ba4a4..fe71137 100644 --- a/src/main/java/de/bluecolored/bluemap/api/AssetStorage.java +++ b/src/main/java/de/bluecolored/bluemap/api/AssetStorage.java @@ -35,6 +35,7 @@ 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 { /** diff --git a/src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java b/src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java index 3fdffc3..b90b223 100644 --- a/src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java +++ b/src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import de.bluecolored.bluemap.api.plugin.Plugin; +import org.jetbrains.annotations.ApiStatus; import java.io.InputStream; import java.io.InputStreamReader; @@ -42,6 +43,7 @@ import java.util.function.Consumer; * An API to control the running instance of BlueMap. *

This API is thread-save, so you can use it async, off the main-server-thread, to save performance!

*/ +@SuppressWarnings({"unused", "UnusedReturnValue"}) public abstract class BlueMapAPI { @SuppressWarnings("unused") @@ -57,6 +59,7 @@ 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(); } } @@ -191,39 +194,33 @@ public abstract class BlueMapAPI { * @return true if the instance has been registered, false if there already was an instance registered * @throws ExecutionException if a listener threw an exception during the registration */ - protected static synchronized boolean registerInstance(BlueMapAPI instance) throws ExecutionException { + @ApiStatus.Internal + protected static synchronized boolean registerInstance(BlueMapAPI instance) throws Exception { if (BlueMapAPI.instance != null) return false; BlueMapAPI.instance = instance; - List thrownExceptions = new ArrayList<>(0); + List thrownExceptions = new ArrayList<>(0); for (Consumer listener : BlueMapAPI.onEnableConsumers) { try { listener.accept(BlueMapAPI.instance); - } catch (Throwable ex) { + } catch (Exception ex) { thrownExceptions.add(ex); } } - 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; + return throwAsOne(thrownExceptions); } /** * Used by BlueMap to unregister the API and call the listeners properly. * @param instance the {@link BlueMapAPI} instance - * @return true if the instance was unregistered, false if there was no or an other instance registered + * @return true if the instance was unregistered, false if there was no or another instance registered * @throws ExecutionException if a listener threw an exception during the un-registration */ - protected static synchronized boolean unregisterInstance(BlueMapAPI instance) throws ExecutionException { + @ApiStatus.Internal + protected static synchronized boolean unregisterInstance(BlueMapAPI instance) throws Exception { if (BlueMapAPI.instance != instance) return false; List thrownExceptions = new ArrayList<>(0); @@ -238,8 +235,12 @@ public abstract class BlueMapAPI { BlueMapAPI.instance = null; + return throwAsOne(thrownExceptions); + } + + private static boolean throwAsOne(List thrownExceptions) throws Exception { if (!thrownExceptions.isEmpty()) { - ExecutionException ex = new ExecutionException(thrownExceptions.get(0)); + Exception ex = thrownExceptions.get(0); for (int i = 1; i < thrownExceptions.size(); i++) { ex.addSuppressed(thrownExceptions.get(i)); } diff --git a/src/main/java/de/bluecolored/bluemap/api/BlueMapMap.java b/src/main/java/de/bluecolored/bluemap/api/BlueMapMap.java index 7fbff94..8b22c86 100644 --- a/src/main/java/de/bluecolored/bluemap/api/BlueMapMap.java +++ b/src/main/java/de/bluecolored/bluemap/api/BlueMapMap.java @@ -28,6 +28,7 @@ import com.flowpowered.math.vector.Vector2i; import com.flowpowered.math.vector.Vector3d; import com.flowpowered.math.vector.Vector3i; import de.bluecolored.bluemap.api.markers.MarkerSet; +import org.jetbrains.annotations.ApiStatus; import java.util.Map; import java.util.function.Predicate; @@ -36,6 +37,7 @@ 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 maps: [] list). */ +@SuppressWarnings("unused") public interface BlueMapMap { /** @@ -91,6 +93,7 @@ public interface BlueMapMap { *

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.

* @param filter The filter that will be used from now on. */ + @ApiStatus.Experimental void setTileFilter(Predicate filter); /** @@ -109,6 +112,7 @@ public interface BlueMapMap { /** * Returns the currently set TileFilter. The default TileFilter is equivalent to t -> true. */ + @ApiStatus.Experimental Predicate getTileFilter(); /** diff --git a/src/main/java/de/bluecolored/bluemap/api/RenderManager.java b/src/main/java/de/bluecolored/bluemap/api/RenderManager.java index fb8f6e1..9a0fc6c 100644 --- a/src/main/java/de/bluecolored/bluemap/api/RenderManager.java +++ b/src/main/java/de/bluecolored/bluemap/api/RenderManager.java @@ -26,12 +26,12 @@ package de.bluecolored.bluemap.api; import com.flowpowered.math.vector.Vector2i; -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,9 +66,8 @@ 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) throws IOException; + boolean scheduleMapPurgeTask(BlueMapMap map); /** * Getter for the current size of the render-queue. diff --git a/src/main/java/de/bluecolored/bluemap/api/WebApp.java b/src/main/java/de/bluecolored/bluemap/api/WebApp.java index f0ee1f6..e2ad2b6 100644 --- a/src/main/java/de/bluecolored/bluemap/api/WebApp.java +++ b/src/main/java/de/bluecolored/bluemap/api/WebApp.java @@ -24,6 +24,8 @@ */ package de.bluecolored.bluemap.api; +import org.jetbrains.annotations.ApiStatus; + import java.awt.image.BufferedImage; import java.io.IOException; import java.nio.file.Path; @@ -31,6 +33,7 @@ import java.util.Map; import java.util.UUID; import java.util.function.Consumer; +@SuppressWarnings("unused") public interface WebApp { /** @@ -44,6 +47,7 @@ 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); /** @@ -51,6 +55,7 @@ public interface WebApp { * @see #setPlayerVisibility(UUID, boolean) * @param player the UUID of the player */ + @ApiStatus.Experimental boolean getPlayerVisibility(UUID player); /** diff --git a/src/main/java/de/bluecolored/bluemap/api/gson/MarkerGson.java b/src/main/java/de/bluecolored/bluemap/api/gson/MarkerGson.java index de973a9..d113999 100644 --- a/src/main/java/de/bluecolored/bluemap/api/gson/MarkerGson.java +++ b/src/main/java/de/bluecolored/bluemap/api/gson/MarkerGson.java @@ -49,8 +49,9 @@ public final class MarkerGson { .setLenient() .create(); - /* This class can not be instantiated. */ - private MarkerGson() {} + private MarkerGson() { + throw new UnsupportedOperationException("Utility class"); + } public static GsonBuilder addAdapters(GsonBuilder builder) { return builder diff --git a/src/main/java/de/bluecolored/bluemap/api/plugin/Plugin.java b/src/main/java/de/bluecolored/bluemap/api/plugin/Plugin.java index 05f737f..d73e211 100644 --- a/src/main/java/de/bluecolored/bluemap/api/plugin/Plugin.java +++ b/src/main/java/de/bluecolored/bluemap/api/plugin/Plugin.java @@ -24,6 +24,7 @@ */ package de.bluecolored.bluemap.api.plugin; +@SuppressWarnings("unused") public interface Plugin { /**