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);
|
private static final Logger logger = LogManager.getLogger(VelocityServer.class);
|
||||||
public static final Gson GENERAL_GSON = new GsonBuilder()
|
public static final Gson GENERAL_GSON = new GsonBuilder()
|
||||||
.registerTypeHierarchyAdapter(Favicon.class, new FaviconSerializer())
|
.registerTypeHierarchyAdapter(Favicon.class, FaviconSerializer.INSTANCE)
|
||||||
.registerTypeHierarchyAdapter(GameProfile.class, new GameProfileSerializer())
|
.registerTypeHierarchyAdapter(GameProfile.class, GameProfileSerializer.INSTANCE)
|
||||||
.create();
|
.create();
|
||||||
private static final Gson PRE_1_16_PING_SERIALIZER = ProtocolUtils
|
private static final Gson PRE_1_16_PING_SERIALIZER = ProtocolUtils
|
||||||
.getJsonChatSerializer(ProtocolVersion.MINECRAFT_1_15_2)
|
.getJsonChatSerializer(ProtocolVersion.MINECRAFT_1_15_2)
|
||||||
.serializer()
|
.serializer()
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.registerTypeHierarchyAdapter(Favicon.class, new FaviconSerializer())
|
.registerTypeHierarchyAdapter(Favicon.class, FaviconSerializer.INSTANCE)
|
||||||
.create();
|
.create();
|
||||||
private static final Gson POST_1_16_PING_SERIALIZER = ProtocolUtils
|
private static final Gson POST_1_16_PING_SERIALIZER = ProtocolUtils
|
||||||
.getJsonChatSerializer(ProtocolVersion.MINECRAFT_1_16)
|
.getJsonChatSerializer(ProtocolVersion.MINECRAFT_1_16)
|
||||||
.serializer()
|
.serializer()
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.registerTypeHierarchyAdapter(Favicon.class, new FaviconSerializer())
|
.registerTypeHierarchyAdapter(Favicon.class, FaviconSerializer.INSTANCE)
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
private final ConnectionManager cm;
|
private final ConnectionManager cm;
|
||||||
|
@ -11,6 +11,12 @@ import java.lang.reflect.Type;
|
|||||||
|
|
||||||
public final class FaviconSerializer implements JsonSerializer<Favicon>, JsonDeserializer<Favicon> {
|
public final class FaviconSerializer implements JsonSerializer<Favicon>, JsonDeserializer<Favicon> {
|
||||||
|
|
||||||
|
public static final FaviconSerializer INSTANCE = new FaviconSerializer();
|
||||||
|
|
||||||
|
private FaviconSerializer() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Favicon deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
|
public Favicon deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
|
||||||
return new Favicon(json.getAsString());
|
return new Favicon(json.getAsString());
|
||||||
|
@ -16,8 +16,13 @@ import java.util.List;
|
|||||||
public final class GameProfileSerializer implements JsonSerializer<GameProfile>,
|
public final class GameProfileSerializer implements JsonSerializer<GameProfile>,
|
||||||
JsonDeserializer<GameProfile> {
|
JsonDeserializer<GameProfile> {
|
||||||
|
|
||||||
|
public static final GameProfileSerializer INSTANCE = new GameProfileSerializer();
|
||||||
private static final Type propertyList = new TypeToken<List<Property>>() {}.getType();
|
private static final Type propertyList = new TypeToken<List<Property>>() {}.getType();
|
||||||
|
|
||||||
|
private GameProfileSerializer() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameProfile deserialize(JsonElement json, Type typeOfT,
|
public GameProfile deserialize(JsonElement json, Type typeOfT,
|
||||||
JsonDeserializationContext context) {
|
JsonDeserializationContext context) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren