LibsDisguises/src/me/libraryaddict/disguise/utilities/json/SerializerGameProfile.java

25 lines
844 B
Java
Raw Normal View History

2017-06-02 15:51:03 +02:00
package me.libraryaddict.disguise.utilities.json;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.google.gson.*;
import com.mojang.authlib.GameProfile;
import java.lang.reflect.Type;
/**
* Created by libraryaddict on 1/06/2017.
*/
public class SerializerGameProfile implements JsonSerializer<WrappedGameProfile>, JsonDeserializer<WrappedGameProfile> {
@Override
public JsonElement serialize(WrappedGameProfile src, Type typeOfSrc, JsonSerializationContext context) {
return context.serialize(src.getHandle(), GameProfile.class);
}
@Override
public WrappedGameProfile deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
return WrappedGameProfile.fromHandle(context.deserialize(json, GameProfile.class));
}
}