Skip to content

Commit ec97711

Browse files
committed
Tidy up
1 parent 8b179fb commit ec97711

File tree

8 files changed

+34
-23
lines changed

8 files changed

+34
-23
lines changed

build.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,12 @@ tasks.javadoc {
8585
options {
8686
(this as? StandardJavadocDocletOptions)?.apply {
8787
links(
88-
"https://docs.oracle.com/javase/8/docs/api/",
88+
"https://docs.oracle.com/en/java/javase/16/docs/api/",
8989
"https://javadoc.io/doc/com.flowpowered/flow-math/1.0.3/",
9090
"https://javadoc.io/doc/com.google.code.gson/gson/2.8.0/",
9191
)
9292
addStringOption("Xdoclint:none", "-quiet")
93-
if (JavaVersion.current().isJava9Compatible)
94-
addBooleanOption("html5", true)
93+
addBooleanOption("html5", true)
9594
}
9695
}
9796
}

src/main/java/de/bluecolored/bluemap/api/AssetStorage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
/**
3636
* A storage that is able to hold any "asset"-data for a map. For example images, icons, scripts or json-files.
3737
*/
38+
@SuppressWarnings("unused")
3839
public interface AssetStorage {
3940

4041
/**

src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.gson.JsonElement;
2929
import com.google.gson.JsonObject;
3030
import de.bluecolored.bluemap.api.plugin.Plugin;
31+
import org.jetbrains.annotations.ApiStatus;
3132

3233
import java.io.InputStream;
3334
import java.io.InputStreamReader;
@@ -42,6 +43,7 @@
4243
* An API to control the running instance of BlueMap.
4344
* <p>This API is thread-save, so you <b>can</b> use it async, off the main-server-thread, to save performance!</p>
4445
*/
46+
@SuppressWarnings({"unused", "UnusedReturnValue"})
4547
public abstract class BlueMapAPI {
4648

4749
@SuppressWarnings("unused")
@@ -57,6 +59,7 @@ public abstract class BlueMapAPI {
5759
gitHash = element.get("git-hash").getAsString();
5860
} catch (Exception ex) {
5961
System.err.println("Failed to load version from resources!");
62+
//noinspection CallToPrintStackTrace
6063
ex.printStackTrace();
6164
}
6265
}
@@ -191,39 +194,33 @@ public static synchronized boolean unregisterListener(Consumer<BlueMapAPI> consu
191194
* @return <code>true</code> if the instance has been registered, <code>false</code> if there already was an instance registered
192195
* @throws ExecutionException if a listener threw an exception during the registration
193196
*/
194-
protected static synchronized boolean registerInstance(BlueMapAPI instance) throws ExecutionException {
197+
@ApiStatus.Internal
198+
protected static synchronized boolean registerInstance(BlueMapAPI instance) throws Exception {
195199
if (BlueMapAPI.instance != null) return false;
196200

197201
BlueMapAPI.instance = instance;
198202

199-
List<Throwable> thrownExceptions = new ArrayList<>(0);
203+
List<Exception> thrownExceptions = new ArrayList<>(0);
200204

201205
for (Consumer<BlueMapAPI> listener : BlueMapAPI.onEnableConsumers) {
202206
try {
203207
listener.accept(BlueMapAPI.instance);
204-
} catch (Throwable ex) {
208+
} catch (Exception ex) {
205209
thrownExceptions.add(ex);
206210
}
207211
}
208212

209-
if (!thrownExceptions.isEmpty()) {
210-
ExecutionException ex = new ExecutionException(thrownExceptions.get(0));
211-
for (int i = 1; i < thrownExceptions.size(); i++) {
212-
ex.addSuppressed(thrownExceptions.get(i));
213-
}
214-
throw ex;
215-
}
216-
217-
return true;
213+
return throwAsOne(thrownExceptions);
218214
}
219215

220216
/**
221217
* Used by BlueMap to unregister the API and call the listeners properly.
222218
* @param instance the {@link BlueMapAPI} instance
223-
* @return <code>true</code> if the instance was unregistered, <code>false</code> if there was no or an other instance registered
219+
* @return <code>true</code> if the instance was unregistered, <code>false</code> if there was no or another instance registered
224220
* @throws ExecutionException if a listener threw an exception during the un-registration
225221
*/
226-
protected static synchronized boolean unregisterInstance(BlueMapAPI instance) throws ExecutionException {
222+
@ApiStatus.Internal
223+
protected static synchronized boolean unregisterInstance(BlueMapAPI instance) throws Exception {
227224
if (BlueMapAPI.instance != instance) return false;
228225

229226
List<Exception> thrownExceptions = new ArrayList<>(0);
@@ -238,8 +235,12 @@ protected static synchronized boolean unregisterInstance(BlueMapAPI instance) th
238235

239236
BlueMapAPI.instance = null;
240237

238+
return throwAsOne(thrownExceptions);
239+
}
240+
241+
private static boolean throwAsOne(List<Exception> thrownExceptions) throws Exception {
241242
if (!thrownExceptions.isEmpty()) {
242-
ExecutionException ex = new ExecutionException(thrownExceptions.get(0));
243+
Exception ex = thrownExceptions.get(0);
243244
for (int i = 1; i < thrownExceptions.size(); i++) {
244245
ex.addSuppressed(thrownExceptions.get(i));
245246
}

src/main/java/de/bluecolored/bluemap/api/BlueMapMap.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.flowpowered.math.vector.Vector3d;
2929
import com.flowpowered.math.vector.Vector3i;
3030
import de.bluecolored.bluemap.api.markers.MarkerSet;
31+
import org.jetbrains.annotations.ApiStatus;
3132

3233
import java.util.Map;
3334
import java.util.function.Predicate;
@@ -36,6 +37,7 @@
3637
* This class represents a map that is rendered by BlueMap of a specific world ({@link BlueMapWorld}).
3738
* Each map belongs to a map configured in BlueMap's configuration file (in the <code>maps: []</code> list).
3839
*/
40+
@SuppressWarnings("unused")
3941
public interface BlueMapMap {
4042

4143
/**
@@ -91,6 +93,7 @@ public interface BlueMapMap {
9193
* <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>
9294
* @param filter The filter that will be used from now on.
9395
*/
96+
@ApiStatus.Experimental
9497
void setTileFilter(Predicate<Vector2i> filter);
9598

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

114118
/**

src/main/java/de/bluecolored/bluemap/api/RenderManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626

2727
import com.flowpowered.math.vector.Vector2i;
2828

29-
import java.io.IOException;
3029
import java.util.Collection;
3130

3231
/**
3332
* The {@link RenderManager} is used to schedule tile-renders and process them on a number of different threads.
3433
*/
34+
@SuppressWarnings("unused")
3535
public interface RenderManager {
3636

3737
/**
@@ -66,9 +66,8 @@ default boolean scheduleMapUpdateTask(BlueMapMap map) {
6666
* An update-task will be scheduled right after the purge, to get the map up-to-date again.
6767
* @param map the map to be purged
6868
* @return true if a new task has been scheduled, false if not (usually because there is already an update-task for this map scheduled)
69-
* @throws IOException if an IOException occurs while trying to create the task.
7069
*/
71-
boolean scheduleMapPurgeTask(BlueMapMap map) throws IOException;
70+
boolean scheduleMapPurgeTask(BlueMapMap map);
7271

7372
/**
7473
* Getter for the current size of the render-queue.

src/main/java/de/bluecolored/bluemap/api/WebApp.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@
2424
*/
2525
package de.bluecolored.bluemap.api;
2626

27+
import org.jetbrains.annotations.ApiStatus;
28+
2729
import java.awt.image.BufferedImage;
2830
import java.io.IOException;
2931
import java.nio.file.Path;
3032
import java.util.Map;
3133
import java.util.UUID;
3234
import java.util.function.Consumer;
3335

36+
@SuppressWarnings("unused")
3437
public interface WebApp {
3538

3639
/**
@@ -44,13 +47,15 @@ public interface WebApp {
4447
* @param player the UUID of the player
4548
* @param visible true if the player-marker should be visible, false if it should be hidden
4649
*/
50+
@ApiStatus.Experimental
4751
void setPlayerVisibility(UUID player, boolean visible);
4852

4953
/**
5054
* Returns <code>true</code> if the given player is currently visible on the web-app.
5155
* @see #setPlayerVisibility(UUID, boolean)
5256
* @param player the UUID of the player
5357
*/
58+
@ApiStatus.Experimental
5459
boolean getPlayerVisibility(UUID player);
5560

5661
/**

src/main/java/de/bluecolored/bluemap/api/gson/MarkerGson.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ public final class MarkerGson {
4949
.setLenient()
5050
.create();
5151

52-
/* This class can not be instantiated. */
53-
private MarkerGson() {}
52+
private MarkerGson() {
53+
throw new UnsupportedOperationException("Utility class");
54+
}
5455

5556
public static GsonBuilder addAdapters(GsonBuilder builder) {
5657
return builder

src/main/java/de/bluecolored/bluemap/api/plugin/Plugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package de.bluecolored.bluemap.api.plugin;
2626

27+
@SuppressWarnings("unused")
2728
public interface Plugin {
2829

2930
/**

0 commit comments

Comments
 (0)