Add EntityPose as deserializable

This commit is contained in:
libraryaddict 2021-02-26 09:57:43 +13:00
parent 35ad450bc3
commit 93fdb30227
2 changed files with 4 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import com.google.gson.internal.LinkedTreeMap;
import me.libraryaddict.disguise.disguisetypes.*; import me.libraryaddict.disguise.disguisetypes.*;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.params.ParamInfoManager; import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
import me.libraryaddict.disguise.utilities.params.types.ParamInfoEnum;
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoParticle; import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoParticle;
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException; import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -73,6 +74,8 @@ public class SerializerFlagWatcher implements JsonDeserializer<FlagWatcher>, Jso
} else if (entry.getValue() instanceof String) { } else if (entry.getValue() instanceof String) {
if (index.getDefault() instanceof WrappedParticle) { if (index.getDefault() instanceof WrappedParticle) {
entry.setValue(((ParamInfoParticle) ParamInfoManager.getParamInfo(WrappedParticle.class)).fromString((String) entry.getValue())); entry.setValue(((ParamInfoParticle) ParamInfoManager.getParamInfo(WrappedParticle.class)).fromString((String) entry.getValue()));
} else if (index.getDefault() instanceof EntityPose) {
entry.setValue(((ParamInfoEnum) ParamInfoManager.getParamInfo(EntityPose.class)).fromString((String) entry.getValue()));
} }
} else if (entry.getValue() instanceof LinkedTreeMap) { // If it's deserialized incorrectly as a map } else if (entry.getValue() instanceof LinkedTreeMap) { // If it's deserialized incorrectly as a map
// If the default value is not VillagerData // If the default value is not VillagerData

View File

@ -26,7 +26,7 @@ public class ParamInfoEnum extends ParamInfo {
} }
@Override @Override
protected Object fromString(String string) throws DisguiseParseException { public Object fromString(String string) throws DisguiseParseException {
string = string.replace("_", ""); string = string.replace("_", "");
for (Map.Entry<String, Object> entry : getValues().entrySet()) { for (Map.Entry<String, Object> entry : getValues().entrySet()) {