Пример #1
0
        public void HandleCommand(Client client, string alias, string[] arguments)
        {
            var command = FindByName(alias) ?? FindByAlias(alias);
            if (command == null)
            {
                client.SendServerMessage($@"Invalid command ""{alias}"".");
                return;
            }

            if(command.LogCommand && !client.Permissions.HasFlag(PermissionFlags.UnVerified))
                Logger.LogCommandMessage(client.Name, $"/{alias} {string.Join(" ", arguments)}");

            if (command.Permissions == PermissionFlags.None)
            {
                client.SendServerMessage($@"Command is disabled!");
                return;
            }

            if ((client.Permissions & command.Permissions) == PermissionFlags.None)
            {
                client.SendServerMessage($@"You have not the permission to use this command!");
                return;
            }

            command.Handle(client, alias, arguments);
        }
Пример #2
0
        public override void Handle(Client client, string alias, string[] arguments)
        {
            if (arguments.Length >= 2)
            {
                var clientName = arguments[0];
                var permissions = arguments.Skip(1).Where(arg => arg != "," || arg != "|").ToArray();

                var cClient = GetClient(clientName);
                if (cClient == null)
                {
                    client.SendServerMessage($"Player {clientName} not found.");
                    return;
                }

                var flags = new List<PermissionFlags>();
                foreach (var permission in permissions)
                {
                    PermissionFlags flag;
                    if (Enum.TryParse(permission, out flag))
                        flags.Add(flag);
                    else
                        client.SendServerMessage($"Permission {permission} not found.");
                }

                client.Permissions = PermissionFlags.None;
                foreach (var flag in flags)
                    client.Permissions |= flag;

                client.SendServerMessage($"Changed {clientName} permissions!");
            }
            else
                client.SendServerMessage($"Invalid arguments given.");
        }
Пример #3
0
 public override void Handle(Client client, string alias, string[] arguments)
 {
     if (arguments.Length == 1)
         client.SendServerMessage(client.RegisterOrLogIn(arguments[0]) ? $"Succesfully logged in!" : $"Wrong password!");
     else
         client.SendServerMessage($"Invalid arguments given.");
 }
Пример #4
0
 public override void Handle(Client client, string alias, string[] arguments)
 {
     if (arguments.Length == 2)
         client.SendServerMessage(client.ChangePassword(arguments[0], arguments[1]) ? $"Succesfully changed password!" : $"Wrong old password!");
     else
         client.SendServerMessage($"Invalid arguments given.");
 }
Пример #5
0
 public override void Handle(Client client, string alias, string[] arguments)
 {
     if (arguments.Length == 1)
     {
         var channelName = arguments[0].ToLower();
         var channel = ChatChannelManager.FindByAlias(channelName);
         client.SendServerMessage(channel != null ? $"{channel.Name}: {channel.Description}" : $"Channel '{channelName}' not found!");
     }
     else
         client.SendServerMessage($"Invalid arguments given.");
 }
Пример #6
0
 public override void Handle(Client client, string alias, string[] arguments)
 {
     if (arguments.Length == 1)
     {
         World.Location = arguments[0];
         World.UseLocation = true;
         client.SendServerMessage($"Set Location to {World.Location}!");
         client.SendServerMessage("Enabled Location!");
     }
     else
         client.SendServerMessage($"Invalid arguments given.");
 }
 public override void Handle(Client client, string alias, string[] arguments)
 {
     if (arguments.Length == 1)
     {
         var channelName = arguments[0].ToLower();
         var channel = ChatChannelManager.FindByAlias(channelName);
         if(channel != null)
             client.SendServerMessage(channel.Subscribe(client) ? $"Changed chat channel to {channel.Name}!" : $"Failed to change chat channel to {channel.Name}!");
         else
             client.SendServerMessage($"Channel '{channelName}' not found!");
     }
     else
         client.SendServerMessage($"Invalid arguments given.");
 }
Пример #8
0
 public override void Handle(Client client, string alias, string[] arguments)
 {
     if (arguments.Length == 1)
     {
         Weather weather;
         if (Enum.TryParse(arguments[0], true, out weather))
         {
             World.Weather = weather;
             client.SendServerMessage($"Set Weather to {weather}!");
         }
         else
             client.SendServerMessage($"Weather '{weather}' not found!");
     }
     else
         client.SendServerMessage($"Invalid arguments given.");
 }
Пример #9
0
 public override void Handle(Client client, string alias, string[] arguments)
 {
     if (arguments.Length == 1)
     {
         Season season;
         if (Enum.TryParse(arguments[0], true, out season))
         {
             World.Season = season;
             client.SendServerMessage($"Set Season to {season}!");
         }
         else
             client.SendServerMessage($"Season '{season}' not found!");
     }
     else
         client.SendServerMessage($"Invalid arguments given.");
 }
