2626import net .raphimc .netminecraft .packet .PacketTypes ;
2727import net .raphimc .netminecraft .packet .impl .common .S2CCustomPayloadPacket ;
2828import net .raphimc .viaproxy .proxy .session .ProxyConnection ;
29+ import net .raphimc .viaproxy .util .AddressUtil ;
2930import net .raphimc .viaproxy .util .logging .Logger ;
3031
3132import java .net .InetSocketAddress ;
@@ -58,7 +59,9 @@ public boolean handleP2S(Packet packet, List<ChannelFutureListener> listeners) t
5859 final String voiceHost = PacketTypes .readString (data , Short .MAX_VALUE ); // voice host
5960 if (voiceHost .isEmpty ()) {
6061 if (this .proxyConnection .getServerAddress () instanceof InetSocketAddress serverAddress ) {
61- PacketTypes .writeString (newData , new InetSocketAddress (serverAddress .getAddress (), port ).toString ());
62+ final String newVoiceHost = AddressUtil .toString (new InetSocketAddress (serverAddress .getAddress (), port ));
63+ PacketTypes .writeString (newData , newVoiceHost );
64+ Logger .u_info ("session" , this .proxyConnection , "Redirecting Simple Voice Chat to " + newVoiceHost );
6265 } else {
6366 throw new IllegalArgumentException ("Server address must be an InetSocketAddress" );
6467 }
@@ -68,7 +71,7 @@ public boolean handleP2S(Packet packet, List<ChannelFutureListener> listeners) t
6871 newData .writeBytes (data );
6972 customPayloadPacket .data = ByteBufUtil .getBytes (newData );
7073 } catch (Throwable e ) {
71- Logger .LOGGER .error ("Failed to handle simple voice chat packet" , e );
74+ Logger .LOGGER .error ("Failed to handle Simple Voice Chat packet" , e );
7275 }
7376 }
7477 }
0 commit comments