From 182c6a325944357e4ef60877da90dbbaa8c04158 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 23 Jun 2016 21:11:50 +1200 Subject: [PATCH] Fix up datawatchers --- config.yml | 1 + .../disguise/utilities/ReflectionManager.java | 29 ++----------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/config.yml b/config.yml index 2e89e3a0..8006c8d1 100644 --- a/config.yml +++ b/config.yml @@ -74,6 +74,7 @@ DisguiseCloneSize: 3 # This I don't really recommend turning on as it can make a memory leak.. # These disguises, as normal will not persist after a server restart. # There is also no EntityDeath option as entities do not revive after death. +# The EntityDespawn option is when you leave the chunk the entity is and the chunk is unloaded KeepDisguises: EntityDespawn: false PlayerDeath: false diff --git a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java index 40a89617..ce92ebe0 100644 --- a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java +++ b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java @@ -25,7 +25,6 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; -import com.comphenix.protocol.wrappers.BlockPosition; import com.comphenix.protocol.wrappers.MinecraftKey; import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry; import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer; @@ -927,7 +926,9 @@ public class ReflectionManager if (value instanceof Optional) { - serializer = Registry.get(((Optional) value).get().getClass(), true); + Optional opt = (Optional) value; + + serializer = Registry.get((opt.isPresent() ? opt.get().getClass() : UUID.class), true); } else { @@ -952,30 +953,6 @@ public class ReflectionManager public static WrappedWatchableObject createWatchable(int index, Object obj) { - if (obj instanceof Optional) - { - Object value = ((Optional) obj).get(); - - if (value instanceof BlockPosition) - { - value = BlockPosition.getConverter().getSpecific(value); - - if (value == null) - return null; - - obj = Optional.of(value); - } - else if (value instanceof ItemStack) - { - value = ReflectionManager.getNmsItem((ItemStack) value); - - if (value == null) - return null; - - obj = Optional.of(value); - } - } - return new WrappedWatchableObject(createDataWatcherItem(index, obj)); }