예제 #1
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!");
        }
예제 #2
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).");
     }
 }
        public void No_placeholders()
        {
            var c = new Chinook();
            var p = new PlaceholderParser();
            var d = p.Parse(c, "Hello, world!");

            Assert.AreEqual(0, d.Count);
        }
        public void Non_existant_placeholder()
        {
            var c = new Chinook();
            var p = new PlaceholderParser();
            var d = p.Parse(c, "Hello, [Does.Not.Exist]!");

            Assert.AreEqual(0, d.Count);
        }
        public void Replace_one_placeholder_no_values()
        {
            var p = new PlaceholderParser();
            var d = p.Replace(new Dictionary <string, string>(), "Hello, [Track.Name]!");

            Assert.AreEqual(1, d.Length);
            Assert.AreEqual("Hello, !", d[0]);
        }
        public void Invalid_path_placeholder()
        {
            var c = new Chinook();
            var p = new PlaceholderParser();
            var d = p.Parse(c, "Hello, [Track.Album.Name]!");

            Assert.AreEqual(0, d.Count);
        }
        public void One_placeholder()
        {
            var c = new Chinook();
            var p = new PlaceholderParser();
            var d = p.Parse(c, "Hello, [Track.Name]!");

            Assert.AreEqual(1, d.Count);
            Assert.IsTrue(d.ContainsKey("[Track.Name]"));
            Assert.AreEqual(new FieldPath(c.Track["Name"]), d["[Track.Name]"]);
        }
예제 #8
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="databaseConnectionFactory">connection factory</param>
 /// <param name="sql">statement sql</param>
 /// <param name="contextAttributes">statement contextual attributes</param>
 protected ConnectionCache(
     DatabaseConnectionFactory databaseConnectionFactory,
     string sql,
     IEnumerable<Attribute> contextAttributes)
 {
     this._databaseConnectionFactory = databaseConnectionFactory;
     this._sql = sql;
     this._sqlFragments = PlaceholderParser.ParsePlaceholder(sql);
     this._contextAttributes = contextAttributes;
 }
        public void Depth2_placeholder()
        {
            var c = new Chinook();
            var p = new PlaceholderParser();
            var d = p.Parse(c, "Hello, [Track.AlbumId.Title]!");

            Assert.AreEqual(1, d.Count);
            Assert.IsTrue(d.ContainsKey("[Track.AlbumId.Title]"));
            Assert.AreEqual(new FieldPath(c.Track["AlbumId"], c.Album["Title"]), d["[Track.AlbumId.Title]"]);
        }
예제 #10
0
 /// <summary>
 /// Gets the example query meta data.
 /// </summary>
 /// <param name="dbDriver">The driver.</param>
 /// <param name="sampleSQL">The sample SQL.</param>
 /// <param name="metadataSetting">The metadata setting.</param>
 /// <param name="contextAttributes">The context attributes.</param>
 /// <returns></returns>
 private static QueryMetaData GetExampleQueryMetaData(
     DbDriver dbDriver,
     string sampleSQL,
     ColumnSettings metadataSetting,
     IEnumerable<Attribute> contextAttributes)
 {
     var sampleSQLFragments = PlaceholderParser.ParsePlaceholder(sampleSQL);
     using (var dbCommand = dbDriver.CreateCommand(sampleSQLFragments, metadataSetting, contextAttributes)) {
         return dbCommand.MetaData;
     }
 }
        public void Replace_non_existant_placeholder()
        {
            var v = new Dictionary <string, string>();

            v.Add("[Track.Name]", "world");
            var p = new PlaceholderParser();
            var d = p.Replace(v, "Hello, [Does.Not.Exist]!");

            Assert.AreEqual(1, d.Length);
            Assert.AreEqual("Hello, !", d[0]);
        }
        public void Replace_depth2_placeholder()
        {
            var v = new Dictionary <string, string>();

            v.Add("[Track.AlbumId.Title]", "album world");
            var p = new PlaceholderParser();
            var d = p.Replace(v, "Hello, [Track.AlbumId.Title]!");

            Assert.AreEqual(1, d.Length);
            Assert.AreEqual("Hello, album world!", d[0]);
        }
        public void Replace_one_placeholder()
        {
            var v = new Dictionary <string, string>();

            v.Add("[Track.Name]", "world");
            var p = new PlaceholderParser();
            var d = p.Replace(v, "Hello, [Track.Name]!");

            Assert.AreEqual(1, d.Length);
            Assert.AreEqual("Hello, world!", d[0]);
        }
        public void Replace_multiple_placeholders()
        {
            var v = new Dictionary <string, string>();

            v.Add("[Artist.Name]", "solar system");
            v.Add("[Track.Name]", "world");
            var p = new PlaceholderParser();
            var d = p.Replace(v, "Hello, [Artist.Name]'s [Track.Name]!");

            Assert.AreEqual(1, d.Length);
            Assert.AreEqual("Hello, solar system's world!", d[0]);
        }
        public void Replace_one_placeholder_two_strings()
        {
            var v = new Dictionary <string, string>();

            v.Add("[Track.Name]", "world");
            v.Add("[Album.Title]", "universe");
            var p = new PlaceholderParser();
            var d = p.Replace(v, "Hello, [Track.Name]!", "Hello, [Album.Title]!");

            Assert.AreEqual(2, d.Length);
            Assert.AreEqual("Hello, world!", d[0]);
            Assert.AreEqual("Hello, universe!", d[1]);
        }
