summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/aizistral
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/aizistral')
-rw-r--r--src/main/java/com/aizistral/nochatreports/config/ServerAddressAdapter.java16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/main/java/com/aizistral/nochatreports/config/ServerAddressAdapter.java b/src/main/java/com/aizistral/nochatreports/config/ServerAddressAdapter.java
index 9a90b6e..c68aed9 100644
--- a/src/main/java/com/aizistral/nochatreports/config/ServerAddressAdapter.java
+++ b/src/main/java/com/aizistral/nochatreports/config/ServerAddressAdapter.java
@@ -1,19 +1,14 @@
package com.aizistral.nochatreports.config;
-import java.io.IOException;
-import java.lang.reflect.Type;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.InstanceCreator;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
-
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.multiplayer.resolver.ServerAddress;
+import java.io.IOException;
+
@Environment(EnvType.CLIENT)
public class ServerAddressAdapter extends TypeAdapter<ServerAddress> {
public static final ServerAddressAdapter INSTANCE = new ServerAddressAdapter();
@@ -25,17 +20,16 @@ public class ServerAddressAdapter extends TypeAdapter<ServerAddress> {
@Override
public ServerAddress read(JsonReader reader) throws IOException {
String string = reader.nextString();
- String address[] = string.split(":");
- if (address.length != 2)
+ if (!ServerAddress.isValidAddress(string))
throw new IOException("Incorrect server address format: " + string);
- return new ServerAddress(address[0], Integer.valueOf(address[1]));
+ return ServerAddress.parseString(string);
}
@Override
public void write(JsonWriter writer, ServerAddress address) throws IOException {
- writer.value(address.getHost() + ":" + address.getPort());
+ writer.value(address.toString());
}
}