From 56d7557bb0d19ee11375a99f6b47f345d829878a Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 28 Jun 2016 06:05:24 +1200 Subject: [PATCH] Fix a concurrent exception --- .../disguise/utilities/PacketsManager.java | 10 ++++++---- .../disguise/utilities/ReflectionManager.java | 20 ------------------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/me/libraryaddict/disguise/utilities/PacketsManager.java b/src/me/libraryaddict/disguise/utilities/PacketsManager.java index a11fb690..d550ec99 100644 --- a/src/me/libraryaddict/disguise/utilities/PacketsManager.java +++ b/src/me/libraryaddict/disguise/utilities/PacketsManager.java @@ -237,16 +237,18 @@ public class PacketsManager DisguiseUtilities.getAddedByPlugins().remove(name); } - Object entityPlayer = ReflectionManager.createEntityPlayer(observer.getWorld(), gameProfile); - spawnPackets[0] = ProtocolLibrary.getProtocolManager() - .createPacketConstructor(Server.NAMED_ENTITY_SPAWN, entityPlayer).createPacket(entityPlayer); + spawnPackets[0] = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN); - // Write spawn packet in order spawnPackets[0].getIntegers().write(0, entityId); // Id + spawnPackets[0].getModifier().write(1, gameProfile.getUUID()); + spawnPackets[0].getDoubles().write(0, loc.getX()); spawnPackets[0].getDoubles().write(1, loc.getY()); spawnPackets[0].getDoubles().write(2, loc.getZ()); + spawnPackets[0].getBytes().write(0, ((byte) (int) (loc.getYaw() * 256.0F / 360.0F))); + spawnPackets[0].getBytes().write(1, ((byte) (int) (loc.getPitch() * 256.0F / 360.0F))); + spawnPackets[0].getDataWatcherModifier().write(0, createDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity), disguise.getWatcher())); // watcher, // duh diff --git a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java index ce92ebe0..8c4066c3 100644 --- a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java +++ b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java @@ -32,13 +32,11 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObje import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.comphenix.protocol.wrappers.WrappedWatchableObject; import com.google.common.base.Optional; -import com.mojang.authlib.GameProfile; import me.libraryaddict.disguise.disguisetypes.DisguiseType; public class ReflectionManager { - private static final String bukkitVersion = Bukkit.getServer().getClass().getName().split("\\.")[3]; private static final Class craftItemClass; private static Method damageAndIdleSoundMethod; @@ -1018,22 +1016,4 @@ public class ReflectionManager return null; } - public static Object createEntityPlayer(World w, WrappedGameProfile profile) - { - Object entityPlayer = null; - - try - { - entityPlayer = getNmsConstructor("EntityPlayer", getNmsClass("MinecraftServer"), getNmsClass("WorldServer"), - GameProfile.class, getNmsClass("PlayerInteractManager")).newInstance(getMinecraftServer(), getWorldServer(w), - profile.getHandle(), getPlayerInteractManager(w)); - } - catch (InstantiationException | IllegalAccessException | InvocationTargetException e) - { - e.printStackTrace(); - } - - return entityPlayer; - } - }