protected override void HandleValue(ServerContext context, ParserResult result)
        {
            PacketSender.SendGlobalMsg(result.Find(Message));

            if (Options.Chat.ShowAnnouncementBanners)
            {
                PacketSender.SendGameAnnouncement(result.Find(Message), Options.Chat.AnnouncementDisplayDuration);
            }
        }
Exemplo n.º 2
0
        protected override void HandleTarget(ServerContext context, ParserResult result, Client target)
        {
            if (target?.Entity == null)
            {
                Console.WriteLine($@"    {Strings.Player.offline}");

                return;
            }

            if (target.Name == null)
            {
                Console.WriteLine($@"    {Strings.Account.notfound}");

                return;
            }

            var power = result.Find(Power);

            DbInterface.SetPlayerPower(target.Name, power.AsUserRights());
            PacketSender.SendEntityDataToProximity(target.Entity);
            PacketSender.SendGlobalMsg(
                power != Access.None
                    ? Strings.Player.admin.ToString(target.Entity.Name)
                    : Strings.Player.deadmin.ToString(target.Entity.Name)
                );

            Console.WriteLine($@"    {Strings.Commandoutput.powerchanged.ToString(target.Entity.Name)}");
        }
Exemplo n.º 3
0
        protected override void HandleTarget(ServerContext context, ParserResult result, Client target)
        {
            if (target == null)
            {
                Console.WriteLine($@"    {Strings.Player.offline}");

                return;
            }

            var duration = result.Find(Duration);
            var ip       = result.Find(Ip);
            var reason   = result.Find(Reason) ?? "";

            // TODO: Refactor the global/console messages into ModeratorActionCommand
            HandleClient(context, target, duration, ip, reason);
        }
        protected override void HandleTarget(ServerContext context, ParserResult result, User target)
        {
            if (target == null)
            {
                Console.WriteLine($@"    {Strings.Account.notfound}");

                return;
            }

            if (target.Power == null)
            {
                throw new ArgumentNullException(nameof(target.Power));
            }

            var access = result.Find(Access);

            target.Power.Api = access;
            if (!access)
            {
                target.Power.ApiRoles = new Database.PlayerData.Security.ApiRoles();
            }

            target.Save();

            Console.WriteLine(
                access
                    ? $@"    {Strings.Commandoutput.apigranted.ToString( target.Name )}"
                    : $@"    {Strings.Commandoutput.apirevoked.ToString( target.Name )}"
                );
        }
Exemplo n.º 5
0
        protected override void HandleTarget(ServerContext context, ParserResult result, User target)
        {
            var power = result.Find(Power);

            if (DbInterface.SetPlayerPower(target, power.AsUserRights()))
            {
                Console.WriteLine($@"    {Strings.Commandoutput.powerchanged.ToString( target?.Name )}");
            }
        }
        protected override void Handle(TContext context, ParserResult result)
        {
            if (result.Find(Help))
            {
                return;
            }

            HandleValue(context, result);
        }
Exemplo n.º 7
0
        protected override void HandleTarget(ServerContext context, ParserResult result, User target)
        {
            if (target == null)
            {
                Console.WriteLine($@"    {Strings.Account.notfound.ToString(result.Find(Target))}");

                return;
            }

            Ban.Remove(target);
            Console.WriteLine($@"    {Strings.Account.unbanned.ToString(target.Name)}");
        }
        protected override void HandleTarget(ServerContext context, ParserResult result, User target)
        {
            if (target == null)
            {
                Console.WriteLine($@"    {Strings.Account.notfound}");

                return;
            }

            if (target.Power == null)
            {
                throw new ArgumentNullException(nameof(target.Power));
            }

            var role = result.Find(Role);

            if (!target.Power.Api)
            {
                Console.WriteLine(Strings.Commandoutput.apirolenotgranted.ToString(role, target.Name));

                return;
            }

            if (string.Equals("users.query", role, StringComparison.OrdinalIgnoreCase))
            {
                target.Power.ApiRoles.UserQuery = true;
            }
            else if (string.Equals("users.manage", role, StringComparison.OrdinalIgnoreCase))
            {
                if (target.Power.ApiRoles.UserQuery)
                {
                    target.Power.ApiRoles.UserManage = true;
                }
                else
                {
                    Console.WriteLine(Strings.Commandoutput.apiroleprereq.ToString(role, "users.query"));

                    return;
                }
            }
            else
            {
                //Role Not Found
                Console.WriteLine(Strings.Commandoutput.apirolenotfound.ToString(role));

                return;
            }

            target.Save();

            Console.WriteLine(Strings.Commandoutput.apirolegranted.ToString(target.Name, role));
        }
