Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed May 20, 2024
1 parent 8b179fb commit ec97711
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 23 deletions.
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/de/bluecolored/bluemap/api/AssetStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
/**
* 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 {

/**
Expand Down
31 changes: 16 additions & 15 deletions src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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;
Expand All @@ -42,6 +43,7 @@
* 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")
Expand All @@ -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();
}
}
Expand Down Expand Up @@ -191,39 +194,33 @@ public static synchronized boolean unregisterListener(Consumer<BlueMapAPI> consu
* @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
*/
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<Throwable> thrownExceptions = new ArrayList<>(0);
List<Exception> thrownExceptions = new ArrayList<>(0);

for (Consumer<BlueMapAPI> 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 <code>true</code> if the instance was unregistered, <code>false</code> if there was no or an other instance registered
* @return <code>true</code> if the instance was unregistered, <code>false</code> 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<Exception> thrownExceptions = new ArrayList<>(0);
Expand All @@ -238,8 +235,12 @@ protected static synchronized boolean unregisterInstance(BlueMapAPI instance) th

BlueMapAPI.instance = null;

return throwAsOne(thrownExceptions);
}

private static boolean throwAsOne(List<Exception> 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));
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/de/bluecolored/bluemap/api/BlueMapMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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;
Expand All @@ -36,6 +37,7 @@
* 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 {

/**
Expand Down Expand Up @@ -91,6 +93,7 @@ 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);

/**
Expand All @@ -109,6 +112,7 @@ public interface BlueMapMap {
/**
* Returns the currently set TileFilter. The default TileFilter is equivalent to <code>t -&gt; true</code>.
*/
@ApiStatus.Experimental
Predicate<Vector2i> getTileFilter();

/**
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/de/bluecolored/bluemap/api/RenderManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

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 {

/**
Expand Down Expand Up @@ -66,9 +66,8 @@ default boolean scheduleMapUpdateTask(BlueMapMap map) {
* 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.
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/de/bluecolored/bluemap/api/WebApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
*/
package de.bluecolored.bluemap.api;

import org.jetbrains.annotations.ApiStatus;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Map;
import java.util.UUID;
import java.util.function.Consumer;

@SuppressWarnings("unused")
public interface WebApp {

/**
Expand All @@ -44,13 +47,15 @@ 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);

/**
* Returns <code>true</code> if the given player is currently visible on the web-app.
* @see #setPlayerVisibility(UUID, boolean)
* @param player the UUID of the player
*/
@ApiStatus.Experimental
boolean getPlayerVisibility(UUID player);

/**
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/de/bluecolored/bluemap/api/gson/MarkerGson.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package de.bluecolored.bluemap.api.plugin;

@SuppressWarnings("unused")
public interface Plugin {

/**
Expand Down

0 comments on commit ec97711

Please sign in to comment.