Skip to content

Commit 59e3e5c

Browse files
committed
Fix return type of start/stop/restart requests
1 parent 41fbe33 commit 59e3e5c

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

src/main/java/com/exaroton/api/request/server/RestartServerRequest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
import com.exaroton.api.APIResponse;
44
import com.exaroton.api.ExarotonClient;
5-
import com.exaroton.api.server.Server;
65
import com.google.gson.Gson;
76
import com.google.gson.reflect.TypeToken;
87
import org.jetbrains.annotations.NotNull;
98

10-
public class RestartServerRequest extends ServerRequest<Server> {
9+
public class RestartServerRequest extends ServerRequest<Void> {
1110

1211
public RestartServerRequest(@NotNull ExarotonClient client, @NotNull Gson gson, @NotNull String id) {
1312
super(client, gson, id);
@@ -19,7 +18,7 @@ protected String getEndpoint() {
1918
}
2019

2120
@Override
22-
protected TypeToken<APIResponse<Server>> getType() {
23-
return new TypeToken<APIResponse<Server>>(){};
21+
protected TypeToken<APIResponse<Void>> getType() {
22+
return new TypeToken<APIResponse<Void>>(){};
2423
}
2524
}

src/main/java/com/exaroton/api/request/server/StartServerRequest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
import com.exaroton.api.APIResponse;
44
import com.exaroton.api.ExarotonClient;
5-
import com.exaroton.api.server.Server;
65
import com.google.gson.Gson;
76
import com.google.gson.reflect.TypeToken;
87
import org.jetbrains.annotations.NotNull;
98

109
import java.net.http.HttpRequest;
1110
import java.util.HashMap;
1211

13-
public class StartServerRequest extends ServerRequest<Server> {
12+
public class StartServerRequest extends ServerRequest<Void> {
1413
private final boolean useOwnCredits;
1514

1615
public StartServerRequest(
@@ -34,8 +33,8 @@ protected String getEndpoint() {
3433
}
3534

3635
@Override
37-
protected TypeToken<APIResponse<Server>> getType() {
38-
return new TypeToken<APIResponse<Server>>(){};
36+
protected TypeToken<APIResponse<Void>> getType() {
37+
return new TypeToken<APIResponse<Void>>(){};
3938
}
4039

4140
@Override

src/main/java/com/exaroton/api/request/server/StopServerRequest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
import com.exaroton.api.APIResponse;
44
import com.exaroton.api.ExarotonClient;
5-
import com.exaroton.api.server.Server;
65
import com.google.gson.Gson;
76
import com.google.gson.reflect.TypeToken;
87
import org.jetbrains.annotations.NotNull;
98

10-
public class StopServerRequest extends ServerRequest<Server> {
9+
public class StopServerRequest extends ServerRequest<Void> {
1110

1211
public StopServerRequest(@NotNull ExarotonClient client, @NotNull Gson gson, @NotNull String id) {
1312
super(client, gson, id);
@@ -19,7 +18,7 @@ protected String getEndpoint() {
1918
}
2019

2120
@Override
22-
protected TypeToken<APIResponse<Server>> getType() {
23-
return new TypeToken<APIResponse<Server>>(){};
21+
protected TypeToken<APIResponse<Void>> getType() {
22+
return new TypeToken<APIResponse<Void>>(){};
2423
}
2524
}

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public CompletableFuture<ServerRAMInfo> setRAM(int ram) throws IOException {
335335
* @return Completable future with an updated server object. This future completes after the request, not once the server has started.
336336
* @throws IOException connection errors
337337
*/
338-
public CompletableFuture<Server> start() throws IOException {
338+
public CompletableFuture<Void> start() throws IOException {
339339
return this.start(false);
340340
}
341341

@@ -346,9 +346,8 @@ public CompletableFuture<Server> start() throws IOException {
346346
* @return Completable future with an updated server object. This future completes after the request, not once the server has started.
347347
* @throws IOException connection errors
348348
*/
349-
public CompletableFuture<Server> start(boolean useOwnCredits) throws IOException {
350-
return client.request(new StartServerRequest(this.client, this.gson, this.id, useOwnCredits))
351-
.thenApply(this::setFromObject);
349+
public CompletableFuture<Void> start(boolean useOwnCredits) throws IOException {
350+
return client.request(new StartServerRequest(this.client, this.gson, this.id, useOwnCredits));
352351
}
353352

354353
/**
@@ -357,9 +356,8 @@ public CompletableFuture<Server> start(boolean useOwnCredits) throws IOException
357356
* @return Completable future with an updated server object. This future completes after the request, not once the server has stopped.
358357
* @throws IOException connection errors
359358
*/
360-
public CompletableFuture<Server> stop() throws IOException {
361-
return client.request(new StopServerRequest(this.client, this.gson, this.id))
362-
.thenApply(this::setFromObject);
359+
public CompletableFuture<Void> stop() throws IOException {
360+
return client.request(new StopServerRequest(this.client, this.gson, this.id));
363361
}
364362

365363
/**
@@ -368,9 +366,8 @@ public CompletableFuture<Server> stop() throws IOException {
368366
* @return Completable future with an updated server object. This future completes after the request, not once the server has restarted.
369367
* @throws IOException connection errors
370368
*/
371-
public CompletableFuture<Server> restart() throws IOException {
372-
return client.request(new RestartServerRequest(this.client, this.gson, this.id))
373-
.thenApply(this::setFromObject);
369+
public CompletableFuture<Void> restart() throws IOException {
370+
return client.request(new RestartServerRequest(this.client, this.gson, this.id));
374371
}
375372

376373
/**

0 commit comments

Comments
 (0)