Beispiel #1
0
 private void addChannel(Clan clan)
 {
     lock (clans) {
         clans.Add(clan);
     }
 }
Beispiel #2
0
 public ClanUser(Player p, Clan clan)
 {
     this.p      = p;
     this.clan   = clan;
     this.rights = Clan.ClanRank.NO_RANK;
 }
Beispiel #3
0
        public void enterChannel(Player p, string owner)
        {
            if (p.getClan() != null)
            {
                return;
            }
            p.getPackets().sendMessage("Attempting to join channel...:clan:");
            if (owner.Equals(p.getLoginDetails().getUsername()))
            {
                Clan newClan = new Clan(p, owner, owner);
                addChannel(newClan);
            }
            Event enterChannelEvent = new Event(700);

            enterChannelEvent.setAction(() => {
                enterChannelEvent.stop();
                foreach (Clan c in clans)
                {
                    if (c != null)
                    {
                        if (c.getClanOwner().Equals(owner))
                        {
                            if (c.getUserList().Count >= 100)
                            {
                                p.getPackets().sendMessage("The channel is full.");
                                return;
                            }
                            if (!owner.Equals(p.getLoginDetails().getUsername()))
                            {
                                if (c.getEnterRights() != Clan.ClanRank.NO_RANK)
                                {
                                    if (c.getEnterRights() == Clan.ClanRank.FRIEND)
                                    {
                                        if (!c.isFriendOfOwner(p) && !c.userHasRank(p.getLoginDetails().getUsername()))
                                        {
                                            p.getPackets().sendMessage("You do not have a high enough rank to enter this clan chat.");
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        bool canEnter = true;
                                        foreach (KeyValuePair <string, Clan.ClanRank> u in c.getUsersWithRank())
                                        {
                                            if (u.Key.Equals(p.getLoginDetails().getUsername()))
                                            {
                                                if (u.Value < c.getEnterRights())
                                                {
                                                    canEnter = false;
                                                    break;
                                                }
                                            }
                                        }
                                        if (!canEnter)
                                        {
                                            p.getPackets().sendMessage("You do not have a high enough rank to enter this clan chat.");
                                            return;
                                        }
                                    }
                                }
                            }
                            c.addUser(p);
                            updateClan(c);
                            p.getPackets().sendMessage("Now talking in channel : " + misc.formatPlayerNameForDisplay(c.getClanName() + ":clan:"));
                            p.getPackets().sendMessage("To talk, start each line of chat with the / symbol. :clan:");
                            return;
                        }
                    }
                }
                p.getPackets().sendMessage("The channel you tried to join does not exist. :clan:");
            });
            Server.registerEvent(enterChannelEvent);
        }