예제 #1
0
        public AccountFullInfo UnBanAccount(string name)
        {
            Account account = AccountMgr.GetAccount(name);

            if (account == null)
            {
                return((AccountFullInfo)null);
            }
            RealmAccount loggedInAccount = ServerApp <WCell.RealmServer.RealmServer> .Instance.GetLoggedInAccount(name);

            if (loggedInAccount != null)
            {
                loggedInAccount.SetAccountActive(true, new DateTime?());
            }
            else
            {
                account.IsActive = true;
                account.SaveLater();
            }

            return(this.InitAccount(account));
        }
예제 #2
0
        public AccountFullInfo BanAccount(string name, DateTime until)
        {
            Account account = AccountMgr.GetAccount(name);

            if (account == null)
            {
                return(null);
            }
            RealmAccount loggedInAccount = ServerApp <RealmServer> .Instance.GetLoggedInAccount(name);

            if (loggedInAccount != null)
            {
                loggedInAccount.SetAccountActive(false, until);
            }
            else
            {
                account.IsActive    = false;
                account.StatusUntil = until;
                account.SaveLater();
            }

            return(InitAccount(account));
        }
예제 #3
0
        public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
        {
            Character chr    = trigger.Args.Target as Character;
            IUser     banner = trigger.Args.User;

            if (chr != null && object.ReferenceEquals((object)chr, (object)banner))
            {
                chr = chr.Target as Character;
            }
            if (chr == null || object.ReferenceEquals((object)chr, (object)banner))
            {
                trigger.Reply("Invalid Target.");
            }
            else if (banner != null && chr.Role >= banner.Role)
            {
                trigger.Reply("Cannot ban Users of higher or equal Rank.");
            }
            else
            {
                TimeSpan?nullable1 = trigger.Text.NextTimeSpan();
                DateTime?until;
                if (nullable1.HasValue)
                {
                    DateTime now       = DateTime.Now;
                    TimeSpan?nullable2 = nullable1;
                    until = nullable2.HasValue ? new DateTime?(now + nullable2.GetValueOrDefault()) : new DateTime?();
                }
                else
                {
                    until = new DateTime?();
                }

                string timeStr = until.HasValue ? "until " + (object)until : "(indefinitely)";
                trigger.Reply("Banning Account {0} ({1}) {2}...", (object)chr.Account.Name, (object)chr.Name,
                              (object)timeStr);
                ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((IMessage) new Message((Action)(() =>
                {
                    IContextHandler contextHandler = chr.ContextHandler;
                    RealmAccount account = chr.Account;
                    if (account == null || contextHandler == null)
                    {
                        trigger.Reply("Character logged off.");
                    }
                    else if (account.SetAccountActive(false, until))
                    {
                        contextHandler.AddMessage((Action)(() =>
                        {
                            if (chr.IsInWorld)
                            {
                                chr.Kick((INamed)banner, "Banned " + timeStr, 5);
                            }
                            trigger.Reply("Done.");
                        }));
                    }
                    else
                    {
                        trigger.Reply("Could not ban Account.");
                    }
                })));
            }
        }