diff --git a/MCGalaxy/Commands/Maintenance/CmdPlayerEdit.cs b/MCGalaxy/Commands/Maintenance/CmdPlayerEdit.cs index fd78bbe57..749213d7e 100644 --- a/MCGalaxy/Commands/Maintenance/CmdPlayerEdit.cs +++ b/MCGalaxy/Commands/Maintenance/CmdPlayerEdit.cs @@ -87,9 +87,12 @@ namespace MCGalaxy.Commands.Maintenance { SetInteger(p, args, PlayerData.ColumnTotalCuboided, int.MaxValue, who, v => who.TotalDeleted = v, UpdateDBHi); } else if (opt == "totalkicked") { - SetInteger(p, args, PlayerData.ColumnKicked, 1000000000, who, + SetInteger(p, args, PlayerData.ColumnKicked, 16777215, who, v => who.TimesBeenKicked = v, UpdateDB); - } else if (opt == "timespent") { + } else if (opt == "messages") { + SetInteger(p, args, PlayerData.ColumnMessages, 16777215, who, + v => who.TotalMessagesSent = v, UpdateDB); + } else if (opt == "timespent") { SetTimespan(p, args, PlayerData.ColumnTimeSpent, who, v => who.TotalTime = v); } else if (opt == "color") { SetColor(p, args, PlayerData.ColumnColor, who, v => who.color = (v.Length == 0 ? who.group.Color : v)); @@ -213,7 +216,7 @@ namespace MCGalaxy.Commands.Maintenance { static void MessageValidTypes(Player p) { Player.Message(p, "%HValid types: %SFirstLogin, LastLogin, Logins, Title, Deaths, Money, " + - "Modified, Drawn, Placed, Deleted, TotalKicked, TimeSpent, Color, TitleColor "); + "Modified, Drawn, Placed, Deleted, TotalKicked, TimeSpent, Color, TitleColor, Messages "); } public override void Help(Player p) { diff --git a/MCGalaxy/Database/PlayerData.cs b/MCGalaxy/Database/PlayerData.cs index c0c67063f..8b7198f20 100644 --- a/MCGalaxy/Database/PlayerData.cs +++ b/MCGalaxy/Database/PlayerData.cs @@ -40,10 +40,11 @@ namespace MCGalaxy.DB { public const string ColumnTotalBlocks = "totalBlocks"; public const string ColumnTotalCuboided = "totalCuboided"; + public const string ColumnMessages = "Messages"; public string Name, Color, Title, TitleColor, IP; public DateTime FirstLogin, LastLogin; - public int DatabaseID, Money, Deaths, Logins, Kicks; + public int DatabaseID, Money, Deaths, Logins, Kicks, Messages; public long TotalModified, TotalDrawn, TotalPlaced, TotalDeleted; public TimeSpan TotalTime; @@ -55,8 +56,8 @@ namespace MCGalaxy.DB { string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Database.Backend.AddRow(DBTable, "Name, IP, FirstLogin, LastLogin, totalLogin, Title, " + - "totalDeaths, Money, totalBlocks, totalKicked, TimeSpent", - p.name, p.ip, now, now, 1, "", 0, 0, 0, 0, (long)p.TotalTime.TotalSeconds); + "totalDeaths, Money, totalBlocks, totalKicked, Messages, TimeSpent", + p.name, p.ip, now, now, 1, "", 0, 0, 0, 0, 0, (long)p.TotalTime.TotalSeconds); using (DataTable ids = Database.Backend.GetRows(DBTable, "ID", "WHERE Name = @0", p.name)) { @@ -80,13 +81,14 @@ namespace MCGalaxy.DB { p.titlecolor = data.TitleColor; p.color = data.Color; if (p.color.Length == 0) p.color = p.group.Color; - - p.TimesDied = data.Deaths; + p.TotalModified = data.TotalModified; p.TotalDrawn = data.TotalDrawn; p.TotalPlaced = data.TotalPlaced; p.TotalDeleted = data.TotalDeleted; + p.TimesDied = data.Deaths; + p.TotalMessagesSent = data.Messages; p.money = data.Money; p.TimesBeenKicked = data.Kicks; } @@ -115,6 +117,7 @@ namespace MCGalaxy.DB { data.Deaths = ParseInt(row[ColumnDeaths].ToString()); data.Logins = ParseInt(row[ColumnLogins].ToString()); data.Kicks = ParseInt(row[ColumnKicked].ToString()); + data.Messages = ParseInt(row[ColumnMessages].ToString()); long blocks = ParseLong(row[ColumnTotalBlocks].ToString()); long cuboided = ParseLong(row[ColumnTotalCuboided].ToString()); diff --git a/MCGalaxy/Database/Stats/TopStat.cs b/MCGalaxy/Database/Stats/TopStat.cs index f1ef2f0f8..f92a5ae06 100644 --- a/MCGalaxy/Database/Stats/TopStat.cs +++ b/MCGalaxy/Database/Stats/TopStat.cs @@ -82,6 +82,8 @@ namespace MCGalaxy.DB { new TopStat("TimeSpent", PlayerData.DBTable, PlayerData.ColumnTimeSpent, MostTime, FormatTimespan, false, " CAST(TimeSpent as unsigned) "), + new TopStat("Messages", PlayerData.DBTable, + PlayerData.ColumnMessages, MostMessages, FormatInteger), }; static string MostLogins() { return "Most logins"; } @@ -90,13 +92,14 @@ namespace MCGalaxy.DB { static string MostNewest() { return "Newest players"; } static string MostOldest() { return "Oldest players"; } static string MostRecent() { return "Most recent players"; } - static string MostNotRecent() { return "Least recent players"; } + static string MostNotRecent() { return "Least recent players"; } static string MostKicked() { return "Most times kicked"; } static string MostModified() { return "Most blocks modified"; } static string MostDrawn() { return "Most blocks drawn"; } - static string MostPlaced() { return "Most blocks placed"; } + static string MostPlaced() { return "Most blocks placed"; } static string MostDeleted() { return "Most blocks deleted"; } - static string MostTime() { return "Most time spent"; } + static string MostTime() { return "Most time spent"; } + static string MostMessages() { return "Most messages written"; } public static string FormatInteger(string input) { long value = PlayerData.ParseLong(input); diff --git a/MCGalaxy/Server/Server.DB.cs b/MCGalaxy/Server/Server.DB.cs index a7a71d253..b8c3a299c 100644 --- a/MCGalaxy/Server/Server.DB.cs +++ b/MCGalaxy/Server/Server.DB.cs @@ -38,8 +38,9 @@ namespace MCGalaxy { new ColumnDesc("totalCuboided", ColumnType.Int64), new ColumnDesc("totalKicked", ColumnType.Int24), new ColumnDesc("TimeSpent", ColumnType.VarChar, 20), - new ColumnDesc("color", ColumnType.VarChar, 2), - new ColumnDesc("title_color", ColumnType.VarChar, 2), + new ColumnDesc("color", ColumnType.VarChar, 6), + new ColumnDesc("title_color", ColumnType.VarChar, 6), + new ColumnDesc("Messages", ColumnType.UInt24), }; static ColumnDesc[] createOpstats = new ColumnDesc[] { @@ -74,10 +75,6 @@ namespace MCGalaxy { Database.Backend.DeleteTable("Playercmds"); } - // Here, since SQLite is a NEW thing from 5.3.0.0, we do not have to check for existing tables in SQLite. - if (!ServerConfig.UseMySQL) return; - // Check if the color column exists. - List columns = Database.Backend.ColumnNames("Players"); if (columns.Count == 0) return; @@ -93,6 +90,9 @@ namespace MCGalaxy { if (!columns.CaselessContains("TotalCuboided")) { Database.Backend.AddColumn("Players", new ColumnDesc("totalCuboided", ColumnType.Int64), "totalBlocks"); } + if (!columns.CaselessContains("Messages")) { + Database.Backend.AddColumn("Players", new ColumnDesc("Messages", ColumnType.UInt64), "title_color"); + } } } } \ No newline at end of file