This repository was archived by the owner on Aug 24, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.java
More file actions
50 lines (42 loc) · 1.65 KB
/
Copy pathExample.java
File metadata and controls
50 lines (42 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package net.enabify.recon.client;
/**
* Recon Client - Java Example
*
* Demonstrates how to use the Recon Java client library
* to send commands to a Minecraft server via REST API.
*/
public class Example {
public static void main(String[] args) {
// Configuration
String host = "127.0.0.1";
int port = 4161;
String user = "admin";
String password = "your_password";
int timeout = 10000; // milliseconds
// Create client instance
Recon recon = new Recon(host, port, user, password, timeout);
// Test connection
System.out.println("Testing connection...");
Recon.ReconResponse response = recon.sendCommand("recon test", true);
if (response.isSuccess()) {
System.out.println("Connection successful!");
System.out.println("Response: " + response.getResponse());
System.out.println("Plain Response: " + response.getPlainResponse());
} else {
System.out.println("Connection failed!");
System.out.println("Error: " + response.getError());
}
System.out.println();
// Execute a command
String cmd = "say Hello from Recon Java client!";
System.out.println("Executing command: " + cmd);
response = recon.sendCommand(cmd, true);
if (response.isSuccess()) {
System.out.println("Command executed successfully.");
System.out.println("Response: " + response.getResponse());
} else {
System.out.println("Command failed.");
System.out.println("Error: " + response.getError());
}
}
}