mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Start tracking total blocks drawn in /whois.
This commit is contained in:
parent
e5d8e0e95e
commit
a5c06065ca
@ -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.LoginBlocks = who.loginBlocks;
|
||||
info.TotalBlocks = who.overallBlocks; info.TotalDrawn = who.TotalBlocksDrawn;
|
||||
info.LoginBlocks = who.loginBlocks;
|
||||
|
||||
info.TimeSpent = who.time; info.TimeOnline = DateTime.Now - who.timeLogged;
|
||||
info.First = who.firstLogin;
|
||||
info.Logins = who.totalLogins; info.Kicks = who.totalKicked;
|
||||
@ -85,6 +87,8 @@ namespace MCGalaxy.Commands {
|
||||
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.TimeSpent = target.totalTime.ParseDBTime();
|
||||
info.First = DateTime.Parse(target.firstLogin);
|
||||
info.Last = DateTime.Parse(target.lastLogin);
|
||||
|
||||
@ -23,7 +23,7 @@ namespace MCGalaxy.Commands {
|
||||
public string FullName, Name;
|
||||
public Group Group;
|
||||
public int Money, Deaths;
|
||||
public long TotalBlocks, LoginBlocks;
|
||||
public long TotalBlocks, LoginBlocks, TotalDrawn;
|
||||
public TimeSpan TimeSpent, TimeOnline;
|
||||
public DateTime First, Last;
|
||||
public int Logins, Kicks;
|
||||
@ -38,20 +38,23 @@ namespace MCGalaxy.Commands {
|
||||
Player.Message(p, " Rank of " + who.Group.ColoredName);
|
||||
|
||||
if (Economy.Enabled)
|
||||
Player.Message(p, " &a" + who.Deaths + " &cdeaths%S, &a" + who.Money +
|
||||
" %S" + Server.moneys +", " + Awards.AwardAmount(who.Name) + " awards");
|
||||
Player.Message(p, " &a{0} &cdeaths%S, &a{2} %S{3}, {1} %Sawards",
|
||||
who.Deaths, Awards.AwardAmount(who.Name), who.Money, Server.moneys);
|
||||
else
|
||||
Player.Message(p, " &a" + who.Deaths + " &cdeaths%S, " + Awards.AwardAmount(who.Name) + " awards");
|
||||
Player.Message(p, " &a{0} &cdeaths%S, {1} %Sawards",
|
||||
who.Deaths, Awards.AwardAmount(who.Name));
|
||||
|
||||
if (who.LoginBlocks >= 0)
|
||||
Player.Message(p, " &bModified &a{0} &eblocks, &a{1} &esince login", who.TotalBlocks, who.LoginBlocks);
|
||||
Player.Message(p, " Modified &a{0} %Sblocks, &a{1} %Ssince login", who.TotalBlocks, who.LoginBlocks);
|
||||
else
|
||||
Player.Message(p, " &bModified &a{0} &eblocks", who.TotalBlocks);
|
||||
Player.Message(p, " Modified &a{0} %Sblocks", who.TotalBlocks);
|
||||
Player.Message(p, " &a0 %Splaced, &a0 %Sdeleted, &a{0} %Sdrawn", who.TotalDrawn);
|
||||
|
||||
if (who.TimeOnline.Ticks > 0)
|
||||
Player.Message(p, " Spent {0} on the server, {1} this session", who.TimeSpent.Shorten(), who.TimeOnline.Shorten());
|
||||
Player.Message(p, " Spent &a{0}%S on the server, &a{1}%S this session",
|
||||
who.TimeSpent.Shorten(), who.TimeOnline.Shorten());
|
||||
else
|
||||
Player.Message(p, " Spent {0} on the server", who.TimeSpent.Shorten());
|
||||
Player.Message(p, " Spent &a{0}%S on the server", who.TimeSpent.Shorten());
|
||||
|
||||
if (who.Last.Ticks > 0)
|
||||
Player.Message(p, " First login &a" + who.First.ToString("yyyy-MM-dd")
|
||||
|
||||
@ -35,19 +35,19 @@ namespace MCGalaxy.Commands {
|
||||
if (!ValidName(p, args[1], "player")) return;
|
||||
|
||||
if (PlayerInfo.FindExact(args[0]) != null) {
|
||||
Player.SendMessage(p, "\"" + args[0] + "\" must be offline to use /infoswap."); return;
|
||||
Player.Message(p, "\"{0}\" must be offline to use /infoswap.", args[0]); return;
|
||||
}
|
||||
if (PlayerInfo.FindExact(args[1]) != null) {
|
||||
Player.SendMessage(p, "\"" + args[1] + "\" must be offline to use /infoswap."); return;
|
||||
Player.Message(p, "\"{0}\" must be offline to use /infoswap.", args[1]); return;
|
||||
}
|
||||
|
||||
OfflinePlayer src = PlayerInfo.Find(args[0], true);
|
||||
if (src == null) {
|
||||
Player.SendMessage(p, "\"" + args[0] + "\" was not found in the database."); return;
|
||||
Player.Message(p, "\"{0}\" was not found in the database.", args[0]); return;
|
||||
}
|
||||
OfflinePlayer dst = PlayerInfo.Find(args[1], true);
|
||||
if (dst == null) {
|
||||
Player.SendMessage(p, "\"" + args[1] + "\" was not found in the database."); return;
|
||||
Player.Message(p, "\"{0}\" was not found in the database.", args[1]); return;
|
||||
}
|
||||
|
||||
Swap(src, dst); Swap(dst, src);
|
||||
@ -58,11 +58,11 @@ namespace MCGalaxy.Commands {
|
||||
void Swap(OfflinePlayer src, OfflinePlayer dst) {
|
||||
string first = DateTime.Parse(src.firstLogin).ToString(format);
|
||||
string last = DateTime.Parse(src.lastLogin).ToString(format);
|
||||
const string syntax = "UPDATE Players SET totalBlocks=@0, color=@1, totalDeaths=@2"
|
||||
+ ", FirstLogin=@3, IP=@4, totalKicked=@5, LastLogin=@6, totalLogin=@7"
|
||||
+ ", Money=@8, Title=@9, title_color=@10, TimeSpent=@11 WHERE Name=@12";
|
||||
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";
|
||||
|
||||
Database.Execute(syntax, src.blocks, src.color, src.deaths,
|
||||
Database.Execute(syntax, src.blocks, src.cuboided, src.color, src.deaths,
|
||||
first, src.ip, src.kicks, last, src.logins,
|
||||
src.money, src.title, src.titleColor, src.totalTime, dst.name);
|
||||
}
|
||||
|
||||
@ -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 => {}); break;
|
||||
SetInteger(p, args, "totalCuboided", int.MaxValue, who, v => who.TotalBlocksDrawn = v); break;
|
||||
case "totalkicked":
|
||||
SetInteger(p, args, "totalKicked", 1000000000, who, v => who.totalKicked = v); break;
|
||||
case "timespent":
|
||||
|
||||
@ -140,11 +140,12 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
lvl.SetTile(b.X, b.Y, b.Z, b.Block, p, b.ExtBlock);
|
||||
p.loginBlocks++;
|
||||
p.overallBlocks++;
|
||||
p.TotalBlocksDrawn++;
|
||||
}
|
||||
} else if (item.Level.bufferblocks) {
|
||||
foreach (var b in item.Op.Perform(item.Marks, p, lvl, item.Brush)) {
|
||||
if (b.Block == Block.Zero) continue;
|
||||
if (!lvl.DoBlockchange(p, b.X, b.Y, b.Z, b.Block, b.ExtBlock)) continue;
|
||||
if (!lvl.DoBlockchange(p, b.X, b.Y, b.Z, b.Block, b.ExtBlock, true)) continue;
|
||||
bP.name = p.name;
|
||||
bP.index = lvl.PosToInt(b.X, b.Y, b.Z);
|
||||
bP.SetData(b.Block, b.ExtBlock, b.Block == 0);
|
||||
@ -156,7 +157,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
} else {
|
||||
foreach (var b in item.Op.Perform(item.Marks, p, item.Level, item.Brush)) {
|
||||
if (b.Block == Block.Zero) continue;
|
||||
if (!lvl.DoBlockchange(p, b.X, b.Y, b.Z, b.Block, b.ExtBlock)) continue;
|
||||
if (!lvl.DoBlockchange(p, b.X, b.Y, b.Z, b.Block, b.ExtBlock, true)) continue;
|
||||
bP.name = p.name;
|
||||
bP.index = lvl.PosToInt(b.X, b.Y, b.Z);
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
|
||||
byte tile, extTile;
|
||||
item.GetBlock(out tile, out extTile);
|
||||
if (lvl.DoBlockchange(p, x, y, z, tile, extTile)) {
|
||||
if (lvl.DoBlockchange(p, x, y, z, tile, extTile, true)) {
|
||||
buffer.Add(lvl.PosToInt(x, y, z), tile, extTile);
|
||||
buffer.CheckIfSend(false);
|
||||
}
|
||||
|
||||
@ -263,12 +263,14 @@ namespace MCGalaxy {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Blockchange(Player p, ushort x, ushort y, ushort z, byte type, byte extType = 0) {
|
||||
if (DoBlockchange(p, x, y, z, type, extType))
|
||||
Player.GlobalBlockchange(this, x, y, z, type, extType);
|
||||
public void Blockchange(Player p, ushort x, ushort y, ushort z,
|
||||
byte block, byte extBlock = 0) {
|
||||
if (DoBlockchange(p, x, y, z, block, extBlock))
|
||||
Player.GlobalBlockchange(this, x, y, z, block, extBlock);
|
||||
}
|
||||
|
||||
public bool DoBlockchange(Player p, ushort x, ushort y, ushort z, byte type, byte extType = 0) {
|
||||
public bool DoBlockchange(Player p, ushort x, ushort y, ushort z,
|
||||
byte block, byte extBlock = 0, bool drawn = false) {
|
||||
string errorLocation = "start";
|
||||
retry:
|
||||
try
|
||||
@ -279,13 +281,13 @@ namespace MCGalaxy {
|
||||
if (b == Block.custom_block) extB = GetExtTile(x, y, z);
|
||||
|
||||
errorLocation = "Permission checking";
|
||||
if (!CheckAffectPermissions(p, x, y, z, b, type, extType)) {
|
||||
if (!CheckAffectPermissions(p, x, y, z, b, block, extBlock)) {
|
||||
p.RevertBlock(x, y, z); return false;
|
||||
}
|
||||
|
||||
if (b == Block.sponge && physics > 0 && type != Block.sponge)
|
||||
if (b == Block.sponge && physics > 0 && block != Block.sponge)
|
||||
OtherPhysics.DoSpongeRemoved(this, PosToInt(x, y, z));
|
||||
if (b == Block.lava_sponge && physics > 0 && type != Block.lava_sponge)
|
||||
if (b == Block.lava_sponge && physics > 0 && block != Block.lava_sponge)
|
||||
OtherPhysics.DoSpongeRemoved(this, PosToInt(x, y, z), true);
|
||||
|
||||
errorLocation = "Undo buffer filling";
|
||||
@ -293,27 +295,29 @@ namespace MCGalaxy {
|
||||
Pos.x = x; Pos.y = y; Pos.z = z;
|
||||
Pos.mapName = name;
|
||||
Pos.type = b; Pos.extType = extB;
|
||||
Pos.newtype = type; Pos.newExtType = extType;
|
||||
Pos.newtype = block; Pos.newExtType = extBlock;
|
||||
Pos.timeDelta = (int)DateTime.UtcNow.Subtract(Server.StartTime).TotalSeconds;
|
||||
p.UndoBuffer.Add(this, Pos);
|
||||
|
||||
errorLocation = "Setting tile";
|
||||
p.loginBlocks++;
|
||||
p.overallBlocks++;
|
||||
SetTile(x, y, z, type);
|
||||
if (b == Block.custom_block && type != Block.custom_block)
|
||||
if (drawn) p.TotalBlocksDrawn++;
|
||||
|
||||
SetTile(x, y, z, block);
|
||||
if (b == Block.custom_block && block != Block.custom_block)
|
||||
RevertExtTileNoCheck(x, y, z);
|
||||
if (type == Block.custom_block)
|
||||
SetExtTileNoCheck(x, y, z, extType);
|
||||
if (block == Block.custom_block)
|
||||
SetExtTileNoCheck(x, y, z, extBlock);
|
||||
|
||||
errorLocation = "Adding physics";
|
||||
if (p.PlayingTntWars && type == Block.smalltnt) AddTntCheck(PosToInt(x, y, z), p);
|
||||
if (physics > 0 && Block.Physics(type)) AddCheck(PosToInt(x, y, z));
|
||||
if (p.PlayingTntWars && block == Block.smalltnt) AddTntCheck(PosToInt(x, y, z), p);
|
||||
if (physics > 0 && Block.Physics(block)) AddCheck(PosToInt(x, y, z));
|
||||
|
||||
changed = true;
|
||||
backedup = false;
|
||||
bool diffBlock = b == Block.custom_block ? extB != extType :
|
||||
Block.Convert(b) != Block.Convert(type);
|
||||
bool diffBlock = b == Block.custom_block ? extB != extBlock :
|
||||
Block.Convert(b) != Block.Convert(block);
|
||||
return diffBlock;
|
||||
} catch (OutOfMemoryException) {
|
||||
Player.Message(p, "Undo buffer too big! Cleared!");
|
||||
@ -436,19 +440,20 @@ namespace MCGalaxy {
|
||||
return pos.X < Width && pos.Y < Height && pos.Z < Length;
|
||||
}
|
||||
|
||||
public void UpdateBlock(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
||||
if (!DoBlockchange(p, x, y, z, type, extType)) return;
|
||||
public void UpdateBlock(Player p, ushort x, ushort y, ushort z,
|
||||
byte block, byte extBlock, bool drawn = false) {
|
||||
if (!DoBlockchange(p, x, y, z, block, extBlock, drawn)) return;
|
||||
BlockPos bP = default(BlockPos);
|
||||
bP.name = p.name;
|
||||
bP.index = PosToInt(x, y, z);
|
||||
bP.SetData(type, extType, type == 0);
|
||||
bP.SetData(block, extBlock, block == 0);
|
||||
if (UseBlockDB)
|
||||
blockCache.Add(bP);
|
||||
|
||||
if (bufferblocks)
|
||||
BlockQueue.Addblock(p, bP.index, type, extType);
|
||||
BlockQueue.Addblock(p, bP.index, block, extBlock);
|
||||
else
|
||||
Player.GlobalBlockchange(this, x, y, z, type, extType);
|
||||
Player.GlobalBlockchange(this, x, y, z, block, extBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,8 +151,7 @@ namespace MCGalaxy {
|
||||
public bool canBuild = true;
|
||||
|
||||
public int money = 0, loginMoney = 0;
|
||||
public long overallBlocks = 0;
|
||||
|
||||
public long overallBlocks = 0, TotalBlocksDrawn = 0;
|
||||
public int loginBlocks = 0;
|
||||
|
||||
public DateTime timeLogged;
|
||||
|
||||
@ -82,7 +82,6 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
SendMessage("You have modified &a" + overallBlocks + " %Sblocks!");
|
||||
string prefix = players.Length == 1 ? "There is" : "There are";
|
||||
string suffix = players.Length == 1 ? " player online" : " players online";
|
||||
SendMessage(prefix + " currently &a" + players.Length + suffix);
|
||||
|
||||
@ -86,16 +86,16 @@ namespace MCGalaxy {
|
||||
|
||||
|
||||
public void save() {
|
||||
const string query = "UPDATE Players SET IP=@0, LastLogin=@1, totalLogin=@2, " +
|
||||
"totalDeaths=@3, Money=@4, totalBlocks=@5, totalKicked=@6, TimeSpent=@7 WHERE Name=@8";
|
||||
const string query = "UPDATE Players SET IP=@0, LastLogin=@1, totalLogin=@2, totalDeaths=@3, " +
|
||||
"Money=@4, totalBlocks=@5, totalCuboided=@6, totalKicked=@7, TimeSpent=@8 WHERE Name=@9";
|
||||
|
||||
if (MySQLSave != null) MySQLSave(this, query);
|
||||
OnMySQLSaveEvent.Call(this, query);
|
||||
if (cancelmysql) { cancelmysql = false; return; }
|
||||
|
||||
Database.Execute(query, ip, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
totalLogins, overallDeath, money, overallBlocks,
|
||||
totalKicked, time.ToDBTime(), name);
|
||||
totalLogins, overallDeath, money, overallBlocks,
|
||||
TotalBlocksDrawn, totalKicked, time.ToDBTime(), name);
|
||||
|
||||
if (Economy.Enabled && loginMoney != money) {
|
||||
Economy.EcoStats ecos = Economy.RetrieveEcoStats(name);
|
||||
@ -120,7 +120,8 @@ namespace MCGalaxy {
|
||||
GlobalBlockchange(level, x, y, z, block, extBlock);
|
||||
}
|
||||
|
||||
public static void GlobalBlockchange(Level level, ushort x, ushort y, ushort z, byte block, byte extBlock) {
|
||||
public static void GlobalBlockchange(Level level, ushort x, ushort y, ushort z,
|
||||
byte block, byte extBlock) {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player p in players) {
|
||||
if (p.level == level) p.SendBlockchange(x, y, z, block, extBlock);
|
||||
|
||||
@ -102,6 +102,7 @@ namespace MCGalaxy {
|
||||
p.totalKicked = 0;
|
||||
p.overallDeath = 0;
|
||||
p.overallBlocks = 0;
|
||||
p.TotalBlocksDrawn = 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" +
|
||||
@ -109,8 +110,8 @@ namespace MCGalaxy {
|
||||
Database.Execute(query, p.name, p.ip, now, now, 1, "", 0, 0, 0, 0, p.time.ToDBTime());
|
||||
|
||||
const string ecoQuery = "INSERT INTO Economy (player, money, total, purchase, payment, salary, fine) " +
|
||||
"VALUES (@0, @1, @2, @3, @4, @5, @6)";
|
||||
Database.Execute(ecoQuery, p.name, p.money, 0, "%cNone", "%cNone", "%cNone", "%cNone");
|
||||
"VALUES (@0, @1, @2, @3, @3, @3, @3)";
|
||||
Database.Execute(ecoQuery, p.name, p.money, 0, "%cNone");
|
||||
}
|
||||
|
||||
internal static void LoadInfo(DataTable playerDb, Player p) {
|
||||
@ -131,6 +132,8 @@ namespace MCGalaxy {
|
||||
|
||||
p.overallDeath = int.Parse(row["TotalDeaths"].ToString());
|
||||
p.overallBlocks = long.Parse(row["totalBlocks"].ToString().Trim());
|
||||
p.TotalBlocksDrawn = long.Parse(row["totalCuboided"].ToString().Trim());
|
||||
|
||||
//money = int.Parse(playerDb.Rows[0]["Money"].ToString());
|
||||
p.money = Economy.RetrieveEcoStats(p.name).money;
|
||||
p.loginMoney = p.money;
|
||||
@ -221,6 +224,7 @@ namespace MCGalaxy {
|
||||
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();
|
||||
return pl;
|
||||
@ -239,7 +243,7 @@ namespace MCGalaxy {
|
||||
|
||||
public class OfflinePlayer {
|
||||
public string name, color, title, titleColor;
|
||||
public string money, deaths, blocks, logins, kicks;
|
||||
public string money, deaths, blocks, cuboided, logins, kicks;
|
||||
public string totalTime, firstLogin, lastLogin, ip;
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ namespace MCGalaxy.Util {
|
||||
P.timeDelta = timeDelta;
|
||||
|
||||
if (pl != null) {
|
||||
if (lvl.DoBlockchange(pl, P.x, P.y, P.z, P.newtype, P.newExtType)) {
|
||||
if (lvl.DoBlockchange(pl, P.x, P.y, P.z, P.newtype, P.newExtType, true)) {
|
||||
buffer.Add(lvl.PosToInt(P.x, P.y, P.z), P.newtype, P.newExtType);
|
||||
buffer.CheckIfSend(false);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user