Skip to content

Commit c3ee4b3

Browse files
committed
Add waitForStatus and logging sections to README
1 parent 2cf86bd commit c3ee4b3

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
## Java exaroton API Client
1+
# Java exaroton API Client
22

33
---
4-
### About
4+
## About
55
The official java library for the [exaroton API](https://developers.exaroton.com/)
66
that can be used to automatically manage Minecraft servers (e.g. starting or stopping them).
77

88
Required Java Version: 11+
99

1010
If you're creating a plugin/mod that runs on an exaroton server, you can get the current server using client.getCurrentServer().
1111

12-
### Installing
12+
## Installing
1313
Gradle:
1414
```gradle
1515
dependencies {
@@ -26,7 +26,7 @@ Maven:
2626
</dependency>
2727
```
2828

29-
### Usage
29+
## Usage
3030
You need an API key to use the API. You can generate an api key in the [account options](https://exaroton.com/account/).
3131

3232

@@ -274,6 +274,23 @@ server.addStatusSubscriber(new ServerStatusSubscriber() {
274274
This event is not only triggered when the status itself changes but also when other events happen,
275275
e.g. a player joins the server.
276276

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+
277294
#### Console messages
278295
The console stream emits an event for every new console line.
279296
```jshelllanguage
@@ -343,3 +360,7 @@ the process stops even if there are dangling event handlers.
343360
```jshelllanguage
344361
server.unsubscribe(); // closes websocket connection
345362
```
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

Comments
 (0)