From 75fb4f2e5352be971549681d688056c9e084c532 Mon Sep 17 00:00:00 2001 From: NavidK0 Date: Mon, 14 Mar 2016 21:53:25 -0400 Subject: [PATCH] Fixed "Thrown Potion # has no item!?" --- src/main/java/me/libraryaddict/disguise/LibsDisguises.java | 1 + .../libraryaddict/disguise/utilities/PacketsManager.java | 7 +++---- .../disguise/utilities/ReflectionManager.java | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java index 6fdec2ed..8158e9b4 100644 --- a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java @@ -46,6 +46,7 @@ import org.bukkit.plugin.java.JavaPlugin; import java.io.IOException; import java.lang.reflect.Field; + public class LibsDisguises extends JavaPlugin { private static LibsDisguises instance; diff --git a/src/main/java/me/libraryaddict/disguise/utilities/PacketsManager.java b/src/main/java/me/libraryaddict/disguise/utilities/PacketsManager.java index d7200ec2..799b027b 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/PacketsManager.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/PacketsManager.java @@ -203,7 +203,6 @@ public class PacketsManager { mods.write(4, yaw); mods.write(5, pitch); } else if (disguise.getType().isPlayer()) { - //TODO: Make player disguises visible again PlayerDisguise playerDisguise = (PlayerDisguise) disguise; String name = playerDisguise.getSkin() != null ? playerDisguise.getSkin() : playerDisguise.getName(); int entityId = disguisedEntity.getEntityId(); @@ -521,13 +520,13 @@ public class PacketsManager { if (event.isCancelled()) { return; } + if (event.isAsync()) { + return; + } event.setPacket(event.getPacket().deepClone()); StructureModifier mods = event.getPacket().getModifier(); Player observer = event.getPlayer(); if (event.getPacketType() == Server.NAMED_SOUND_EFFECT) { - if (event.isAsync()) { - return; - } Object soundEffect = mods.read(0); SoundType soundType = null; Location soundLoc = new Location(observer.getWorld(), ((Integer) mods.read(2)) / 8D, diff --git a/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java b/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java index 1ce2dd4e..f68f57e3 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java @@ -12,6 +12,7 @@ import org.apache.commons.lang3.tuple.Pair; import org.bukkit.Art; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.entity.Entity; @@ -104,6 +105,10 @@ public class ReflectionManager { case "EnderPearl": entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), getNmsClass("EntityLiving")).newInstance(world, createEntityInstance("Cow")); break; + case "Potion": + entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), Double.TYPE, Double.TYPE, Double.TYPE, getNmsClass("ItemStack")) + .newInstance(world, 0d, 0d, 0d, getNmsItem(new ItemStack(Material.SPLASH_POTION))); + break; default: entityObject = entityClass.getDeclaredConstructor(getNmsClass("World")).newInstance(world); break;