Exemplo n.º 9
0
        protected override void HandleValue(ServerContext context, ParserResult result)
        {
            var operation = result.Find(Operation);

            if (operation == Strings.Commands.Arguments.MetricsDisable)
            {
                Options.Instance.Metrics.Enable = false;
                Metrics.MetricsRoot.Instance.Disable();
                Options.SaveToDisk();
            }
            else if (operation == Strings.Commands.Arguments.MetricsEnable)
            {
                if (Metrics.MetricsRoot.Instance == null)
                {
                    Metrics.MetricsRoot.Init();
                }
                Options.Instance.Metrics.Enable = true;
                Options.SaveToDisk();
            }
            Console.WriteLine(Options.Instance.Metrics.Enable ? Strings.Commandoutput.metricsenabled.ToString() : Strings.Commandoutput.metricsdisabled.ToString());
        }
Exemplo n.º 10
0
        protected override void HandleValue(ServerContext context, ParserResult result)
        {
            var operation = result.Find(Operation);

            if (operation == Strings.Commands.Arguments.CpsLock)
            {
                Globals.CpsLock = true;
            }
            else if (operation == Strings.Commands.Arguments.CpsUnlock)
            {
                Globals.CpsLock = false;
            }

            //else if (operation == Strings.Commands.Arguments.CpsStatus)
            //{
            //    Console.WriteLine(Globals.CpsLock
            //        ? Strings.Commandoutput.cpslocked
            //        : Strings.Commandoutput.cpsunlocked);
            //}
            // TODO: Rethink what messages we want to display here. Confirmation of the change is ideal. To reuse code we effectively don't need to really handle status.
            Console.WriteLine(Globals.CpsLock ? Strings.Commandoutput.cpslocked : Strings.Commandoutput.cpsunlocked);
        }
Exemplo n.º 11
0
        protected override void HandleTarget(ServerContext context, ParserResult result, User target)
        {
            if (target == null)
            {
                Console.WriteLine($@"    {Strings.Account.notfound}");

                return;
            }

            if (target.Power == null)
            {
                throw new ArgumentNullException(nameof(target.Power));
            }

            var role = result.Find(Role);

            if (role == "users.query")
            {
                target.Power.ApiRoles.UserQuery  = false;
                target.Power.ApiRoles.UserManage = false;
            }
            else if (role == "users.manage")
            {
                target.Power.ApiRoles.UserManage = false;
            }
            else
            {
                //Role Not Found
                Console.WriteLine(Strings.Commandoutput.apirolenotfound.ToString(role));

                return;
            }

            DbInterface.SavePlayerDatabaseAsync();

            Console.WriteLine(Strings.Commandoutput.apirolerevoked.ToString(target.Name, role));
        }
Exemplo n.º 12
0
        protected override void HandleValue(ServerContext context, ParserResult result)
        {
            var target = FindTarget(context, result, result.Find(Target));

            HandleTarget(context, result, target);
        }
Exemplo n.º 13
0
 protected override void HandleValue(ServerContext context, ParserResult result)
 {
     PacketSender.SendGlobalMsg(result.Find(Message));
 }