Relative timespans in /balance

This commit is contained in:
UnknownShadow200 2016-09-06 08:26:33 +10:00
parent 329fdb24e9
commit a557a05703
3 changed files with 31 additions and 14 deletions

View File

@ -59,7 +59,7 @@ namespace MCGalaxy.Commands {
Level[] loaded = LevelInfo.Loaded.Items; Level[] loaded = LevelInfo.Loaded.Items;
if (LevelInfo.FindExact(map) == null) if (LevelInfo.FindExact(map) == null)
CmdLoad.LoadLevel(p, map, Server.AutoLoad); CmdLoad.LoadLevel(p, map, "0", Server.AutoLoad);
if (LevelInfo.FindExact(map) != null) if (LevelInfo.FindExact(map) != null)
PlayerActions.ChangeMap(p, map); PlayerActions.ChangeMap(p, map);
} else if (cmd == "LB" || cmd == "LEVELBLOCK") { } else if (cmd == "LB" || cmd == "LEVELBLOCK") {

View File

@ -50,14 +50,30 @@ namespace MCGalaxy.Commands {
Economy.EcoStats ecos = Economy.RetrieveStats(target); Economy.EcoStats ecos = Economy.RetrieveStats(target);
Player.Message(p, " Total spent: &f" + ecos.TotalSpent + " &3" + Server.moneys); Player.Message(p, " Total spent: &f" + ecos.TotalSpent + " &3" + Server.moneys);
if (!(String.IsNullOrEmpty(ecos.Purchase) || ecos.Purchase == "%cNone")) Output(p, ecos.Purchase, "purchase");
Player.Message(p, " Last purchase: " + ecos.Purchase); Output(p, ecos.Payment, "payment");
if (!(String.IsNullOrEmpty(ecos.Payment) || ecos.Payment == "%cNone")) Output(p, ecos.Salary, "receipt");
Player.Message(p, " Last payment: " + ecos.Payment); Output(p, ecos.Fine, "fine");
if (!(String.IsNullOrEmpty(ecos.Salary) || ecos.Salary == "%cNone")) }
Player.Message(p, " Last receipt: " + ecos.Salary);
if (!(String.IsNullOrEmpty(ecos.Fine) || ecos.Fine == "%cNone")) const string dateFormat = "MM'/'dd'/'yyyy hh:mm:ss";
Player.Message(p, " Last fine: " + ecos.Fine); static void Output(Player p, string value, string type) {
if (String.IsNullOrEmpty(value) || value == "%cNone") return;
int timeIndex = value.IndexOf(" on %f");
if (timeIndex == -1) {
Player.Message(p, " Last {0}: {1}", type, value); return;
}
string msg = value.Substring(0, timeIndex);
string date = value.Substring(timeIndex + 6);
// Attempt to show relative time
DateTime time;
if (DateTime.TryParseExact(date, dateFormat, null, 0, out time)) {
TimeSpan delta = DateTime.Now - time;
value = msg + " %f" + delta.Shorten() + " ago";
}
Player.Message(p, " Last {0}: {1}", type, value);
} }
public override void Help(Player p) { public override void Help(Player p) {

View File

@ -79,7 +79,8 @@ namespace MCGalaxy.Commands.Building {
} }
internal static int GetBlock(Player p, string msg, out byte extBlock, bool checkPlacePerm = true) { public static int GetBlock(Player p, string msg, out byte extBlock,
bool checkPlacePerm = true) {
byte block = Block.Byte(msg); byte block = Block.Byte(msg);
extBlock = 0; extBlock = 0;
if (msg.CaselessEq("skip") || msg.CaselessEq("none")) return Block.Zero; if (msg.CaselessEq("skip") || msg.CaselessEq("none")) return Block.Zero;