Skip to content

Commit 2e28d29

Browse files
tangjin0418kangarko
authored andcommitted
Add "GetPlayerServer". (PaperMC#1484)
1 parent b8f99f4 commit 2e28d29

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BungeeCordMessageResponder.java

+18
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,21 @@ private void processForwardToServer(ByteBufDataInput in) {
301301
}
302302
}
303303

304+
private void processGetPlayerServer(ByteBufDataInput in) {
305+
proxy.getPlayer(in.readUTF()).ifPresent(player -> {
306+
player.getCurrentServer().ifPresent(server -> {
307+
ByteBuf buf = Unpooled.buffer();
308+
ByteBufDataOutput out = new ByteBufDataOutput(buf);
309+
310+
out.writeUTF("GetPlayerServer");
311+
out.writeUTF(player.getUsername());
312+
out.writeUTF(server.getServerInfo().getName());
313+
314+
sendResponseOnConnection(buf);
315+
});
316+
});
317+
}
318+
304319
static String getBungeeCordChannel(ProtocolVersion version) {
305320
return version.noLessThan(ProtocolVersion.MINECRAFT_1_13) ? MODERN_CHANNEL.getId()
306321
: LEGACY_CHANNEL.getId();
@@ -331,6 +346,9 @@ boolean process(PluginMessagePacket message) {
331346
ByteBufDataInput in = new ByteBufDataInput(message.content());
332347
String subChannel = in.readUTF();
333348
switch (subChannel) {
349+
case "GetPlayerServer":
350+
this.processGetPlayerServer(in);
351+
break;
334352
case "ForwardToPlayer":
335353
this.processForwardToPlayer(in);
336354
break;

0 commit comments

Comments
 (0)