Skip to content

Commit 96ac769

Browse files
committed
Make setFromObject private or internal
1 parent a17b7ea commit 96ac769

File tree

3 files changed

+8
-21
lines changed

3 files changed

+8
-21
lines changed

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ public CompletableFuture<Server> get() throws IOException {
279279
return client.request(new GetServerRequest(this.client, this.gson, this.id))
280280
.thenApply(data -> {
281281
this.fetched = true;
282-
this.setFromObject(data);
283-
return this;
282+
return this.setFromObject(data);
284283
});
285284
}
286285

@@ -345,10 +344,7 @@ public CompletableFuture<Server> start() throws IOException {
345344
*/
346345
public CompletableFuture<Server> start(boolean useOwnCredits) throws IOException {
347346
return client.request(new StartServerRequest(this.client, this.gson, this.id, useOwnCredits))
348-
.thenApply(data -> {;
349-
this.setFromObject(data);
350-
return this;
351-
});
347+
.thenApply(this::setFromObject);
352348
}
353349

354350
/**
@@ -359,10 +355,7 @@ public CompletableFuture<Server> start(boolean useOwnCredits) throws IOException
359355
*/
360356
public CompletableFuture<Server> stop() throws IOException {
361357
return client.request(new StopServerRequest(this.client, this.gson, this.id))
362-
.thenApply(server -> {
363-
this.setFromObject(server);
364-
return this;
365-
});
358+
.thenApply(this::setFromObject);
366359
}
367360

368361
/**
@@ -373,10 +366,7 @@ public CompletableFuture<Server> stop() throws IOException {
373366
*/
374367
public CompletableFuture<Server> restart() throws IOException {
375368
return client.request(new RestartServerRequest(this.client, this.gson, this.id))
376-
.thenApply(server -> {
377-
this.setFromObject(server);
378-
return this;
379-
});
369+
.thenApply(this::setFromObject);
380370
}
381371

382372
/**
@@ -429,6 +419,7 @@ public PlayerList getPlayerList(String name) {
429419
* @param server server fetched from the API
430420
* @return updated server object
431421
*/
422+
@ApiStatus.Internal
432423
public Server setFromObject(Server server) {
433424
this.id = server.getId();
434425
this.name = server.getName();

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ public ServerFile(
6767
*/
6868
public CompletableFuture<ServerFile> get() throws IOException {
6969
return client.request(new GetFileInfoRequest(this.client, this.gson, this.server.getId(), this.path))
70-
.thenApply(data -> {
71-
this.setFromObject(data);
72-
return this;
73-
});
70+
.thenApply(this::setFromObject);
7471
}
7572

7673
/**
@@ -269,7 +266,7 @@ public void setPath(String path) {
269266
* @param file file fetched from the API
270267
* @return updated file object
271268
*/
272-
public ServerFile setFromObject(ServerFile file) {
269+
private ServerFile setFromObject(ServerFile file) {
273270
if (file.path != null) {
274271
this.setPath(path);
275272
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ public void handleData(String type, String message) {
8989
break;
9090

9191
case "status":
92-
Server oldServer = new Server(server.getClient(), gson, server.getId())
93-
.setFromObject(server);
92+
Server oldServer = new Server(server.getClient(), gson, server.getId()).setFromObject(server);
9493
this.server.setFromObject(gson.fromJson(message, ServerStatusStreamData.class).getData());
9594

9695
//start/stop streams based on status

0 commit comments

Comments
 (0)