diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 5e4382443..a641acfb1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -91,20 +91,20 @@ public class VelocityServer implements ProxyServer, ForwardingAudience { private static final Logger logger = LogManager.getLogger(VelocityServer.class); public static final Gson GENERAL_GSON = new GsonBuilder() - .registerTypeHierarchyAdapter(Favicon.class, new FaviconSerializer()) - .registerTypeHierarchyAdapter(GameProfile.class, new GameProfileSerializer()) + .registerTypeHierarchyAdapter(Favicon.class, FaviconSerializer.INSTANCE) + .registerTypeHierarchyAdapter(GameProfile.class, GameProfileSerializer.INSTANCE) .create(); private static final Gson PRE_1_16_PING_SERIALIZER = ProtocolUtils .getJsonChatSerializer(ProtocolVersion.MINECRAFT_1_15_2) .serializer() .newBuilder() - .registerTypeHierarchyAdapter(Favicon.class, new FaviconSerializer()) + .registerTypeHierarchyAdapter(Favicon.class, FaviconSerializer.INSTANCE) .create(); private static final Gson POST_1_16_PING_SERIALIZER = ProtocolUtils .getJsonChatSerializer(ProtocolVersion.MINECRAFT_1_16) .serializer() .newBuilder() - .registerTypeHierarchyAdapter(Favicon.class, new FaviconSerializer()) + .registerTypeHierarchyAdapter(Favicon.class, FaviconSerializer.INSTANCE) .create(); private final ConnectionManager cm; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/FaviconSerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/FaviconSerializer.java index 3d6ea395f..a67862323 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/FaviconSerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/FaviconSerializer.java @@ -11,6 +11,12 @@ import java.lang.reflect.Type; public final class FaviconSerializer implements JsonSerializer, JsonDeserializer { + public static final FaviconSerializer INSTANCE = new FaviconSerializer(); + + private FaviconSerializer() { + + } + @Override public Favicon deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { return new Favicon(json.getAsString()); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/GameProfileSerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/GameProfileSerializer.java index b8a53b29d..c93b9a3cc 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/GameProfileSerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/GameProfileSerializer.java @@ -16,8 +16,13 @@ import java.util.List; public final class GameProfileSerializer implements JsonSerializer, JsonDeserializer { + public static final GameProfileSerializer INSTANCE = new GameProfileSerializer(); private static final Type propertyList = new TypeToken>() {}.getType(); + private GameProfileSerializer() { + + } + @Override public GameProfile deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {