Skip to content

Commit

Permalink
Add "GetPlayerServer". (#1484)
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjin0418 authored Jan 2, 2025
1 parent 1db8c8c commit 00b6885
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,21 @@ private void processForwardToServer(ByteBufDataInput in) {
}
}

private void processGetPlayerServer(ByteBufDataInput in) {
proxy.getPlayer(in.readUTF()).ifPresent(player -> {
player.getCurrentServer().ifPresent(server -> {
ByteBuf buf = Unpooled.buffer();
ByteBufDataOutput out = new ByteBufDataOutput(buf);

out.writeUTF("GetPlayerServer");
out.writeUTF(player.getUsername());
out.writeUTF(server.getServerInfo().getName());

sendResponseOnConnection(buf);
});
});
}

static String getBungeeCordChannel(ProtocolVersion version) {
return version.noLessThan(ProtocolVersion.MINECRAFT_1_13) ? MODERN_CHANNEL.getId()
: LEGACY_CHANNEL.getId();
Expand Down Expand Up @@ -331,6 +346,9 @@ boolean process(PluginMessagePacket message) {
ByteBufDataInput in = new ByteBufDataInput(message.content());
String subChannel = in.readUTF();
switch (subChannel) {
case "GetPlayerServer":
this.processGetPlayerServer(in);
break;
case "ForwardToPlayer":
this.processForwardToPlayer(in);
break;
Expand Down

0 comments on commit 00b6885

Please sign in to comment.