This repository has been archived by the owner on Jun 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename API builders Make ServerProcessMeta inherit from ServerProcessData Remove custom server name functionality Remove startGameServer methods Remove a lot of priority stop functionality
- Loading branch information
1 parent
8593e33
commit 6d4ee74
Showing
25 changed files
with
511 additions
and
1,284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...dnet-api-core/src/main/java/de/dytanic/cloudnet/api/builders/ApiServerProcessBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package de.dytanic.cloudnet.api.builders; | ||
|
||
import de.dytanic.cloudnet.api.CloudAPI; | ||
import de.dytanic.cloudnet.api.network.packet.api.PacketOutStartServer; | ||
import de.dytanic.cloudnet.lib.process.ServerProcessBuilder; | ||
import de.dytanic.cloudnet.lib.process.ServerProcessData; | ||
import de.dytanic.cloudnet.lib.server.ServerProcessMeta; | ||
|
||
import java.util.UUID; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Builder for a server process in the API for proxies and servers. | ||
* Uses {@link ServerProcessData} for storing the data. | ||
*/ | ||
public class ApiServerProcessBuilder extends ServerProcessBuilder { | ||
|
||
/** | ||
* Creates a new server process builder for a server of the specified server group. | ||
* This value is mandatory as servers cannot be started without belonging to a group. | ||
* | ||
* @param serverGroupName the name of the server group that the server will be started from. | ||
* | ||
* @return the newly created server process builder. | ||
*/ | ||
public static ServerProcessBuilder create(String serverGroupName) { | ||
return new ApiServerProcessBuilder().serverGroupName(serverGroupName); | ||
} | ||
|
||
/** | ||
* Requests the master to initiate this server startup. | ||
* This will trigger a sequence of messages to be passed between the calling service, | ||
* the master and the wrapper that will start the server. | ||
* <p> | ||
* Once the server is started, the returned future will be completed and contains the | ||
* process metadata that was valid at the time of starting up. | ||
* <p> | ||
* Note that the delay between requesting the start (ie. this method) and the actual | ||
* completion of the returned future is indefinite and the future may not actually | ||
* be completed at all- | ||
* | ||
* @return a future that will be completed once the server is connected to the cloud network. | ||
*/ | ||
public CompletableFuture<ServerProcessMeta> startServer() { | ||
final UUID uuid = UUID.randomUUID(); | ||
this.getServerProcessData().getServerConfig().getProperties().append("cloudnet:requestId", uuid); | ||
CloudAPI.getInstance().getNetworkConnection().sendAsynchronous( | ||
new PacketOutStartServer(this.getServerProcessData()) | ||
); | ||
return CloudAPI.getInstance().getCloudService().waitForServer(uuid); | ||
} | ||
|
||
} |
Oops, something went wrong.
6d4ee74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closes #236