Remove use of internal gson API

This commit is contained in:
md_5 2023-03-25 11:00:13 +11:00
parent 2ef5e7004b
commit 963854f8d5
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -3,8 +3,8 @@ package net.md_5.bungee.api;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.TypeAdapters;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonWriter;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -27,13 +27,26 @@ public class Favicon
@Override @Override
public void write(JsonWriter out, Favicon value) throws IOException public void write(JsonWriter out, Favicon value) throws IOException
{ {
TypeAdapters.STRING.write( out, value == null ? null : value.getEncoded() ); if ( value == null )
{
out.nullValue();
} else
{
out.value( value.getEncoded() );
}
} }
@Override @Override
public Favicon read(JsonReader in) throws IOException public Favicon read(JsonReader in) throws IOException
{ {
String enc = TypeAdapters.STRING.read( in ); JsonToken peek = in.peek();
if ( peek == JsonToken.NULL )
{
in.nextNull();
return null;
}
String enc = in.nextString();
return enc == null ? null : create( enc ); return enc == null ? null : create( enc );
} }
}; };