Skip to content

Commit 1a84372

Browse files
committed
Some final cleanups
1 parent 31a7344 commit 1a84372

File tree

8 files changed

+14
-35
lines changed

8 files changed

+14
-35
lines changed

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ JSON body you can use `ApiRequest#jsonBodyPublisher(Object)`. This only affects
4242
string or object.
4343

4444
### WebSockets
45-
The `java-websocket` library has been replaced by the built-in Java 11 websocket implementation. Unless you were using
46-
the `WebSocketClient` or `WebSocketManager` classes directly this shouldn't require any changes to your code.
47-
48-
`Server#subscribe` and `Server#unsubscribe` now accept the `StreamName` enum instead of any string
45+
The `java-websocket` library has been replaced by the built-in Java 11 websocket implementation. Websocket connections
46+
are now automatically created when a subscriber is registered and closed when the last subscriber is removed. Manually
47+
closing a connection using `Server#unsubscribe()` is still supported. This method does not throw an exception if there
48+
is no connection to close.
4949

5050
The debug/error handler methods have been removed. Errors and debug messages are now exclusively logged using SLF4J
5151

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.exaroton.api;
22

3+
/**
4+
* Exception thrown by the exaroton API.
5+
*/
36
public class APIException extends Exception {
47
public APIException(String message) {
58
super(message);
69
}
7-
8-
public APIException(String message, Throwable cause) {
9-
super(message, cause);
10-
}
1110
}

src/main/java/com/exaroton/api/BrandColor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.exaroton.api;
22

3+
@SuppressWarnings("unused")
34
public enum BrandColor {
45
DARK(0x0f0f0f),
56
LIGHT(0xffffff),

src/main/java/com/exaroton/api/server/PlayerList.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ public CompletableFuture<List<String>> add(String... entries) throws IOException
7878
* @throws IOException Connection errors
7979
*/
8080
public CompletableFuture<List<String>> add(Collection<String> entries) throws IOException {
81-
if (entries.isEmpty()) {
82-
throw new IllegalArgumentException("Can't add empty list");
83-
}
84-
81+
ParameterValidator.requireNonEmpty(entries, "entries");
8582
return client.request(new AddPlayerListEntriesRequest(this.client, this.gson, this.serverId, this.name, entries));
8683
}
8784

@@ -105,10 +102,7 @@ public CompletableFuture<List<String>> remove(String... entries) throws IOExcept
105102
* @throws IOException Connection errors
106103
*/
107104
public CompletableFuture<List<String>> remove(List<String> entries) throws IOException {
108-
if (entries.isEmpty()) {
109-
throw new IllegalArgumentException("Can't remove empty list");
110-
}
111-
105+
ParameterValidator.requireNonEmpty(entries, "entries");
112106
return client.request(new RemovePlayerListEntriesRequest(this.client, this.gson, this.serverId, this.name, entries));
113107
}
114108
}

src/main/java/com/exaroton/api/server/Server.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,8 @@ public void removeTickSubscriber(@NotNull TickSubscriber subscriber) {
564564

565565
/**
566566
* Unsubscribe from websocket events. This happens automatically when there are no registered subscribers, but you
567-
* might still want to call this method explicitly as a cleanup step.
567+
* might still want to call this method explicitly as a cleanup step. If no connection is active, this method does
568+
* nothing.
568569
*/
569570
public void unsubscribe() {
570571
if (this.webSocket == null) {

src/main/java/com/exaroton/api/server/ServerMOTDInfo.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
package com.exaroton.api.server;
22

3-
import org.jetbrains.annotations.ApiStatus;
4-
3+
@SuppressWarnings("unused")
54
public final class ServerMOTDInfo {
65
/**
76
* Server MOTD
87
*/
9-
private final String motd;
10-
11-
@ApiStatus.Internal
12-
public ServerMOTDInfo(String motd) {
13-
this.motd = motd;
14-
}
8+
private String motd;
159

1610
/**
1711
* @return server MOTD

src/main/java/com/exaroton/api/ws/DebugListener.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/main/java/com/exaroton/api/ws/ErrorListener.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)