Start tracking total placed and total deleted, not yet saved to the database though.

This commit is contained in:
UnknownShadow200 2016-07-31 22:35:14 +10:00
parent 366551c28c
commit e4ace08a91
16 changed files with 81 additions and 72 deletions

View File

@ -19,12 +19,12 @@ namespace MCGalaxy {
PlayerData pl = PlayerInfo.FindData(p);
if (pl == null) return;
modified_blocks = int.Parse(pl.Blocks);
modified_blocks = (int)pl.Blocks;
time = pl.TotalTime;
first_login = pl.FirstLogin;
last_login = pl.LastLogin;
total_logins = int.Parse(pl.Logins);
kicks = int.Parse(pl.Kicks);
first_login = pl.FirstLogin.ToString("yyyy-MM-dd HH:mm:ss");
last_login = pl.LastLogin.ToString("yyyy-MM-dd HH:mm:ss");
total_logins = pl.Logins;
kicks = pl.Kicks;
}
}
}

View File

@ -40,8 +40,7 @@ namespace MCGalaxy.Commands {
Player.Message(p, "Searching PlayerDB..");
PlayerData target = PlayerInfo.FindOfflineMatches(p, message);
if (target == null) return;
Show(p, target.Name, DateTime.Parse(target.FirstLogin),
DateTime.Parse(target.LastLogin));
Show(p, target.Name, target.FirstLogin, target.LastLogin);
}
static void Show(Player p, string name, DateTime first, DateTime last) {

View File

@ -60,7 +60,9 @@ namespace MCGalaxy.Commands {
info.Name = who.name;
info.Group = who.group;
info.Money = who.money; info.Deaths = who.overallDeath;
info.TotalBlocks = who.overallBlocks; info.TotalDrawn = who.TotalBlocksDrawn;
info.TotalBlocks = who.overallBlocks; info.TotalDrawn = who.TotalDrawn;
info.TotalPlaced = who.TotalPlaced; info.TotalDeleted = who.TotalDeleted;
info.LoginBlocks = who.loginBlocks;
info.TimeSpent = who.time; info.TimeOnline = DateTime.Now - who.timeLogged;
@ -76,27 +78,28 @@ namespace MCGalaxy.Commands {
return info;
}
WhoInfo FromOffline(PlayerData target, string message) {
Group group = Group.findPlayerGroup(target.Name);
string color = target.Color == "" ? group.color : target.Color;
string prefix = target.Title == "" ? "" : color + "[" + target.TitleColor + target.Title + color + "] ";
WhoInfo FromOffline(PlayerData data, string message) {
Group group = Group.findPlayerGroup(data.Name);
string color = data.Color == "" ? group.color : data.Color;
string prefix = data.Title == "" ? "" : color + "[" + data.TitleColor + data.Title + color + "] ";
WhoInfo info = new WhoInfo();
info.FullName = prefix + color + target.Name.TrimEnd('+');
info.Name = target.Name;
info.FullName = prefix + color + data.Name.TrimEnd('+');
info.Name = data.Name;
info.Group = group;
info.Money = int.Parse(target.Money); info.Deaths = int.Parse(target.Deaths);
info.TotalBlocks = long.Parse(target.Blocks); info.LoginBlocks = -1;
info.TotalDrawn = long.Parse(target.Cuboided);
info.Money = data.Money; info.Deaths = data.Deaths;
info.TimeSpent = target.TotalTime.ParseDBTime();
info.First = DateTime.Parse(target.FirstLogin);
info.Last = DateTime.Parse(target.LastLogin);
info.Logins = int.Parse(target.Logins); info.Kicks = int.Parse(target.Kicks);
info.IP = target.IP;
info.TotalBlocks = data.Blocks; info.TotalDrawn = data.Cuboided;
info.LoginBlocks = -1;
info.TimeSpent = data.TotalTime.ParseDBTime();
info.First = data.FirstLogin;
info.Last = data.LastLogin;
info.Logins = data.Logins; info.Kicks = data.Kicks;
info.IP = data.IP;
if (Server.zombie.Running) {
ZombieStats stats = Server.zombie.LoadZombieStats(target.Name);
ZombieStats stats = Server.zombie.LoadZombieStats(data.Name);
info.RoundsTotal = stats.TotalRounds; info.InfectedTotal = stats.TotalInfected;
info.RoundsMax = stats.MaxRounds; info.InfectedMax = stats.MaxInfected;
}

View File

@ -23,7 +23,7 @@ namespace MCGalaxy.Commands {
public string FullName, Name;
public Group Group;
public int Money, Deaths;
public long TotalBlocks, LoginBlocks, TotalDrawn;
public long TotalBlocks, LoginBlocks, TotalDrawn, TotalPlaced, TotalDeleted;
public TimeSpan TimeSpent, TimeOnline;
public DateTime First, Last;
public int Logins, Kicks;
@ -48,7 +48,8 @@ namespace MCGalaxy.Commands {
Player.Message(p, " Modified &a{0} %Sblocks, &a{1} %Ssince login", who.TotalBlocks, who.LoginBlocks);
else
Player.Message(p, " Modified &a{0} %Sblocks", who.TotalBlocks);
Player.Message(p, " &a0 %Splaced, &a0 %Sdeleted, &a{0} %Sdrawn", who.TotalDrawn);
Player.Message(p, " &a{0} %Splaced, &a{1} %Sdeleted, &a{2} %Sdrawn",
who.TotalPlaced, who.TotalDeleted, who.TotalDrawn);
if (who.TimeOnline.Ticks > 0)
Player.Message(p, " Spent &a{0}%S on the server, &a{1}%S this session",

View File

@ -56,8 +56,8 @@ namespace MCGalaxy.Commands {
const string format = "yyyy-MM-dd HH:mm:ss";
void Swap(PlayerData src, PlayerData dst) {
string first = DateTime.Parse(src.FirstLogin).ToString(format);
string last = DateTime.Parse(src.LastLogin).ToString(format);
string first = src.FirstLogin.ToString(format);
string last = src.LastLogin.ToString(format);
const string syntax = "UPDATE Players SET totalBlocks=@0, totalCuboided=@1" +
", color=@2, totalDeaths=@3, FirstLogin=@4, IP=@5, totalKicked=@6, LastLogin=@7" +
", totalLogin=@8, Money=@9, Title=@10, title_color=@11, TimeSpent=@12 WHERE Name=@13";

View File

@ -72,7 +72,7 @@ namespace MCGalaxy.Commands {
SetInteger(p, args, "totalBlocks", int.MaxValue, who, v => who.overallBlocks = v); break;
case "totalcuboided":
case "totalcuboid":
SetInteger(p, args, "totalCuboided", int.MaxValue, who, v => who.TotalBlocksDrawn = v); break;
SetInteger(p, args, "totalCuboided", int.MaxValue, who, v => who.TotalDrawn = v); break;
case "totalkicked":
SetInteger(p, args, "totalKicked", 1000000000, who, v => who.totalKicked = v); break;
case "timespent":

View File

@ -61,10 +61,10 @@ namespace MCGalaxy.Commands {
for (int z = Math.Min(m[0].Z, m[1].Z); z <= Math.Max(m[0].Z, m[1].Z); z++)
for (int x = Math.Min(m[0].X, m[1].X); x <= Math.Max(m[0].X, m[1].X); x++)
{
byte tile = blocks[x + width * (z + y * length)], extTile = 0;
if (tile == Block.custom_block)
extTile = other.GetExtTile((ushort)x, (ushort)y, (ushort)z);
p.level.UpdateBlock(p, (ushort)x, (ushort)y, (ushort)z, tile, extTile);
byte block = blocks[x + width * (z + y * length)], extBlock = 0;
if (block == Block.custom_block)
extBlock = other.GetExtTile((ushort)x, (ushort)y, (ushort)z);
p.level.UpdateBlock(p, (ushort)x, (ushort)y, (ushort)z, block, extBlock, true);
}
return true;
}

View File

@ -37,7 +37,7 @@ namespace MCGalaxy.Commands.Building {
}
static void Place(Player p, int x, int y, int z) {
p.level.UpdateBlock(p, (ushort)x, (ushort)y, (ushort)z, Block.goldsolid, 0);
p.level.UpdateBlock(p, (ushort)x, (ushort)y, (ushort)z, Block.goldsolid, 0, true);
}
public override void Help(Player p) {

View File

@ -84,7 +84,7 @@ namespace MCGalaxy.Commands.Building {
if (tile == Block.custom_block) extTile = lvl.GetExtTile(x, y, z);
bool sameBlock = type == Block.custom_block ? extType == extTile : type == tile;
if (sameBlock) p.level.UpdateBlock(p, x, y, z, Block.air, 0);
if (sameBlock) p.level.UpdateBlock(p, x, y, z, Block.air, 0, true);
}
Player.Message(p, "Drilled " + buffer.Count + " blocks.");
return true;

View File

@ -166,7 +166,7 @@ namespace MCGalaxy.Commands.Building {
}
if (col.A < 20) cur.Block = Block.air;
p.level.UpdateBlock(p, (ushort)P.X, (ushort)P.Y, (ushort)P.Z, cur.Block, 0);
p.level.UpdateBlock(p, (ushort)P.X, (ushort)P.Y, (ushort)P.Z, cur.Block, 0, true);
}
if (dArgs.name == "tempImage_" + p.name)

View File

@ -69,7 +69,7 @@ namespace MCGalaxy.Commands.Building {
ushort endX = (ushort)(m[0].X + dirX * distance);
ushort endY = (ushort)(m[0].Y + dirY * distance);
ushort endZ = (ushort)(m[0].Z + dirZ * distance);
p.level.UpdateBlock(p, endX, endY, endZ, Block.rock, 0);
p.level.UpdateBlock(p, endX, endY, endZ, Block.rock, 0, true);
if (interval > 0) {
int x = m[0].X, y = m[0].Y, z = m[0].Z;
@ -80,7 +80,7 @@ namespace MCGalaxy.Commands.Building {
delta = Math.Abs(x - m[0].X) + Math.Abs(y - m[0].Y) + Math.Abs(z - m[0].Z);
}
} else {
p.level.UpdateBlock(p, (ushort)m[0].X, (ushort)m[0].Y, (ushort)m[0].Z, Block.rock, 0);
p.level.UpdateBlock(p, (ushort)m[0].X, (ushort)m[0].Y, (ushort)m[0].Z, Block.rock, 0, true);
}
Player.Message(p, "Placed stone blocks {0} apart.", interval > 0 ? interval : distance);

View File

@ -137,9 +137,7 @@ namespace MCGalaxy.Drawing.Ops {
continue;
lvl.SetTile(b.X, b.Y, b.Z, b.Block, p, b.ExtBlock);
p.loginBlocks++;
p.overallBlocks++;
p.TotalBlocksDrawn++;
p.IncrementBlockStats(b.Block, true);
}
} else if (item.Level.bufferblocks) {
foreach (var b in item.Op.Perform(item.Marks, p, lvl, item.Brush)) {

View File

@ -292,9 +292,7 @@ namespace MCGalaxy {
p.UndoBuffer.Add(this, Pos);
errorLocation = "Setting tile";
p.loginBlocks++;
p.overallBlocks++;
if (drawn) p.TotalBlocksDrawn++;
p.IncrementBlockStats(block, drawn);
SetTile(x, y, z, block);
if (b == Block.custom_block && block != Block.custom_block)

View File

@ -150,15 +150,15 @@ namespace MCGalaxy {
//Using for anything else can cause unintended effects!
public bool canBuild = true;
public int money = 0, loginMoney = 0;
public long overallBlocks = 0, TotalBlocksDrawn = 0;
public int loginBlocks = 0;
public int money, loginMoney;
public long overallBlocks, TotalDrawn, TotalPlaced, TotalDeleted;
public int loginBlocks;
public DateTime timeLogged;
public DateTime firstLogin, lastLogin;
public int totalLogins = 0;
public int totalKicked = 0;
public int overallDeath = 0;
public int totalLogins;
public int totalKicked;
public int overallDeath;
public bool staticCommands = false;
internal bool outdatedClient = false; // for ClassicalSharp 0.98.5, which didn't reload map for BlockDefinitions

View File

@ -27,6 +27,15 @@ namespace MCGalaxy {
public sealed partial class Player : IDisposable {
public void IncrementBlockStats(byte block, bool drawn) {
loginBlocks++;
overallBlocks++;
if (drawn) TotalDrawn++;
else if (block == 0) TotalDeleted++;
else TotalPlaced++;
}
public static string CheckPlayerStatus(Player p) {
if ( p.hidden ) return "hidden";
if ( p.IsAfk ) return "afk";
@ -95,7 +104,7 @@ namespace MCGalaxy {
Database.Execute(query, ip, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
totalLogins, overallDeath, money, overallBlocks,
TotalBlocksDrawn, totalKicked, time.ToDBTime(), name);
TotalDrawn, totalKicked, time.ToDBTime(), name);
if (Economy.Enabled && loginMoney != money) {
Economy.EcoStats ecos = Economy.RetrieveEcoStats(name);

View File

@ -21,9 +21,10 @@ using MCGalaxy.SQL;
namespace MCGalaxy {
public class PlayerData {
public string Name, Color, Title, TitleColor;
public string Money, Deaths, Blocks, Cuboided, Logins, Kicks;
public string TotalTime, FirstLogin, LastLogin, IP, UserID;
public string Name, Color, Title, TitleColor, TotalTime, IP;
public DateTime FirstLogin, LastLogin;
public int UserID, Money, Deaths, Logins, Kicks;
public long Blocks, Cuboided;
internal static void Create(Player p) {
p.prefix = "";
@ -38,7 +39,7 @@ namespace MCGalaxy {
p.totalKicked = 0;
p.overallDeath = 0;
p.overallBlocks = 0;
p.TotalBlocksDrawn = 0;
p.TotalDrawn = 0;
string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
const string query = "INSERT INTO Players (Name, IP, FirstLogin, LastLogin, totalLogin, Title, totalDeaths" +
@ -54,11 +55,11 @@ namespace MCGalaxy {
internal static void Load(DataTable playerDb, Player p) {
PlayerData data = PlayerData.Fill(playerDb.Rows[0]);
p.totalLogins = int.Parse(data.Logins) + 1;
p.totalLogins = data.Logins + 1;
p.time = data.TotalTime.ParseDBTime();
p.DatabaseID = int.Parse(data.UserID);
p.firstLogin = DateTime.Parse(data.FirstLogin);
p.lastLogin = DateTime.Parse(data.LastLogin);
p.DatabaseID = data.UserID;
p.firstLogin = data.FirstLogin;
p.lastLogin = data.LastLogin;
p.title = data.Title;
if (p.title != "") p.title = p.title.Replace("[", "").Replace("]", "");
@ -67,36 +68,36 @@ namespace MCGalaxy {
p.color = data.Color;
if (p.color == "") p.color = p.group.color;
p.overallDeath = int.Parse(data.Deaths);
p.overallBlocks = long.Parse(data.Blocks);
p.TotalBlocksDrawn = long.Parse(data.Cuboided);
p.overallDeath = data.Deaths;
p.overallBlocks = data.Blocks;
p.TotalDrawn = data.Cuboided;
//money = int.Parse(data.money);
p.money = Economy.RetrieveEcoStats(p.name).money;
p.loginMoney = p.money;
p.totalKicked = int.Parse(data.Kicks);
p.totalKicked = data.Kicks;
}
public static PlayerData Fill(DataRow row) {
PlayerData pl = new PlayerData();
pl.Name = row["Name"].ToString().Trim();
pl.IP = row["IP"].ToString().Trim();
pl.UserID = row["ID"].ToString().Trim();
pl.UserID = int.Parse(row["ID"].ToString().Trim());
pl.TotalTime = row["TimeSpent"].ToString();
pl.FirstLogin = row["FirstLogin"].ToString();
pl.LastLogin = row["LastLogin"].ToString();
pl.FirstLogin = DateTime.Parse(row["FirstLogin"].ToString());
pl.LastLogin = DateTime.Parse(row["LastLogin"].ToString());
pl.Title = row["Title"].ToString().Trim();
pl.TitleColor = ParseColor(row["title_color"]);
pl.Color = ParseColor(row["color"]);
pl.Money = row["Money"].ToString();
pl.Deaths = row["TotalDeaths"].ToString();
pl.Blocks = row["totalBlocks"].ToString();
pl.Cuboided = row["totalCuboided"].ToString();
pl.Logins = row["totalLogin"].ToString();
pl.Kicks = row["totalKicked"].ToString();
pl.Money = int.Parse(row["Money"].ToString());
pl.Deaths = int.Parse(row["TotalDeaths"].ToString());
pl.Blocks = long.Parse(row["totalBlocks"].ToString());
pl.Cuboided = long.Parse(row["totalCuboided"].ToString());
pl.Logins = int.Parse(row["totalLogin"].ToString());
pl.Kicks = int.Parse(row["totalKicked"].ToString());
return pl;
}