コード例 #1
0
        public string Execute(ICharacter character, int?minutes = null)
        {
            if (character is null)
            {
                throw new Exception("The character name is not provided");
            }

            minutes ??= DefaultDuration;
            if (minutes < 0)
            {
                throw new Exception($"Minutes must be in 0-{int.MaxValue} range");
            }

            if (minutes.Value == 0)
            {
                // un-mute
                if (ServerPlayerMuteSystem.Unmute(character))
                {
                    return($"{character.Name} successfully un-muted");
                }

                return($"{character.Name} was not muted so no changes are done");
            }

            if (character == this.ExecutionContextCurrentCharacter)
            {
                throw new Exception("You cannot mute yourself");
            }

            ServerPlayerMuteSystem.Mute(character, minutes.Value);
            return(string.Format("{0} successfully muted on the server for {1}",
                                 character.Name,
                                 ClientTimeFormatHelper.FormatTimeDuration(minutes.Value * 60.0)));
        }
コード例 #2
0
        public string Execute(
            [CustomSuggestions(nameof(GetCharacterNameSuggestions))]
            string playerName)
        {
            var character = Server.Characters.GetPlayerCharacter(playerName);

            if (character == null)
            {
                throw new Exception("The character name is not provided");
            }

            if (ServerPlayerMuteSystem.Unmute(character))
            {
                return($"{character.Name} successfully un-muted");
            }

            return($"{character.Name} was not muted so no changes are done");
        }