Skip to content

Commit 4796232

Browse files
committed
fix: event structure
1 parent a6a9b28 commit 4796232

12 files changed

Lines changed: 30 additions & 2784 deletions

api/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55

66
`maven-publish`
77
alias(libs.plugins.openapi.generator)
8+
kotlin("jvm")
89
}
910

1011
java {
@@ -22,6 +23,7 @@ dependencies {
2223
implementation(rootProject.libs.gson.fire)
2324
implementation(rootProject.libs.jakarta.annotation)
2425
implementation(rootProject.libs.javax.annotation)
26+
implementation(kotlin("stdlib-jdk8"))
2527
}
2628

2729
tasks.named<ShadowJar>("shadowJar") {
@@ -60,7 +62,7 @@ sourceSets {
6062

6163
openApiGenerate {
6264
generatorName.set("java")
63-
inputSpec.set("${rootDir}/swagger.yaml")
65+
remoteInputSpec.set("https://controller.platform.simplecloud.app/swagger/doc.json")
6466

6567
outputDir.set("$buildDir/generated")
6668

@@ -184,4 +186,7 @@ tasks.register<Javadoc>("generateJavadocSite") {
184186
addStringOption("Xmaxwarns", "10000")
185187
}
186188
}
189+
}
190+
repositories {
191+
mavenCentral()
187192
}

api/src/main/java/app/simplecloud/api/internal/event/server/ServerDeletedEventImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public Server getServer() {
6363
summary.setNumericalId(runtime.getNumericalId());
6464
summary.setIp(runtime.getIp());
6565
summary.setPort(runtime.getPort());
66+
summary.setState(delegate.getRuntimeInfo().getState().toString());
67+
summary.setPlayerCount(-1); // TODO: implement with real player count by adding it to runtime info
6668
if (!runtime.getServerhostId().isEmpty()) {
6769
summary.setServerhostId(runtime.getServerhostId());
6870
}

api/src/main/java/app/simplecloud/api/internal/event/server/ServerStartedEventImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public Server getServer() {
6363
summary.setNumericalId(runtime.getNumericalId());
6464
summary.setIp(runtime.getIp());
6565
summary.setPort(runtime.getPort());
66+
summary.setState(delegate.getRuntimeInfo().getState().toString());
67+
summary.setPlayerCount(-1); // TODO: implement with real player count by adding it to runtime info
6668
if (!runtime.getServerhostId().isEmpty()) {
6769
summary.setServerhostId(runtime.getServerhostId());
6870
}

api/src/main/java/app/simplecloud/api/internal/event/server/ServerStateChangedEventImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public Server getServer() {
7777
summary.setNumericalId(runtime.getNumericalId());
7878
summary.setIp(runtime.getIp());
7979
summary.setPort(runtime.getPort());
80+
summary.setState(delegate.getRuntimeInfo().getState().toString());
81+
summary.setPlayerCount(-1); // TODO: implement with real player count by adding it to runtime info
8082
if (!runtime.getServerhostId().isEmpty()) {
8183
summary.setServerhostId(runtime.getServerhostId());
8284
}

api/src/main/java/app/simplecloud/api/internal/event/server/ServerStoppedEventImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public Server getServer() {
6464
summary.setNumericalId(runtime.getNumericalId());
6565
summary.setIp(runtime.getIp());
6666
summary.setPort(runtime.getPort());
67+
summary.setState(delegate.getRuntimeInfo().getState().toString());
68+
summary.setPlayerCount(-1); // TODO: implement with real player count by adding it to runtime info
6769
if (!runtime.getServerhostId().isEmpty()) {
6870
summary.setServerhostId(runtime.getServerhostId());
6971
}

api/src/main/java/app/simplecloud/api/internal/event/server/ServerUpdatedEventImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public Server getServer() {
6363
summary.setNumericalId(runtime.getNumericalId());
6464
summary.setIp(runtime.getIp());
6565
summary.setPort(runtime.getPort());
66+
summary.setState(delegate.getRuntimeInfo().getState().toString());
67+
summary.setPlayerCount(-1); // TODO: implement with real player count by adding it to runtime info
6668
if (!runtime.getServerhostId().isEmpty()) {
6769
summary.setServerhostId(runtime.getServerhostId());
6870
}

api/src/main/java/app/simplecloud/api/internal/group/GroupApiImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class GroupApiImpl implements GroupApi {
1717
public GroupApiImpl(CloudApiOptions options) {
1818
this.options = options;
1919
this.serverGroupsApi = new ServerGroupsApi();
20+
this.serverGroupsApi.setCustomBaseUrl(options.getControllerUrl());
2021
}
2122

2223
@Override

api/src/main/java/app/simplecloud/api/internal/server/ServerApiImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class ServerApiImpl implements ServerApi {
3434
public ServerApiImpl(CloudApiOptions options) {
3535
this.options = options;
3636
this.serversApi = new ServersApi();
37+
this.serversApi.setCustomBaseUrl(options.getControllerUrl());
3738
}
3839

3940
@Override

api/src/main/java/app/simplecloud/api/internal/server/ServerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public ServerState getState() {
142142
throw new IllegalStateException("Server state is null");
143143
}
144144
try {
145-
return ServerState.valueOf(stateStr);
145+
return ServerState.parse(stateStr);
146146
} catch (IllegalArgumentException e) {
147147
throw new IllegalStateException("Invalid server state: " + stateStr, e);
148148
}

api/src/main/java/app/simplecloud/api/server/ServerState.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public enum ServerState {
3232
/**
3333
* Server is in the process of shutting down.
3434
*/
35-
STOPPING
35+
STOPPING;
36+
37+
public static ServerState parse(String state) {
38+
return ServerState.valueOf(state.toUpperCase().replace("SERVER_STATE_", ""));
39+
}
40+
3641
}
3742

0 commit comments

Comments
 (0)