Fix up datawatchers

This commit is contained in:
libraryaddict 2016-06-23 21:11:50 +12:00
parent bf3c11878a
commit 182c6a3259
2 changed files with 4 additions and 26 deletions

@ -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

@ -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));
}