Example #1
0
 public virtual void LoadAll(bool initCooldown = false)
 {
     if (DebugLevel >= 1)
     {
         Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Loading {Name}s..");
     }
     List.Clear();
     foreach (string file in Directory.EnumerateFiles(FilesDirectory, $"*.{FileExtension}", SearchOption.AllDirectories))
     {
         var obj = JsonConvert.DeserializeObject <JsonType>(FilterComments.Run(file));
         if (List.Any(x => x.Name == obj.Name))
         {
             Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [ERROR] Cannot add {Name} {obj.Name} because it already exists in the list!");
             continue;
         }
         List.Add(obj);
         if (initCooldown)
         {
             SetupDelayable(obj);
         }
         if (DebugLevel >= 1)
         {
             Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Loaded {Name}: {obj.Name}");
         }
     }
     if (DebugLevel >= 1)
     {
         Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Loaded in {List.Count} {Name}(s).");
     }
 }
Example #2
0
        public static void Run(SvPlayer player, string message)
        {
            string arg1 = GetArgument.Run(1, false, true, message);

            if (string.IsNullOrEmpty(arg1))
            {
                player.SendChatMessage(ArgRequired);
                return;
            }
            if (WipePassword == "default")
            {
                player.SendChatMessage($"<color={errorColor}>Password was not changed yet, cannot use this command.</color>");
                return;
            }
            if (arg1 != WipePassword)
            {
                player.SendChatMessage($"<color={errorColor}>Invalid password.</color>");
                return;
            }
            Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Wipe command ran by {player.player.username}, password matched, deleting all save files.");
            foreach (var currPlayer in PlayerList.Values.ToList())
            {
                player.svManager.Disconnect(currPlayer.ShPlayer.svPlayer.connection, DisconnectTypes.Problem);
            }
            Thread.Sleep(500);
            var files = Directory.GetFiles(Path.Combine(Application.persistentDataPath, "PlayerData/"), "*.json").Where(item => item.EndsWith(".json", StringComparison.CurrentCulture));

            foreach (var file in files.ToList())
            {
                File.Delete(file);
            }
            Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] All user data deleted!");
        }
Example #3
0
        public static void Run(SvPlayer player, string message)
        {
            var arg1 = GetArgument.Run(1, false, false, message);
            var arg2 = GetArgument.Run(2, false, true, message);

            if (string.IsNullOrEmpty(arg1) || string.IsNullOrEmpty(arg2))
            {
                player.SendChatMessage(ArgRequired);
                return;
            }
            var shPlayer = GetShByStr.Run(arg1, true);

            if (shPlayer == null)
            {
                player.SendChatMessage(NotFoundOnlineIdOnly);
                return;
            }
            LogMessage.LogOther($"{PlaceholderParser.ParseTimeStamp()} [INFO] {shPlayer.username} Got banned by {player.playerData.username} (Reason: {arg2}");
            player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"<color={argColor}>{shPlayer.username}</color> <color={warningColor}>Just got banned by</color> <color={argColor}>{player.playerData.username}</color> <color={warningColor}>(Reason: </color><color={argColor}>{arg2}</color><color={warningColor}>)</color>");
            SendDiscordMessage.BanMessage(shPlayer.username, player.playerData.username, arg2);
            player.SendChatMessage($"<color={infoColor}>Banned</color> <color={argColor}>{shPlayer.username}</color><color={infoColor}>. (Reason: {arg2})</color>");
            player.svManager.AddBanned(shPlayer);
            player.svManager.Disconnect(shPlayer.svPlayer.connection, DisconnectTypes.Banned);
        }