33import com .viaversion .viaversion .api .protocol .version .ProtocolVersion ;
44import net .lenni0451 .commons .gson .GsonParser ;
55import net .lenni0451 .commons .gson .elements .GsonObject ;
6- import net .lenni0451 .commons .gson .elements .GsonPrimitive ;
76import net .lenni0451 .miniconnect .Main ;
87import net .lenni0451 .miniconnect .model .ConnectionInfo ;
98import net .lenni0451 .miniconnect .utils .AESEncryption ;
109import net .lenni0451 .miniconnect .utils .UUIDUtils ;
1110import net .raphimc .viaproxy .saves .impl .accounts .Account ;
1211import net .raphimc .viaproxy .saves .impl .accounts .MicrosoftAccount ;
13- import net .raphimc .viaproxy .util .AddressUtil ;
1412
1513import javax .annotation .Nullable ;
1614import java .io .File ;
@@ -32,8 +30,6 @@ public static File baseDir() {
3230 @ Nullable
3331 public String serverAddress ;
3432 @ Nullable
35- public Integer serverPort ;
36- @ Nullable
3733 public ProtocolVersion targetVersion ;
3834 @ Nullable
3935 public Account account ;
@@ -49,15 +45,13 @@ public PlayerConfig(final UUID uuid) {
4945 }
5046
5147 public void applyConnectionInfo (final ConnectionInfo connectionInfo ) {
52- this .serverAddress = connectionInfo .host ();
53- this .serverPort = connectionInfo .port ();
48+ this .serverAddress = connectionInfo .address ();
5449 this .targetVersion = connectionInfo .protocolVersion ();
5550 this .account = connectionInfo .account ();
5651 }
5752
5853 public ConnectionInfo toConnectionInfo () {
59- int serverPort = this .serverPort == null || this .serverPort == -1 ? AddressUtil .getDefaultPort (this .targetVersion ) : this .serverPort ;
60- return new ConnectionInfo (this .handshakeAddress , this .handshakePort , this .serverAddress , serverPort , this .targetVersion , this .account );
54+ return new ConnectionInfo (this .handshakeAddress , this .handshakePort , this .serverAddress , this .targetVersion , this .account );
6155 }
6256
6357 public void load () throws Exception {
@@ -72,7 +66,6 @@ public void load() throws Exception {
7266 String json = new String (decryptedData , StandardCharsets .UTF_8 );
7367 GsonObject object = GsonParser .parse (json ).asObject ();
7468 this .serverAddress = object .getString ("serverAddress" , null );
75- this .serverPort = object .optPrimitive ("serverPort" ).map (GsonPrimitive ::asInt ).orElse (null );
7669 this .targetVersion = object .optPrimitive ("targetVersion" ).map (p -> ProtocolVersion .getProtocol (p .asInt ())).orElse (null );
7770 this .account = object .optObject ("account" ).map (GsonObject ::getJsonObject ).map (MicrosoftAccount ::new ).orElse (null );
7871 }
@@ -85,7 +78,6 @@ public void save() throws Exception {
8578
8679 GsonObject object = new GsonObject ();
8780 if (this .serverAddress != null ) object .add ("serverAddress" , this .serverAddress );
88- if (this .serverPort != null ) object .add ("serverPort" , this .serverPort );
8981 if (this .targetVersion != null ) object .add ("targetVersion" , this .targetVersion .getOriginalVersion ());
9082 if (this .account != null ) object .add ("account" , this .account .toJson ());
9183 byte [] key = UUIDUtils .toBytes (this .uuid );
0 commit comments