mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 20:16:36 -04:00
Relative timespans in /balance
This commit is contained in:
parent
329fdb24e9
commit
a557a05703
@ -59,7 +59,7 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
Level[] loaded = LevelInfo.Loaded.Items;
|
||||
if (LevelInfo.FindExact(map) == null)
|
||||
CmdLoad.LoadLevel(p, map, Server.AutoLoad);
|
||||
CmdLoad.LoadLevel(p, map, "0", Server.AutoLoad);
|
||||
if (LevelInfo.FindExact(map) != null)
|
||||
PlayerActions.ChangeMap(p, map);
|
||||
} else if (cmd == "LB" || cmd == "LEVELBLOCK") {
|
||||
|
@ -26,17 +26,17 @@ namespace MCGalaxy.Commands {
|
||||
public override string type { get { return CommandTypes.Economy; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
|
||||
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
|
||||
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (CheckSuper(p, message, "player name")) return;
|
||||
if (!Formatter.ValidName(p, message, "player")) return;
|
||||
if (!Formatter.ValidName(p, message, "player")) return;
|
||||
int matches = 1;
|
||||
Player who = message == "" ? p : PlayerInfo.FindMatches(p, message, out matches);
|
||||
if (matches > 1) return;
|
||||
|
||||
string target = null;
|
||||
int money = 0;
|
||||
int money = 0;
|
||||
if (matches == 0) {
|
||||
target = Economy.FindMatches(p, message, out money);
|
||||
if (target == null) return;
|
||||
@ -50,20 +50,36 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
Economy.EcoStats ecos = Economy.RetrieveStats(target);
|
||||
Player.Message(p, " Total spent: &f" + ecos.TotalSpent + " &3" + Server.moneys);
|
||||
if (!(String.IsNullOrEmpty(ecos.Purchase) || ecos.Purchase == "%cNone"))
|
||||
Player.Message(p, " Last purchase: " + ecos.Purchase);
|
||||
if (!(String.IsNullOrEmpty(ecos.Payment) || ecos.Payment == "%cNone"))
|
||||
Player.Message(p, " Last payment: " + ecos.Payment);
|
||||
if (!(String.IsNullOrEmpty(ecos.Salary) || ecos.Salary == "%cNone"))
|
||||
Player.Message(p, " Last receipt: " + ecos.Salary);
|
||||
if (!(String.IsNullOrEmpty(ecos.Fine) || ecos.Fine == "%cNone"))
|
||||
Player.Message(p, " Last fine: " + ecos.Fine);
|
||||
Output(p, ecos.Purchase, "purchase");
|
||||
Output(p, ecos.Payment, "payment");
|
||||
Output(p, ecos.Salary, "receipt");
|
||||
Output(p, ecos.Fine, "fine");
|
||||
}
|
||||
|
||||
const string dateFormat = "MM'/'dd'/'yyyy hh:mm:ss";
|
||||
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) {
|
||||
Player.Message(p, "%T/balance [player]");
|
||||
Player.Message(p, "%HShows how much %3" + Server.moneys + " %H<player> has, " +
|
||||
"plus their most recent transactions.");
|
||||
"plus their most recent transactions.");
|
||||
Player.Message(p, "%HIf [player] is not given, shows your own balance.");
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
extBlock = 0;
|
||||
if (msg.CaselessEq("skip") || msg.CaselessEq("none")) return Block.Zero;
|
||||
|
Loading…
x
Reference in New Issue
Block a user