Пример #1
0
        private void handleClanRanks(Player player, Packet packet)
        {
            int  rank = packet.readByteA();
            long name = packet.readLong();

            if (name < 0 || (rank < 0 || rank > 6))
            {
                return;
            }
            Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());

            if (clan != null)
            {
                ClanUser user = clan.getUserByName(Misc.longToPlayerName(name));
                if (user != null)
                {
                    user.setClanRights((Clan.ClanRank)rank);
                    Server.getClanManager().updateClan(clan);
                }
                Clan.ClanRank userExists;
                if (clan.getUsersWithRank().TryGetValue(Misc.longToPlayerName(name), out userExists))
                {
                    clan.getUsersWithRank()[Misc.longToPlayerName(name)] = (Clan.ClanRank)rank;  //Exists already, so altar.
                }
                else
                {
                    clan.getUsersWithRank().Add(Misc.longToPlayerName(name), (Clan.ClanRank)rank); //Not existed yet. so add
                }
            }
        }