Пример #10
0
        public override void Handle(Client client, string alias, string[] arguments)
        {
            if (arguments.Length >= 1)
            {
                var clientName = arguments[0];
                var cClient = GetClient(clientName);
                if (cClient == null)
                {
                    client.SendServerMessage($"Player {clientName} not found!");
                    return;
                }

                var reason = arguments.Length > 1 ? arguments[1] : "";
                cClient.Kick(reason);
            }
            else
                client.SendServerMessage($"Invalid arguments given.");
        }
Пример #11
0
        public override void Handle(Client client, string alias, string[] arguments)
        {
            if (arguments.Length == 1)
            {
                if (arguments[0].ToLower() == "real")
                {
                    World.UseRealTime = !World.UseRealTime;
                    client.SendServerMessage(World.UseRealTime ? "Enabled Real Time!" : "Disabled Real Time!");
                    return;
                }
                if (arguments[0].ToLower() == "daycycle")
                {
                    World.DoDayCycle = !World.DoDayCycle;
                    client.SendServerMessage(World.DoDayCycle ? "Enabled Day Cycle!" : "Disabled Day Cycle!");
                    return;
                }

                TimeSpan time;
                if (TimeSpan.TryParseExact(arguments[0], "HH\\:mm\\:ss", null, out time))
                {
                    World.CurrentTime = time;
                    World.UseRealTime = false;
                    client.SendServerMessage($"Set time to {time}!");
                    client.SendServerMessage("Disabled Real Time!");
                }
                else
                    client.SendServerMessage("Invalid time!");
            }
            else
                client.SendServerMessage($"Invalid arguments given.");
        }
Пример #12
0
        private void HelpPage(Client client, int page)
        {
            const int perPage = 5;
            var numPages = (int) Math.Floor((double) CommandManager.Commands.Count / perPage);
            if ((CommandManager.Commands.Count % perPage) > 0)
                numPages++;

            if (page < 1 || page > numPages)
                page = 1;

            var startingIndex = (page - 1) * perPage;
            client.SendServerMessage($"--Help page {page} of {numPages}--");
            for (var i = 0; i < perPage; i++)
            {
                var index = startingIndex + i;
                if (index > CommandManager.Commands.Count - 1)
                    break;
                
                var command = CommandManager.Commands[index];
                client.SendServerMessage($"/{command.Name} - {command.Description}");
            }
        }
Пример #13
0
        public override void Handle(Client client, string alias, string[] arguments)
        {
            client.SendServerMessage($"Command not implemented.");
            return;

            if (arguments.Length == 1)
            {
                var clientName = arguments[0];
                var cClient = GetClient(clientName);
                if (cClient == null)
                {
                    client.SendServerMessage($"Player {clientName} not found!");
                    return;
                }

            }
            else
                client.SendServerMessage($"Invalid arguments given.");



            /*
            if (!MutedPlayers.ContainsKey(id))
                MutedPlayers.Add(id, new List<int>());

            var muteId = Server.GetClientId(muteName);
            if (id == muteId)
                return MuteStatus.MutedYourself;

            if (muteId != -1)
            {
                MutedPlayers[id].Add(muteId);
                return MuteStatus.Completed;
            }

            return MuteStatus.ClientNotFound;
            */
        }
Пример #14
0
 public override void Help(Client client, string alias) { client.SendServerMessage($"Correct usage is /{alias} <permission permission permission>"); }
Пример #15
0
 public override void Help(Client client, string alias) { client.SendServerMessage($"Correct usage is /{alias} <Time[HH:mm:ss]/Real>"); }
Пример #16
0
 public override void Help(Client client, string alias){ client.SendServerMessage($"Correct usage is /{alias} <PlayerName> [Reason]"); }
Пример #17
0
 public virtual void Help(Client client, string alias) { client.SendServerMessage($@"Command ""{alias}"" is not functional!"); }
Пример #18
0
 public override void Help(Client client, string alias){ client.SendServerMessage($"Correct usage is /{alias} <global/local/'custom'>"); }
Пример #19
0
 public override void Help(Client client, string alias) { client.SendServerMessage($"Correct usage is /{alias} <page#/command> [command arguments]"); }
Пример #20
0
 public override void Help(Client client, string alias) { client.SendServerMessage($"Correct usage is /{alias} <Weather>"); }
Пример #21
0
 public override void Help(Client client, string alias){ client.SendServerMessage($"Correct usage is /{alias} <OldPassword> <NewPassword>"); }