Fix a concurrent exception

This commit is contained in:
libraryaddict 2016-06-28 06:05:24 +12:00
parent 7d80353abb
commit 56d7557bb0
2 changed files with 6 additions and 24 deletions

View File

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

View File

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