예제 #16
0
        /// <summary>
        /// Gets the SQL fragments.
        /// </summary>
        /// <param name="databaseStreamSpec">The database stream spec.</param>
        /// <returns></returns>
        private static IList<PlaceholderParser.Fragment> GetSqlFragments(
            DBStatementStreamSpec databaseStreamSpec)
        {
            IList<PlaceholderParser.Fragment> sqlFragments;
            try {
                sqlFragments = PlaceholderParser.ParsePlaceholder(databaseStreamSpec.SqlWithSubsParams);
            }
            catch (PlaceholderParseException ex) {
                const string text = "Error parsing SQL";
                throw new ExprValidationException(text + ", reason: " + ex.Message, ex);
            }

            return sqlFragments;
        }
예제 #17
0
        public static void Run(SvPlayer player, string message)
        {
            var arg1     = GetArgument.Run(1, false, true, message);
            var shplayer = player.player;

            if (string.IsNullOrEmpty(arg1))
            {
                if (PlayerList[shplayer.ID].StaffChatEnabled)
                {
                    PlayerList[shplayer.ID].StaffChatEnabled = false;
                    player.SendChatMessage($"<color={infoColor}>Staff chat disabled.</color>");
                }
                else
                {
                    PlayerList[shplayer.ID].StaffChatEnabled = true;
                    player.SendChatMessage($"<color={infoColor}>Staff chat enabled.</color>");
                }
                return;
            }
            SendChatMessageToAdmins.Run(PlaceholderParser.ParseUserMessage(player.player, AdminChatMessage, arg1));
        }
예제 #18
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);
        }
예제 #19
0
        /// <summary>
        /// This replaces the HTML placeholders that we're rendered into the html
        /// markup before the module calls this method to update the placeholders with
        /// the real dependencies.
        /// </summary>
        /// <param name="html"></param>
        /// <returns></returns>
        public string ParseHtmlPlaceholders(string html)
        {
            GenerateOutput();

            return(PlaceholderParser.ParseHtmlPlaceholders(CurrentContext, html, JsMarkupRegex, CssMarkupRegex, _output.ToArray()));
        }
예제 #20
0
        public static void Run(SvPlayer player, string message)
        {
            var arg1 = GetArgument.Run(1, false, true, message);

            if (string.IsNullOrWhiteSpace(arg1))
            {
                player.SendChatMessage(ArgRequired);
                return;
            }
            player.Send(LocalChatMe ? SvSendType.Local : SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, PlaceholderParser.ParseUserMessage(player.player, MeMessage, arg1));
        }