public void hidePlayer(Player player, boolean hide) {
        PlayerConnection playerConnection;

        //EntityPlayer handle = (EntityPlayer) player;
        EntityPlayer handle = ((CraftPlayer)player).getHandle();
        playerConnection = handle.playerConnection;

        if(playerConnection != null) {
            if (hide) {
                handle.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{handle}));

                for (Player all : Bukkit.getOnlinePlayers()) {
                    all.hidePlayer(player);
                }

            }
            else {
                handle.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{handle}));

                for (Player all : Bukkit.getOnlinePlayers()) {
                    all.showPlayer(player);
                }

            }
        }

    }