Skip to content

Commit 3ace2cf

Browse files
committed
Add management protocol README
1 parent 65346a4 commit 3ace2cf

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,31 @@ server.addHeapSubscriber(new HeapSubscriber() {
351351
});
352352
```
353353

354+
#### Management Protocol
355+
The Minecraft server management protocol introduced in 1.21.9 allows controlling various server settings without
356+
restarting the server and receiving events from the server. This API client supports proxying this protocol through the
357+
exaroton websocket connection. All parameters/responses are JSON elements. There are no predefined classes for the data.
358+
359+
```jshelllanguage
360+
ExarotonClient client = new ExarotonClient("example-api-token");
361+
362+
Server server = client.getServer("tgkm731xO7GiHt76");
363+
364+
// Perform a request
365+
server.sendServerManagementRequest(
366+
"minecraft:operators/remove",
367+
JsonParser.parseString("[[{\"name\":\"" + playerName + "\"}]]")
368+
)
369+
370+
// Subscribe to notifications
371+
server.addServerManagementNotificationSubscriber(new ManagementNotificationSubscriber() {
372+
@Override
373+
public void handleNotification(@NotNull String name, @Nullable JsonElement data) {
374+
System.out.println("Received event: " + event);
375+
}
376+
});
377+
```
378+
354379
#### Unsubscribe
355380
When all subscribers for a stream are removed, this library automatically unsubscribes from events for that stream. Once
356381
all streams are closed the websocket connection is closed as well.

0 commit comments

Comments
 (0)