geforkt von Mirrors/Velocity
Share instances of the custom Gson type serializers
Dieser Commit ist enthalten in:
Ursprung
5d287306c2
Commit
1dd900194d
@ -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;
|
||||
|
@ -11,6 +11,12 @@ import java.lang.reflect.Type;
|
||||
|
||||
public final class FaviconSerializer implements JsonSerializer<Favicon>, JsonDeserializer<Favicon> {
|
||||
|
||||
public static final FaviconSerializer INSTANCE = new FaviconSerializer();
|
||||
|
||||
private FaviconSerializer() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Favicon deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
|
||||
return new Favicon(json.getAsString());
|
||||
|
@ -16,8 +16,13 @@ import java.util.List;
|
||||
public final class GameProfileSerializer implements JsonSerializer<GameProfile>,
|
||||
JsonDeserializer<GameProfile> {
|
||||
|
||||
public static final GameProfileSerializer INSTANCE = new GameProfileSerializer();
|
||||
private static final Type propertyList = new TypeToken<List<Property>>() {}.getType();
|
||||
|
||||
private GameProfileSerializer() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile deserialize(JsonElement json, Type typeOfT,
|
||||
JsonDeserializationContext context) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren