Fixed #354
This commit is contained in:
parent
3d4ee8a020
commit
4df20dbd4c
@ -171,11 +171,10 @@ public class FlagWatcher {
|
||||
if (newHealth > 0 && hasDied) {
|
||||
hasDied = false;
|
||||
|
||||
Bukkit.getScheduler()
|
||||
.scheduleSyncDelayedTask(LibsDisguises.getInstance(), () -> {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), () -> {
|
||||
try {
|
||||
DisguiseUtilities.sendSelfDisguise((Player) getDisguise().getEntity(),
|
||||
getDisguise());
|
||||
DisguiseUtilities
|
||||
.sendSelfDisguise((Player) getDisguise().getEntity(), getDisguise());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
@ -1,10 +1,18 @@
|
||||
package me.libraryaddict.disguise.utilities.json;
|
||||
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ArrowWatcher;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import sun.reflect.generics.tree.BaseType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@ -15,14 +23,28 @@ import java.util.Map;
|
||||
/**
|
||||
* Created by libraryaddict on 1/06/2017.
|
||||
*/
|
||||
public class SerializerFlagWatcher implements JsonDeserializer<FlagWatcher>, JsonSerializer<FlagWatcher>, InstanceCreator<FlagWatcher> {
|
||||
public class SerializerFlagWatcher implements JsonDeserializer<FlagWatcher>, JsonSerializer<FlagWatcher>,
|
||||
InstanceCreator<FlagWatcher> {
|
||||
private Gson gson;
|
||||
|
||||
public SerializerFlagWatcher() {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gsonBuilder.registerTypeAdapter(MetaIndex.class, new SerializerMetaIndex());
|
||||
gsonBuilder.registerTypeAdapter(WrappedGameProfile.class, new SerializerGameProfile());
|
||||
gsonBuilder.registerTypeAdapter(WrappedBlockData.class, new SerializerWrappedBlockData());
|
||||
gsonBuilder.registerTypeAdapter(WrappedChatComponent.class, new SerializerChatComponent());
|
||||
gsonBuilder.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer());
|
||||
gsonBuilder.registerTypeAdapter(ItemStack.class, new SerializerItemStack());
|
||||
|
||||
gson = gsonBuilder.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlagWatcher deserialize(JsonElement json, Type typeOfT,
|
||||
JsonDeserializationContext context) throws JsonParseException {
|
||||
try {
|
||||
FlagWatcher watcher = context.deserialize(json,
|
||||
Class.forName(((JsonObject) json).get("flagType").getAsString()));
|
||||
FlagWatcher watcher = (FlagWatcher) gson
|
||||
.fromJson(json, Class.forName(((JsonObject) json).get("flagType").getAsString()));
|
||||
|
||||
DisguiseType entity = DisguiseType.valueOf(((JsonObject) json).get("entityType").getAsString());
|
||||
|
||||
@ -79,7 +101,7 @@ public class SerializerFlagWatcher implements JsonDeserializer<FlagWatcher>, Jso
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(FlagWatcher src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject obj = (JsonObject) context.serialize(src);
|
||||
JsonObject obj = (JsonObject) gson.toJsonTree(src);
|
||||
|
||||
obj.addProperty("flagType", src.getClass().getName());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user