mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Add 'messages' to database table, to /pe, to /top
This commit is contained in:
parent
c4439e05a2
commit
55ea39630d
@ -87,9 +87,12 @@ namespace MCGalaxy.Commands.Maintenance {
|
|||||||
SetInteger(p, args, PlayerData.ColumnTotalCuboided, int.MaxValue, who,
|
SetInteger(p, args, PlayerData.ColumnTotalCuboided, int.MaxValue, who,
|
||||||
v => who.TotalDeleted = v, UpdateDBHi);
|
v => who.TotalDeleted = v, UpdateDBHi);
|
||||||
} else if (opt == "totalkicked") {
|
} else if (opt == "totalkicked") {
|
||||||
SetInteger(p, args, PlayerData.ColumnKicked, 1000000000, who,
|
SetInteger(p, args, PlayerData.ColumnKicked, 16777215, who,
|
||||||
v => who.TimesBeenKicked = v, UpdateDB);
|
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);
|
SetTimespan(p, args, PlayerData.ColumnTimeSpent, who, v => who.TotalTime = v);
|
||||||
} else if (opt == "color") {
|
} else if (opt == "color") {
|
||||||
SetColor(p, args, PlayerData.ColumnColor, who, v => who.color = (v.Length == 0 ? who.group.Color : v));
|
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) {
|
static void MessageValidTypes(Player p) {
|
||||||
Player.Message(p, "%HValid types: %SFirstLogin, LastLogin, Logins, Title, Deaths, Money, " +
|
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) {
|
public override void Help(Player p) {
|
||||||
|
@ -40,10 +40,11 @@ namespace MCGalaxy.DB {
|
|||||||
|
|
||||||
public const string ColumnTotalBlocks = "totalBlocks";
|
public const string ColumnTotalBlocks = "totalBlocks";
|
||||||
public const string ColumnTotalCuboided = "totalCuboided";
|
public const string ColumnTotalCuboided = "totalCuboided";
|
||||||
|
public const string ColumnMessages = "Messages";
|
||||||
|
|
||||||
public string Name, Color, Title, TitleColor, IP;
|
public string Name, Color, Title, TitleColor, IP;
|
||||||
public DateTime FirstLogin, LastLogin;
|
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 long TotalModified, TotalDrawn, TotalPlaced, TotalDeleted;
|
||||||
public TimeSpan TotalTime;
|
public TimeSpan TotalTime;
|
||||||
|
|
||||||
@ -55,8 +56,8 @@ namespace MCGalaxy.DB {
|
|||||||
|
|
||||||
string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
Database.Backend.AddRow(DBTable, "Name, IP, FirstLogin, LastLogin, totalLogin, Title, " +
|
Database.Backend.AddRow(DBTable, "Name, IP, FirstLogin, LastLogin, totalLogin, Title, " +
|
||||||
"totalDeaths, Money, totalBlocks, totalKicked, TimeSpent",
|
"totalDeaths, Money, totalBlocks, totalKicked, Messages, TimeSpent",
|
||||||
p.name, p.ip, now, now, 1, "", 0, 0, 0, 0, (long)p.TotalTime.TotalSeconds);
|
p.name, p.ip, now, now, 1, "", 0, 0, 0, 0, 0, (long)p.TotalTime.TotalSeconds);
|
||||||
|
|
||||||
using (DataTable ids = Database.Backend.GetRows(DBTable,
|
using (DataTable ids = Database.Backend.GetRows(DBTable,
|
||||||
"ID", "WHERE Name = @0", p.name)) {
|
"ID", "WHERE Name = @0", p.name)) {
|
||||||
@ -80,13 +81,14 @@ namespace MCGalaxy.DB {
|
|||||||
p.titlecolor = data.TitleColor;
|
p.titlecolor = data.TitleColor;
|
||||||
p.color = data.Color;
|
p.color = data.Color;
|
||||||
if (p.color.Length == 0) p.color = p.group.Color;
|
if (p.color.Length == 0) p.color = p.group.Color;
|
||||||
|
|
||||||
p.TimesDied = data.Deaths;
|
|
||||||
p.TotalModified = data.TotalModified;
|
p.TotalModified = data.TotalModified;
|
||||||
p.TotalDrawn = data.TotalDrawn;
|
p.TotalDrawn = data.TotalDrawn;
|
||||||
p.TotalPlaced = data.TotalPlaced;
|
p.TotalPlaced = data.TotalPlaced;
|
||||||
p.TotalDeleted = data.TotalDeleted;
|
p.TotalDeleted = data.TotalDeleted;
|
||||||
|
|
||||||
|
p.TimesDied = data.Deaths;
|
||||||
|
p.TotalMessagesSent = data.Messages;
|
||||||
p.money = data.Money;
|
p.money = data.Money;
|
||||||
p.TimesBeenKicked = data.Kicks;
|
p.TimesBeenKicked = data.Kicks;
|
||||||
}
|
}
|
||||||
@ -115,6 +117,7 @@ namespace MCGalaxy.DB {
|
|||||||
data.Deaths = ParseInt(row[ColumnDeaths].ToString());
|
data.Deaths = ParseInt(row[ColumnDeaths].ToString());
|
||||||
data.Logins = ParseInt(row[ColumnLogins].ToString());
|
data.Logins = ParseInt(row[ColumnLogins].ToString());
|
||||||
data.Kicks = ParseInt(row[ColumnKicked].ToString());
|
data.Kicks = ParseInt(row[ColumnKicked].ToString());
|
||||||
|
data.Messages = ParseInt(row[ColumnMessages].ToString());
|
||||||
|
|
||||||
long blocks = ParseLong(row[ColumnTotalBlocks].ToString());
|
long blocks = ParseLong(row[ColumnTotalBlocks].ToString());
|
||||||
long cuboided = ParseLong(row[ColumnTotalCuboided].ToString());
|
long cuboided = ParseLong(row[ColumnTotalCuboided].ToString());
|
||||||
|
@ -82,6 +82,8 @@ namespace MCGalaxy.DB {
|
|||||||
new TopStat("TimeSpent", PlayerData.DBTable,
|
new TopStat("TimeSpent", PlayerData.DBTable,
|
||||||
PlayerData.ColumnTimeSpent, MostTime, FormatTimespan,
|
PlayerData.ColumnTimeSpent, MostTime, FormatTimespan,
|
||||||
false, " CAST(TimeSpent as unsigned) "),
|
false, " CAST(TimeSpent as unsigned) "),
|
||||||
|
new TopStat("Messages", PlayerData.DBTable,
|
||||||
|
PlayerData.ColumnMessages, MostMessages, FormatInteger),
|
||||||
};
|
};
|
||||||
|
|
||||||
static string MostLogins() { return "Most logins"; }
|
static string MostLogins() { return "Most logins"; }
|
||||||
@ -90,13 +92,14 @@ namespace MCGalaxy.DB {
|
|||||||
static string MostNewest() { return "Newest players"; }
|
static string MostNewest() { return "Newest players"; }
|
||||||
static string MostOldest() { return "Oldest players"; }
|
static string MostOldest() { return "Oldest players"; }
|
||||||
static string MostRecent() { return "Most recent 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 MostKicked() { return "Most times kicked"; }
|
||||||
static string MostModified() { return "Most blocks modified"; }
|
static string MostModified() { return "Most blocks modified"; }
|
||||||
static string MostDrawn() { return "Most blocks drawn"; }
|
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 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) {
|
public static string FormatInteger(string input) {
|
||||||
long value = PlayerData.ParseLong(input);
|
long value = PlayerData.ParseLong(input);
|
||||||
|
@ -38,8 +38,9 @@ namespace MCGalaxy {
|
|||||||
new ColumnDesc("totalCuboided", ColumnType.Int64),
|
new ColumnDesc("totalCuboided", ColumnType.Int64),
|
||||||
new ColumnDesc("totalKicked", ColumnType.Int24),
|
new ColumnDesc("totalKicked", ColumnType.Int24),
|
||||||
new ColumnDesc("TimeSpent", ColumnType.VarChar, 20),
|
new ColumnDesc("TimeSpent", ColumnType.VarChar, 20),
|
||||||
new ColumnDesc("color", ColumnType.VarChar, 2),
|
new ColumnDesc("color", ColumnType.VarChar, 6),
|
||||||
new ColumnDesc("title_color", ColumnType.VarChar, 2),
|
new ColumnDesc("title_color", ColumnType.VarChar, 6),
|
||||||
|
new ColumnDesc("Messages", ColumnType.UInt24),
|
||||||
};
|
};
|
||||||
|
|
||||||
static ColumnDesc[] createOpstats = new ColumnDesc[] {
|
static ColumnDesc[] createOpstats = new ColumnDesc[] {
|
||||||
@ -74,10 +75,6 @@ namespace MCGalaxy {
|
|||||||
Database.Backend.DeleteTable("Playercmds");
|
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<string> columns = Database.Backend.ColumnNames("Players");
|
List<string> columns = Database.Backend.ColumnNames("Players");
|
||||||
if (columns.Count == 0) return;
|
if (columns.Count == 0) return;
|
||||||
|
|
||||||
@ -93,6 +90,9 @@ namespace MCGalaxy {
|
|||||||
if (!columns.CaselessContains("TotalCuboided")) {
|
if (!columns.CaselessContains("TotalCuboided")) {
|
||||||
Database.Backend.AddColumn("Players", new ColumnDesc("totalCuboided", ColumnType.Int64), "totalBlocks");
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user