public string Execute(ICharacter character, int minutes = 30, string kickMessageInQuotes = null)
        {
            if (character is null)
            {
                throw new Exception("The character name is not provided");
            }

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

            if (minutes < 1 ||
                minutes > 10000)
            {
                throw new Exception("Minutes must be in 1-10000 range");
            }

            ServerPlayerAccessSystem.Kick(character, minutes, kickMessageInQuotes);

            var result = $"{character.Name} successfully kicked from the server for {minutes} minutes";

            if (!string.IsNullOrEmpty(kickMessageInQuotes))
            {
                result += " with a following message:"
                          + Environment.NewLine
                          + kickMessageInQuotes;
            }

            return(result);
        }
Example #2
0
        public string Execute(
            [CustomSuggestions(nameof(GetClanTagSuggestions))]
            string clanTag)
        {
            var faction = FactionSystem.ServerGetFactionByClanTag(clanTag);

            var bannedCount = 0;

            foreach (var playerName in FactionSystem.ServerGetFactionMemberNames(faction))
            {
                var character = Server.Characters.GetPlayerCharacter(playerName);
                if (character == this.ExecutionContextCurrentCharacter)
                {
                    continue;
                }

                if (ServerPlayerAccessSystem.SetBlackListEntry(playerName, isEnabled: true))
                {
                    bannedCount++;
                }
            }

            if (bannedCount == 0)
            {
                return($"No need to add anyone from the faction [{clanTag}] to the blacklist (already added)");
            }

            return($"{bannedCount} player(s) of the faction [{clanTag}] were added to the blacklist");
        }
        public string Execute(
            [CustomSuggestions(nameof(GetCharacterNameSuggestions))]
            string playerName)
        {
            if (ServerPlayerAccessSystem.SetBlackListEntry(playerName, isEnabled: true))
            {
                return($"{playerName} added to the blacklist");
            }

            return($"{playerName} is already in the blacklist");
        }
        public string Execute(
            [CustomSuggestions(nameof(GetCharacterNameSuggestions))]
            string playerName)
        {
            if (ServerPlayerAccessSystem.SetBlackListEntry(playerName, isEnabled: false))
            {
                return($"{playerName} removed from the blacklist");
            }

            return($"{playerName} is not found in the blacklist");
        }
Example #5
0
        public string Execute(
            [CustomSuggestions(nameof(GetCharacterNameSuggestions))]
            string playerName)
        {
            if (ServerPlayerAccessSystem.SetWhiteListEntry(playerName, isEnabled: true))
            {
                return
                    ($"{playerName} added to the whitelist (please don't forget to enable the whitelist if you want to use it and still didn't done it)");
            }

            return($"{playerName} is already in the whitelist");
        }
        public string Execute()
        {
            var list = ServerPlayerAccessSystem.GetWhiteList().ToList();

            if (list.Count == 0)
            {
                return("Whitelist is empty");
            }

            return("Whitelisted players:"
                   + Environment.NewLine
                   + list.GetJoinedString(Environment.NewLine));
        }
Example #7
0
        public string Execute(
            [CustomSuggestions(nameof(GetClanTagSuggestions))]
            string clanTag,
            int minutes = 30,
            string kickMessageInQuotes = null)
        {
            var faction = FactionSystem.ServerGetFactionByClanTag(clanTag);

            if (minutes < 1 ||
                minutes > 10000)
            {
                throw new Exception("Minutes must be in 1-10000 range");
            }

            var kickedCount = 0;

            foreach (var playerName in FactionSystem.ServerGetFactionMemberNames(faction))
            {
                var character = Server.Characters.GetPlayerCharacter(playerName);
                if (character == this.ExecutionContextCurrentCharacter)
                {
                    continue;
                }

                ServerPlayerAccessSystem.Kick(character, minutes, kickMessageInQuotes);
                kickedCount++;
            }

            if (kickedCount == 0)
            {
                return($"Cannot kick anyone from the faction [{clanTag}]");
            }

            var result =
                $"{kickedCount} player(s) of the faction [{clanTag}] successfully kicked from the server for {minutes} minutes";

            if (!string.IsNullOrEmpty(kickMessageInQuotes))
            {
                result += " with a following message:"
                          + Environment.NewLine
                          + kickMessageInQuotes;
            }

            return(result);
        }
        public string Execute(
            [CustomSuggestions(nameof(GetCharacterNameSuggestions))]
            string playerName)
        {
            var character = Server.Characters.GetPlayerCharacter(playerName);

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

            if (ServerPlayerAccessSystem.Unkick(character))
            {
                return($"{character.Name} successfully un-kicked");
            }

            return($"{character.Name} was not kicked so no changes are done");
        }
        public string Execute(ICharacter character, int minutes = 30)
        {
            if (character == null)
            {
                throw new Exception("The character name is not provided");
            }

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

            if (minutes < 1 ||
                minutes > 10000)
            {
                throw new Exception("Minutes must be in 1-10000 range");
            }

            ServerPlayerAccessSystem.Kick(character, minutes);
            return($"{character.Name} successfully kicked from the server for {minutes} minutes");
        }
 private static IEnumerable <string> GetCharacterNameSuggestions(string startsWith)
 {
     return(ServerPlayerAccessSystem.GetKickList());
 }
Example #11
0
 public string Execute(bool isEnabled)
 {
     ServerPlayerAccessSystem.SetWhitelistMode(isEnabled);
     return("Whitelist mode switched: " + (isEnabled ? "enabled" : "disabled") + " now");
 }
Example #12
0
 public string Execute(bool isEnabled = true)
 {
     ServerPlayerAccessSystem.SetWhitelistModeEnabled(isEnabled);
     return("Whitelist is " + (isEnabled ? "enabled" : "disabled"));
 }