|
1 | | -## Java exaroton API Client |
| 1 | +# Java exaroton API Client |
2 | 2 |
|
3 | 3 | --- |
4 | | -### About |
| 4 | +## About |
5 | 5 | The official java library for the [exaroton API](https://developers.exaroton.com/) |
6 | 6 | that can be used to automatically manage Minecraft servers (e.g. starting or stopping them). |
7 | 7 |
|
8 | 8 | Required Java Version: 11+ |
9 | 9 |
|
10 | 10 | If you're creating a plugin/mod that runs on an exaroton server, you can get the current server using client.getCurrentServer(). |
11 | 11 |
|
12 | | -### Installing |
| 12 | +## Installing |
13 | 13 | Gradle: |
14 | 14 | ```gradle |
15 | 15 | dependencies { |
|
26 | 26 | </dependency> |
27 | 27 | ``` |
28 | 28 |
|
29 | | -### Usage |
| 29 | +## Usage |
30 | 30 | You need an API key to use the API. You can generate an api key in the [account options](https://exaroton.com/account/). |
31 | 31 |
|
32 | 32 |
|
@@ -274,6 +274,23 @@ server.addStatusSubscriber(new ServerStatusSubscriber() { |
274 | 274 | This event is not only triggered when the status itself changes but also when other events happen, |
275 | 275 | e.g. a player joins the server. |
276 | 276 |
|
| 277 | +It's also possible to wait until your server reaches a specific status using the websocket API: |
| 278 | +```jshelllanguage |
| 279 | +server.waitForStatus(ServerStatus.OFFLINE, ServerStatus.CRASHED).join(); |
| 280 | +``` |
| 281 | + |
| 282 | +It is highly recommended to consider all possible status changes and/or configure a timeout to prevent your application |
| 283 | +from hanging e.g. if starting the server fails or the server crashes while stopping. To set a timeout just use |
| 284 | +`Future#get(long,TimeUnit)`: |
| 285 | + |
| 286 | +```jshelllanguage |
| 287 | +try { |
| 288 | + server.waitForStatus(ServerStatus.OFFLINE, ServerStatus.CRASHED).get(5, TimeUnit.MINUTES); |
| 289 | +} catch (TimeoutException e) { |
| 290 | + System.out.println("Server did not reach the desired status in time!"); |
| 291 | +} |
| 292 | +``` |
| 293 | + |
277 | 294 | #### Console messages |
278 | 295 | The console stream emits an event for every new console line. |
279 | 296 | ```jshelllanguage |
@@ -343,3 +360,7 @@ the process stops even if there are dangling event handlers. |
343 | 360 | ```jshelllanguage |
344 | 361 | server.unsubscribe(); // closes websocket connection |
345 | 362 | ``` |
| 363 | + |
| 364 | +### Logging |
| 365 | +This library uses `slf4j` for logging, but does not include any provider on its own. See the SLF4J docs for more |
| 366 | +information on which providers are available or how to install them: https://www.slf4j.org/manual.html#swapping |
0 commit comments