Skip to content

Commit 438c3f9

Browse files
committed
Include server addy and bot name in response.
1 parent 5135087 commit 438c3f9

3 files changed

Lines changed: 34 additions & 3 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
plugin_version=1.0.0
1+
plugin_version=1.0.1
22
plugin_name=PearlPlusWebAPI
33
mc=1.21.4
44
maven_group=dev.zenith.ppapi

src/main/java/dev/zenith/ppapi/api/PPApiServer.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,13 @@ private Javalin createServer() {
119119
ctx.json(new ApiErrorResponse(result.error()));
120120
return;
121121
}
122-
ctx.json(new PearlStatusResponse(result.pearls(), result.output()));
122+
var botInfo = readZenithBotInfo();
123+
ctx.json(new PearlStatusResponse(
124+
result.pearls(),
125+
result.output(),
126+
botInfo.minecraftServer(),
127+
botInfo.botUsername()
128+
));
123129
ctx.status(200);
124130
})
125131
.post("/pearlplus/load", ctx -> {
@@ -222,4 +228,27 @@ private record ConfigPearlResult(
222228
List<String> output,
223229
String error
224230
) { }
231+
232+
private BotInfo readZenithBotInfo() {
233+
String server = null;
234+
String username = null;
235+
var config = Globals.CONFIG;
236+
if (config != null) {
237+
if (config.authentication != null) {
238+
username = config.authentication.username;
239+
}
240+
if (config.client != null && config.client.server != null) {
241+
var address = config.client.server.address;
242+
if (address != null && !address.isBlank()) {
243+
server = address;
244+
}
245+
}
246+
}
247+
return new BotInfo(server, username);
248+
}
249+
250+
private record BotInfo(
251+
String minecraftServer,
252+
String botUsername
253+
) { }
225254
}

src/main/java/dev/zenith/ppapi/api/model/PearlStatusResponse.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44

55
public record PearlStatusResponse(
66
List<String> pearls,
7-
List<String> output
7+
List<String> output,
8+
String minecraftServer,
9+
String botUsername
810
) { }

0 commit comments

Comments
 (0)