Skip to content

Commit 66d63fe

Browse files
committed
refactor: improve server start
1 parent de96444 commit 66d63fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+435
-367
lines changed

api/build.gradle.kts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ dependencies {
2626

2727
tasks.named<ShadowJar>("shadowJar") {
2828
mergeServiceFiles()
29-
29+
3030
val versionPath = project.version.toString().replace(".", "_").replace("-", "_")
31-
31+
3232
relocate("io.nats", "app.simplecloud.api.shaded.v${versionPath}.nats")
3333
relocate("com.google", "app.simplecloud.api.shaded.v${versionPath}.google")
3434
relocate("build.buf", "app.simplecloud.api.shaded.v${versionPath}.buf")
@@ -39,11 +39,11 @@ tasks.named<ShadowJar>("shadowJar") {
3939
relocate("org.intellij", "app.simplecloud.api.shaded.v${versionPath}.intellij")
4040
relocate("org.jetbrains", "app.simplecloud.api.shaded.v${versionPath}.jetbrains")
4141
relocate("kotlin", "app.simplecloud.api.shaded.v${versionPath}.kotlin")
42-
42+
4343
relocate("google", "app.simplecloud.api.shaded.v${versionPath}.google")
4444
relocate("native", "app.simplecloud.api.shaded.v${versionPath}.native")
4545
relocate("core", "app.simplecloud.api.shaded.v${versionPath}.core")
46-
46+
4747
archiveClassifier.set("")
4848
}
4949

@@ -75,11 +75,13 @@ openApiGenerate {
7575
modelPackage.set("app.simplecloud.api.web.models")
7676
packageName.set("app.simplecloud.api.web")
7777

78-
configOptions.set(mapOf(
79-
"library" to "okhttp-gson",
80-
"serializationLibrary" to "gson",
81-
"useJakartaEe" to "true"
82-
))
78+
configOptions.set(
79+
mapOf(
80+
"library" to "okhttp-gson",
81+
"serializationLibrary" to "gson",
82+
"useJakartaEe" to "true"
83+
)
84+
)
8385
}
8486

8587
tasks.compileJava {
@@ -106,7 +108,7 @@ publishing {
106108
artifact(tasks.named<ShadowJar>("shadowJar")) {
107109
classifier = ""
108110
}
109-
111+
110112
artifact(tasks.named<Jar>("javadocJar"))
111113
artifact(tasks.named<Jar>("sourcesJar"))
112114

api/src/main/java/app/simplecloud/api/CloudApi.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77

88
/**
99
* Main entry point for the SimpleCloud API.
10-
*
10+
*
1111
* <p>This interface provides access to manage server groups, individual servers,
1212
* and subscribe to system events. Use the static factory methods to create an instance.
13-
*
13+
*
1414
* <p>Example usage:
1515
* <pre>{@code
1616
* CloudApi api = CloudApi.create(CloudApiOptions.builder()
1717
* .networkId("your-network-id")
1818
* .networkSecret("your-secret")
1919
* .build());
20-
*
20+
*
2121
* // Manage server groups
2222
* api.group().getAllGroups().thenAccept(groups -> {
2323
* groups.forEach(group -> System.out.println(group.getName()));
2424
* });
25-
*
25+
*
2626
* // Query servers
2727
* api.server().getAllServers().thenAccept(servers -> {
2828
* System.out.println("Active servers: " + servers.size());
2929
* });
30-
*
30+
*
3131
* // Subscribe to events
3232
* Subscription sub = api.event().group().onCreated(event -> {
3333
* System.out.println("Group created: " + event.getServerGroupId());
@@ -38,15 +38,15 @@ public interface CloudApi {
3838

3939
/**
4040
* Creates a CloudAPI instance with default options.
41-
*
41+
*
4242
* <p>Default options are loaded from environment variables:
4343
* <ul>
4444
* <li>SIMPLECLOUD_NETWORK_ID (default: "default")</li>
4545
* <li>SIMPLECLOUD_NETWORK_SECRET (default: "")</li>
4646
* <li>SIMPLECLOUD_NATS_URL (default: "nats://localhost:4222")</li>
4747
* <li>SIMPLECLOUD_CONTROLLER_URL (default: "http://localhost:1337")</li>
4848
* </ul>
49-
*
49+
*
5050
* @return a new CloudApi instance
5151
*/
5252
static CloudApi create() {
@@ -55,7 +55,7 @@ static CloudApi create() {
5555

5656
/**
5757
* Creates a CloudAPI instance with custom options.
58-
*
58+
*
5959
* @param options the configuration options for the API client
6060
* @return a new CloudApi instance
6161
*/
@@ -65,28 +65,28 @@ static CloudApi create(CloudApiOptions options) {
6565

6666
/**
6767
* Returns the group management API.
68-
*
68+
*
6969
* <p>Use this to create, read, update, and delete server groups.
70-
*
70+
*
7171
* @return the group API
7272
*/
7373
GroupApi group();
7474

7575
/**
7676
* Returns the server management API.
77-
*
77+
*
7878
* <p>Use this to query running servers, start new instances, and stop servers.
79-
*
79+
*
8080
* @return the server API
8181
*/
8282
ServerApi server();
8383

8484
/**
8585
* Returns the event subscription API.
86-
*
86+
*
8787
* <p>Use this to subscribe to real-time events for groups, servers,
8888
* persistent servers, and blueprints.
89-
*
89+
*
9090
* @return the event API
9191
*/
9292
EventApi event();

api/src/main/java/app/simplecloud/api/blueprint/Blueprint.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,88 +6,88 @@
66

77
/**
88
* Represents a server blueprint configuration.
9-
*
9+
*
1010
* <p>Blueprints are reusable templates that define the base software configuration
1111
* for server instances, including the Minecraft version, server software type,
1212
* runtime environment, and workflow steps to execute during server lifecycle.
1313
*/
1414
public interface Blueprint {
15-
15+
1616
/**
1717
* Returns the unique identifier of this blueprint.
18-
*
18+
*
1919
* @return the blueprint ID
2020
*/
2121
String getBlueprintId();
22-
22+
2323
/**
2424
* Returns the human-readable name of this blueprint.
25-
*
25+
*
2626
* @return the blueprint name
2727
*/
2828
String getName();
29-
29+
3030
/**
3131
* Returns the configurator used to set up this blueprint.
32-
*
32+
*
3333
* @return the configurator name, or null if not set
3434
*/
3535
@Nullable String getConfigurator();
36-
36+
3737
/**
3838
* Returns the Minecraft version this blueprint is configured for.
39-
*
39+
*
4040
* @return the Minecraft version, or null if not applicable
4141
*/
4242
@Nullable String getMinecraftVersion();
43-
43+
4444
/**
4545
* Returns the server software type (e.g., "paper", "spigot", "velocity").
46-
*
46+
*
4747
* @return the server software, or null if not set
4848
*/
4949
@Nullable String getServerSoftware();
50-
50+
5151
/**
5252
* Returns the download URL for the server software.
53-
*
53+
*
5454
* @return the server URL, or null if not set
5555
*/
5656
@Nullable String getServerUrl();
57-
57+
5858
/**
5959
* Returns the specific version of the server software.
60-
*
60+
*
6161
* @return the software version, or null if not set
6262
*/
6363
@Nullable String getSoftwareVersion();
64-
64+
6565
/**
6666
* Returns the runtime configuration for servers using this blueprint.
67-
*
67+
*
6868
* <p>Defines the runtime type (e.g., Java) and associated configuration.
69-
*
69+
*
7070
* @return the runtime config, or null if not set
7171
*/
7272
@Nullable RuntimeConfig getRuntimeConfig();
73-
73+
7474
/**
7575
* Returns the workflow steps to execute during server lifecycle events.
76-
*
76+
*
7777
* @return the list of workflow step IDs, or null if none defined
7878
*/
7979
@Nullable List<String> getWorkflowSteps();
80-
80+
8181
/**
8282
* Returns the timestamp when this blueprint was created (ISO 8601 format).
83-
*
83+
*
8484
* @return the creation timestamp
8585
*/
8686
String getCreatedAt();
87-
87+
8888
/**
8989
* Returns the timestamp when this blueprint was last updated (ISO 8601 format).
90-
*
90+
*
9191
* @return the update timestamp
9292
*/
9393
String getUpdatedAt();

api/src/main/java/app/simplecloud/api/blueprint/RuntimeConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ public void setWith(@Nullable Map<String, Object> with) {
3232
}
3333
}
3434

35+

api/src/main/java/app/simplecloud/api/blueprint/RuntimeType.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,24 @@
44
* Represents the runtime type for server execution.
55
*/
66
public enum RuntimeType {
7-
/** Java runtime environment. */
7+
/**
8+
* Java runtime environment.
9+
*/
810
JAVA,
9-
10-
/** Node.js runtime environment. */
11+
12+
/**
13+
* Node.js runtime environment.
14+
*/
1115
NODE,
12-
13-
/** Python runtime environment. */
16+
17+
/**
18+
* Python runtime environment.
19+
*/
1420
PYTHON,
15-
16-
/** Docker container runtime. */
21+
22+
/**
23+
* Docker container runtime.
24+
*/
1725
DOCKER
1826
}
1927

api/src/main/java/app/simplecloud/api/event/EventApi.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
/**
99
* API for subscribing to real-time system events.
10-
*
10+
*
1111
* <p>Provides access to event streams for various system entities.
1212
* All event subscriptions return a {@link Subscription} that must be
1313
* closed when no longer needed to prevent resource leaks.
@@ -16,28 +16,28 @@ public interface EventApi {
1616

1717
/**
1818
* Returns the event API for server group events.
19-
*
19+
*
2020
* @return the group event API
2121
*/
2222
GroupEventApi group();
2323

2424
/**
2525
* Returns the event API for server instance events.
26-
*
26+
*
2727
* @return the server event API
2828
*/
2929
ServerEventApi server();
3030

3131
/**
3232
* Returns the event API for persistent server events.
33-
*
33+
*
3434
* @return the persistent server event API
3535
*/
3636
PersistentServerEventApi persistentServer();
3737

3838
/**
3939
* Returns the event API for blueprint events.
40-
*
40+
*
4141
* @return the blueprint event API
4242
*/
4343
BlueprintEventApi blueprint();

api/src/main/java/app/simplecloud/api/event/Subscription.java

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

33
/**
44
* Represents an active event subscription.
5-
*
5+
*
66
* <p>Subscriptions must be closed when no longer needed to release resources.
77
* This interface implements {@link AutoCloseable} for use in try-with-resources.
88
*/
99
public interface Subscription extends AutoCloseable {
1010

1111
/**
1212
* Unsubscribes from the event stream.
13-
*
13+
*
1414
* <p>After calling this method, the handler will no longer receive events.
1515
* This method is idempotent and can be called multiple times safely.
1616
*/
1717
void unsubscribe();
1818

1919
/**
2020
* Closes the subscription by calling {@link #unsubscribe()}.
21-
*
21+
*
2222
* <p>This method allows subscriptions to be used in try-with-resources statements.
2323
*/
2424
@Override

0 commit comments

Comments
 (0)