Exemple #1
0
        public void ExecuteCommand(string[] fullCmd, ICommandUser sender)
        {
            Contract.Requires(fullCmd != null);
            Contract.Requires(fullCmd.Length > 0);

            var cmd = fullCmd.Take(1).Single();

            if (string.IsNullOrWhiteSpace(cmd))
            {
                return;
            }

            var command = GetCommand(cmd);

            if (command == null)
            {
                sender.Respond("Unknown command: {0}".Interpolate(cmd));
                return;
            }

            if (command.RequiresSender && (sender == null || sender is ConsoleCommandUser))
            {
                sender.Respond("Command {0} requires a sender.".Interpolate(cmd));
                return;
            }

            var permission = command.RequiredPermission;

            if (sender != null && permission != null && permission != typeof(ConsolePermission) && !sender.HasPermission(permission))
            {
                sender.Respond("Command {0} requires permission {1}.".Interpolate(cmd, permission));
                return;
            }

            // Process all commands in a serial manner. Not asynchronously, though, as this would cause
            // problems with console cancellation.
            lock (_cmdLock)
            {
                try
                {
                    command.Execute(new CommandArguments(fullCmd.Skip(1)), sender);
                }
                catch (CommandArgumentException ex)
                {
                    sender.Respond("Argument error for command {0}: {1}".Interpolate(cmd, ex.Message));
                }
                catch (Exception ex)
                {
                    ExceptionManager.RegisterException(ex);
                    return;
                }
            }
        }
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var condensedOpCode = args.NextUInt16();
            var opCodes = OpCodeUtility.GetOpCodesForCondensedOpCode(condensedOpCode);

            if (opCodes.Count() == 0)
            {
                sender.Respond("No uncompressed opcodes found.");
                return;
            }

            sender.Respond("Found the following opcodes:");
            foreach (var uncompressedOpCode in opCodes)
                sender.Respond("{0} ({0:X})".Interpolate(uncompressedOpCode));
        }
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var condensedOpCode = args.NextUInt16();
            var opCodes         = OpCodeUtility.GetOpCodesForCondensedOpCode(condensedOpCode);

            if (opCodes.Count() == 0)
            {
                sender.Respond("No uncompressed opcodes found.");
                return;
            }

            sender.Respond("Found the following opcodes:");
            foreach (var uncompressedOpCode in opCodes)
            {
                sender.Respond("{0} ({0:X})".Interpolate(uncompressedOpCode));
            }
        }
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var opCode = args.NextUInt16();
            if (opCode == 0)
            {
                sender.Respond("Invalid opcode given.");
                return;
            }

            var jamClient = OpCodeUtility.GetJamClientOpCode(opCode);
            sender.Respond(jamClient != null ? "JAM client opcode: {0} ({0:X})".Interpolate(jamClient) :
                "Could not calculate JAM client opcode.");

            var jamClientConn = OpCodeUtility.GetJamClientConnectionOpCode(opCode);
            sender.Respond(jamClientConn != null ? "JAM client connection opcode: {0} ({0:X})".Interpolate(jamClientConn) :
                "Could not calculate JAM client connection opcode.");
        }
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var opCode = args.NextUInt16();
            if (opCode == 0)
            {
                sender.Respond("Invalid opcode given.");
                return;
            }

            var result = OpCodeUtility.CompressOpCode(opCode);
            if (result == null)
            {
                sender.Respond("Could not condense opcode.");
                return;
            }

            sender.Respond("Condensed opcode: {0}".Interpolate(result));
        }
Exemple #6
0
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var name     = args.NextString();
            var password = args.NextString();
            var email    = args.NextString();
            var box      = args.NextEnum <ClientBoxLevel>(ClientBoxLevel.Cataclysm);
            var locale   = args.NextEnum <ClientLocale>(ClientLocale.English);

            if (string.IsNullOrEmpty(name))
            {
                sender.Respond("No name given.");
                return;
            }

            if (name.Length < Constants.Accounts.MinNameLength || name.Length > Constants.Accounts.MaxNameLength)
            {
                sender.Respond("Name must be between {0} and {1} characters long.".Interpolate(Constants.Accounts.MinNameLength,
                                                                                               Constants.Accounts.MaxNameLength));
                return;
            }

            if (string.IsNullOrEmpty(password))
            {
                sender.Respond("No password given.");
                return;
            }

            if (password.Length < Constants.Accounts.MinPasswordLength || password.Length > Constants.Accounts.MaxPasswordLength)
            {
                sender.Respond("Password must be between {0} and {1} characters long.".Interpolate(Constants.Accounts.MinPasswordLength,
                                                                                                   Constants.Accounts.MaxPasswordLength));
                return;
            }

            if (string.IsNullOrEmpty(email))
            {
                sender.Respond("No email given.");
                return;
            }

            AccountManager.Instance.PostAsync(x => x.CreateAccount(name, password, email, box, locale));
        }
Exemple #7
0
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var opCode = args.NextUInt16();

            if (opCode == 0)
            {
                sender.Respond("Invalid opcode given.");
                return;
            }

            var jamClient = OpCodeUtility.GetJamClientOpCode(opCode);

            sender.Respond(jamClient != null ? "JAM client opcode: {0} ({0:X})".Interpolate(jamClient) :
                           "Could not calculate JAM client opcode.");

            var jamClientConn = OpCodeUtility.GetJamClientConnectionOpCode(opCode);

            sender.Respond(jamClientConn != null ? "JAM client connection opcode: {0} ({0:X})".Interpolate(jamClientConn) :
                           "Could not calculate JAM client connection opcode.");
        }
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var fileName = args.NextString();
            if (string.IsNullOrEmpty(fileName))
            {
                sender.Respond("No file name given.");
                return;
            }

            AccountApplication.Instance.AccountDbContext.PostAsync(x => x.Schema.Export(fileName));
        }
Exemple #9
0
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var opCode = args.NextUInt16();

            if (opCode == 0)
            {
                sender.Respond("Invalid opcode given.");
                return;
            }

            var result = OpCodeUtility.CompressOpCode(opCode);

            if (result == null)
            {
                sender.Respond("Could not condense opcode.");
                return;
            }

            sender.Respond("Condensed opcode: {0}".Interpolate(result));
        }
Exemple #10
0
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var fileName = args.NextString();

            if (string.IsNullOrEmpty(fileName))
            {
                sender.Respond("No file name given.");
                return;
            }

            AccountApplication.Instance.AccountDbContext.PostAsync(x => x.Schema.Export(fileName));
        }