diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/GameProfile.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/GameProfile.java index 2ffefb3b9..153668cb4 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/GameProfile.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/GameProfile.java @@ -17,10 +17,8 @@ */ package org.jackhuang.hmcl.auth.yggdrasil; -import com.google.gson.*; import org.jackhuang.hmcl.util.Immutable; -import java.lang.reflect.Type; import java.util.UUID; /** @@ -63,34 +61,4 @@ public final class GameProfile { return properties; } - public static class Serializer implements JsonSerializer, JsonDeserializer { - - public static final Serializer INSTANCE = new Serializer(); - - private Serializer() { - } - - @Override - public JsonElement serialize(GameProfile src, Type type, JsonSerializationContext context) { - JsonObject result = new JsonObject(); - if (src.getId() != null) - result.add("id", context.serialize(src.getId())); - if (src.getName() != null) - result.addProperty("name", src.getName()); - return result; - } - - @Override - public GameProfile deserialize(JsonElement je, Type type, JsonDeserializationContext context) throws JsonParseException { - if (!(je instanceof JsonObject)) - throw new JsonParseException("The json element is not a JsonObject."); - - JsonObject json = (JsonObject) je; - - UUID id = json.has("id") ? context.deserialize(json.get("id"), UUID.class) : null; - String name = json.has("name") ? json.getAsJsonPrimitive("name").getAsString() : null; - return new GameProfile(id, name); - } - } - } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilService.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilService.java index 670a913bd..264942248 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilService.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilService.java @@ -120,8 +120,7 @@ public class YggdrasilService { public Optional getCompleteGameProfile(UUID uuid) throws AuthenticationException { Objects.requireNonNull(uuid); - return Optional.ofNullable(fromJson(request(provider.getProfilePropertiesURL(uuid), null), ProfileResponse.class)) - .map(response -> new GameProfile(response.id, response.name, response.properties)); + return Optional.ofNullable(fromJson(request(provider.getProfilePropertiesURL(uuid), null), GameProfile.class)); } public Optional> getTextures(GameProfile profile) throws AuthenticationException { @@ -191,12 +190,6 @@ public class YggdrasilService { } } - private class ProfileResponse { - public UUID id; - public String name; - public PropertyMap properties; - } - private class TextureResponse { public Map textures; } @@ -216,7 +209,6 @@ public class YggdrasilService { } private static final Gson GSON = new GsonBuilder() - .registerTypeAdapter(GameProfile.class, GameProfile.Serializer.INSTANCE) .registerTypeAdapter(PropertyMap.class, PropertyMap.Serializer.INSTANCE) .registerTypeAdapter(UUID.class, UUIDTypeAdapter.INSTANCE) .create();