From cbe1a09ded4ad70a3f69066ca7d6189e55224744 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 6 Aug 2018 01:18:01 +1200 Subject: [PATCH] Support ChatComponent --- .../disguise/utilities/ReflectionManager.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java index f6016275..1d720a0f 100644 --- a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java +++ b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java @@ -881,9 +881,24 @@ public class ReflectionManager { if (value instanceof Optional) { Optional opt = (Optional) value; - serializer = Registry.get((opt.isPresent() ? - getNmsClass("IBlockData").isInstance(opt.get()) ? getNmsClass("IBlockData") : opt.get().getClass() : - UUID.class), true); + if (opt.isPresent()) { + Object val = opt.get(); + Class cl; + Class iBlockData = getNmsClass("IBlockData"); + Class iChat = getNmsClass("IChatBaseComponent"); + + if (iBlockData.isInstance(val)) { + cl = iBlockData; + } else if (iChat.isInstance(val)) { + cl = iChat; + } else { + cl = val.getClass(); + } + + serializer = Registry.get(cl, true); + } else { + serializer = Registry.get(UUID.class, true); + } } else { serializer = Registry.get(getNmsClass("ParticleParam").isInstance(value) ? getNmsClass("ParticleParam") : value.getClass());