Added chat serializing which should clear a rare issue
This commit is contained in:
parent
0393613a67
commit
9e7f332788
@ -861,6 +861,7 @@ public class DisguiseUtilities {
|
|||||||
gsonBuilder.registerTypeAdapter(WrappedBlockData.class, new SerializerWrappedBlockData());
|
gsonBuilder.registerTypeAdapter(WrappedBlockData.class, new SerializerWrappedBlockData());
|
||||||
gsonBuilder.registerTypeAdapter(Disguise.class, new SerializerDisguise());
|
gsonBuilder.registerTypeAdapter(Disguise.class, new SerializerDisguise());
|
||||||
gsonBuilder.registerTypeAdapter(FlagWatcher.class, new SerializerFlagWatcher());
|
gsonBuilder.registerTypeAdapter(FlagWatcher.class, new SerializerFlagWatcher());
|
||||||
|
gsonBuilder.registerTypeAdapter(FlagWatcher.class, new SerializerChatComponent());
|
||||||
gsonBuilder.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer());
|
gsonBuilder.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer());
|
||||||
gsonBuilder.registerTypeAdapter(ItemStack.class, new SerializerItemStack());
|
gsonBuilder.registerTypeAdapter(ItemStack.class, new SerializerItemStack());
|
||||||
|
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.json;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
|
import com.google.gson.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 27/11/2018.
|
||||||
|
*/
|
||||||
|
public class SerializerChatComponent implements JsonDeserializer<WrappedChatComponent>,
|
||||||
|
JsonSerializer<WrappedChatComponent> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WrappedChatComponent deserialize(JsonElement json, Type typeOfT,
|
||||||
|
JsonDeserializationContext context) throws JsonParseException {
|
||||||
|
if (json.isJsonPrimitive()) {
|
||||||
|
return WrappedChatComponent.fromJson(json.getAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonElement serialize(WrappedChatComponent src, Type typeOfSrc, JsonSerializationContext context) {
|
||||||
|
return context.serialize(src.getJson());
|
||||||
|
}
|
||||||
|
}
|
@ -82,6 +82,7 @@ public class SerializerFlagWatcher implements JsonDeserializer<FlagWatcher>, Jso
|
|||||||
JsonObject obj = (JsonObject) context.serialize(src);
|
JsonObject obj = (JsonObject) context.serialize(src);
|
||||||
|
|
||||||
obj.addProperty("flagType", src.getClass().getName());
|
obj.addProperty("flagType", src.getClass().getName());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Method method = FlagWatcher.class.getDeclaredMethod("getDisguise");
|
Method method = FlagWatcher.class.getDeclaredMethod("getDisguise");
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user