@@ -32,14 +32,14 @@ You need an API key to use the API. You can generate an api key in the [account
3232
3333#### Create a client
3434
35- ``` java
35+ ``` jshelllanguage
3636ExarotonClient client = new ExarotonClient("example-api-token");
3737```
3838
3939### REST API
4040
4141#### Show account info
42- ``` java
42+ ``` jshelllanguage
4343ExarotonClient client = new ExarotonClient("example-api-token");
4444
4545try {
@@ -52,11 +52,11 @@ try {
5252Objects of the Account class contain getters for each field in the [ API docs] ( https://developers.exaroton.com/#account-get ) .
5353
5454#### Get all servers
55- ``` java
55+ ``` jshelllanguage
5656ExarotonClient client = new ExarotonClient("example-api-token");
5757
5858try {
59- Server [] servers = client. getServers();
59+ List< Server> servers = client.getServers();
6060 for (Server server: servers) {
6161 System.out.println(server.getId() + ":" + server.getAddress());
6262 }
@@ -68,7 +68,7 @@ Objects of the Server class contain getters for each field in the [API docs](htt
6868
6969
7070#### Get a single server
71- ``` java
71+ ``` jshelllanguage
7272ExarotonClient client = new ExarotonClient("example-api-token");
7373
7474Server server = client.getServer("tgkm731xO7GiHt76");
8585```
8686
8787#### Check the server status
88- ``` java
88+ ``` jshelllanguage
8989ExarotonClient client = new ExarotonClient("example-api-token");
9090
9191Server server = client.getServer("tgkm731xO7GiHt76");
9999 else if (server.hasStatus(ServerStatus.OFFLINE)) {
100100 System.out.println("Server is offline!");
101101 }
102- else if (server. hasStatus(new int []{ ServerStatus . PREPARING , ServerStatus . LOADING , ServerStatus . STARTING} )) {
102+ else if (server.hasStatus(ServerStatus.PREPARING, ServerStatus.LOADING, ServerStatus.STARTING)) {
103103 System.out.println("Server is starting!");
104104 }
105105} catch (APIException e) {
@@ -122,7 +122,7 @@ Status codes:
122122You can use the ServerStatus class to easily get the value of any status.
123123
124124#### Get/Share your server log
125- ``` java
125+ ``` jshelllanguage
126126ExarotonClient client = new ExarotonClient("example-api-token");
127127
128128Server server = client.getServer("tgkm731xO7GiHt76");
@@ -142,7 +142,7 @@ The result is cached and will not return the latest updates immediately. It's no
142142
143143
144144#### Get/Set server RAM
145- ``` java
145+ ``` jshelllanguage
146146ExarotonClient client = new ExarotonClient("example-api-token");
147147
148148Server server = client.getServer("tgkm731xO7GiHt76");
@@ -166,7 +166,7 @@ Player lists are also cached any might not immediately return new results when c
166166You can list all available playerlists using server.getPlayerLists()
167167
168168##### List/modify entries
169- ``` java
169+ ``` jshelllanguage
170170ExarotonClient client = new ExarotonClient("example-api-token");
171171
172172Server server = client.getServer("tgkm731xO7GiHt76");
@@ -185,15 +185,15 @@ try {
185185
186186#### Files
187187To manage a file on your server first obtain a file Object:
188- ``` java
188+ ``` jshelllanguage
189189ExarotonClient client = new ExarotonClient("example-api-token");
190190
191191Server server = client.getServer("tgkm731xO7GiHt76");
192192ServerFile file = server.getFile("/whitelist.json");
193193```
194194
195195Now you can fetch file info, get the context of a file (if it's a text file) or download it.
196- ``` java
196+ ``` jshelllanguage
197197file.getInfo();
198198if (file.isTextFile()) {
199199 System.out.println(file.getContent());
@@ -204,21 +204,21 @@ else {
204204```
205205
206206You can also write to the file or upload a file:
207- ``` java
207+ ``` jshelllanguage
208208file.putContent("I can write to a file o.O");
209209file.upload(Paths.get("other-whitelist.json"));
210210```
211211
212212Deleting files and creating directories is possible as well:
213- ``` java
213+ ``` jshelllanguage
214214file.delete();
215215file.createAsDirectory();
216216```
217217
218218#### Configs
219219Some files are special because they are parsed, validated and understood by the exaroton backend.
220220These files are called configs and can be managed like this:
221- ``` java
221+ ``` jshelllanguage
222222ExarotonClient client = new ExarotonClient("example-api-token");
223223
224224Server server = client.getServer("tgkm731xO7GiHt76");
@@ -234,7 +234,7 @@ ConfigOption option = config.getOption("level-seed");
234234```
235235
236236There are several types of options which extend the ServerConfigOption class:
237- ``` java
237+ ``` jshelllanguage
238238for (ServerConfigOption option: options) {
239239 if (option.getType() == OptionType.BOOLEAN) {
240240 BooleanConfigOption booleanOption = (BooleanConfigOption) option;
@@ -244,17 +244,17 @@ for (ServerConfigOption option: options) {
244244```
245245
246246To save changes to a config, use the save() method:
247- ``` java
247+ ``` jshelllanguage
248248config.getOption("level-seed").setValue("example");
249249config.save();
250250```
251251
252252#### Credit Pools
253253Credit pools allow you to share payments for your server with other users in a safe way.
254254You can view information about credit pools like this:
255- ``` java
255+ ``` jshelllanguage
256256// get all credit pools
257- CreditPool [] pools = client. getCreditPools();
257+ List< CreditPool> pools = client.getCreditPools();
258258for (CreditPool pool: pools) {
259259 System.out.println(pool.getName() + ": " + pool.getCredits());
260260}
@@ -266,18 +266,18 @@ System.out.println(pool.getName() + ": " + pool.getCredits());
266266```
267267
268268The API also allows you to fetch the servers in a pool:
269- ``` java
269+ ``` jshelllanguage
270270CreditPool pool = client.getCreditPool("N2t9gWOMpzRL37FI");
271- Server [] servers = pool. getServers();
271+ List< Server> servers = pool.getServers();
272272for (Server server: servers) {
273273System.out.println(server.getName() + ": " + server.getAddress());
274274}
275275```
276276
277277If you have the "View members" permission, you can even get all members of a pool:
278- ``` java
278+ ``` jshelllanguage
279279CreditPool pool = client.getCreditPool("N2t9gWOMpzRL37FI");
280- CreditPoolMember [] members = pool. getMembers();
280+ List< CreditPoolMember> members = pool.getMembers();
281281for (CreditPoolMember member: members) {
282282 System.out.println(member.getName() + ": " + member.getCredits());
283283}
@@ -293,7 +293,7 @@ You can simply connect to the websocket API for a server by running the subscrib
293293By default, you are always subscribed to server status update events, you can react to server status
294294changes by adding a subscriber:
295295
296- ``` java
296+ ``` jshelllanguage
297297ExarotonClient client = new ExarotonClient("example-api-token");
298298
299299Server server = client.getServer("tgkm731xO7GiHt76");
@@ -311,7 +311,7 @@ e.g. a player joins the server.
311311#### Console messages
312312One of the optional streams is the console stream. You can subscribe to one or more optional streams
313313using the subscribe method. The console stream emits an event for every new console line.
314- ``` java
314+ ``` jshelllanguage
315315ExarotonClient client = new ExarotonClient("example-api-token");
316316
317317Server server = client.getServer("tgkm731xO7GiHt76");
@@ -333,7 +333,7 @@ instead, so you can just use it the same way as [before](#get-a-single-server).
333333On Minecraft Java edition servers with version 1.16 and higher it is possible to get the tick times,
334334and the TPS (ticks per second) of your server. This information is also available as an optional stream.
335335
336- ``` java
336+ ``` jshelllanguage
337337ExarotonClient client = new ExarotonClient("example-api-token");
338338
339339Server server = client.getServer("tgkm731xO7GiHt76");
@@ -355,7 +355,7 @@ on Java. It is not recommended using both.
355355
356356You can subscribe to multiple streams at once by passing an array to the subscribe function.
357357
358- ``` java
358+ ``` jshelllanguage
359359ExarotonClient client = new ExarotonClient("example-api-token");
360360
361361Server server = client.getServer("tgkm731xO7GiHt76");
@@ -377,7 +377,7 @@ server.addHeapSubscriber(new HeapSubscriber() {
377377#### Unsubscribe
378378You can unsubscribe from one, multiple or all streams using the server.unsubscribe() function.
379379
380- ``` java
380+ ``` jshelllanguage
381381ExarotonClient client = new ExarotonClient("example-api-token");
382382
383383Server server = client.getServer("tgkm731xO7GiHt76");
@@ -388,7 +388,7 @@ server.unsubscribe(); // closes websocket connection
388388```
389389
390390### Debugging Websocket connections
391- ``` java
391+ ``` jshelllanguage
392392ExarotonClient client = new ExarotonClient("example-api-token");
393393
394394Server server = client.getServer("tgkm731xO7GiHt76");
@@ -398,4 +398,4 @@ server.getWebSocket().setErrorListener((message, throwable) -> {
398398 System.out.println(throwable.toString());
399399});
400400server.getWebSocket().setDebugListener(System.out::println);
401- ```
401+ ```
0 commit comments