From 963854f8d5e4ef4ef4648f79a924406441fa2b3b Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 25 Mar 2023 11:00:13 +1100 Subject: [PATCH] Remove use of internal gson API --- .../java/net/md_5/bungee/api/Favicon.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/Favicon.java b/api/src/main/java/net/md_5/bungee/api/Favicon.java index 2884b5a5..53737be2 100644 --- a/api/src/main/java/net/md_5/bungee/api/Favicon.java +++ b/api/src/main/java/net/md_5/bungee/api/Favicon.java @@ -3,8 +3,8 @@ package net.md_5.bungee.api; import com.google.common.base.Preconditions; import com.google.common.io.BaseEncoding; import com.google.gson.TypeAdapter; -import com.google.gson.internal.bind.TypeAdapters; import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; @@ -27,13 +27,26 @@ public class Favicon @Override 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 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 ); } };