From a4aec8a80e3712f188653fc7d93240deb1dedc37 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 30 May 2016 15:28:47 +1000 Subject: [PATCH] Cleanup /baninfo. --- Commands/CommandKeywords.cs | 2 +- .../CmdBanInfo.cs} | 37 ++++++++++++------- MCGalaxy_.csproj | 2 +- 3 files changed, 25 insertions(+), 16 deletions(-) rename Commands/{Moderation/CmdBaninfo.cs => Information/CmdBanInfo.cs} (55%) diff --git a/Commands/CommandKeywords.cs b/Commands/CommandKeywords.cs index 65bcf8de4..be517cfbb 100644 --- a/Commands/CommandKeywords.cs +++ b/Commands/CommandKeywords.cs @@ -54,7 +54,7 @@ namespace MCGalaxy.Commands { new CommandKeywords((new CmdBalance()), "cash " + Server.moneys); new CommandKeywords((new CmdBan()), "kick mod punish"); new CommandKeywords((new CmdBanEdit()), "reason edit ban"); - new CommandKeywords((new CmdBaninfo()), "info ban details"); + new CommandKeywords((new CmdBanInfo()), "info ban details"); new CommandKeywords((new CmdBanip()), "ip ban kick mod punish"); new CommandKeywords((new CmdBanlist()), "list ban info mod"); new CommandKeywords((new CmdBind()), "block replace"); diff --git a/Commands/Moderation/CmdBaninfo.cs b/Commands/Information/CmdBanInfo.cs similarity index 55% rename from Commands/Moderation/CmdBaninfo.cs rename to Commands/Information/CmdBanInfo.cs index 93fdb243e..b30899cb0 100644 --- a/Commands/Moderation/CmdBaninfo.cs +++ b/Commands/Information/CmdBanInfo.cs @@ -16,30 +16,39 @@ permissions and limitations under the Licenses. */ namespace MCGalaxy.Commands.Moderation { - public sealed class CmdBaninfo : Command { + public sealed class CmdBanInfo : Command { public override string name { get { return "baninfo"; } } public override string shortcut { get { return ""; } } public override string type { get { return CommandTypes.Moderation; } } public override bool museumUsable { get { return true; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } - public CmdBaninfo() { } + public CmdBanInfo() { } public override void Use(Player p, string message) { - if (message == "" || message.Length <= 3) { Help(p); return; } + if (message == "") { + if (p == null) { Player.Message(p, "Console must provide a player name."); return; } + message = p.name; + } + bool banned = Group.findPerm(LevelPermission.Banned).playerList.Contains(message); + string msg = message + (banned ? " is &CBANNED" : " is not banned"); string[] data = Ban.GetBanData(message); + if (data != null && banned) { + Group grp = Group.Find(data[3]); + string grpName = grp == null ? data[3] : grp.ColoredName; + msg += " %S(Former rank: " + grpName + "%S)"; + } + Player.Message(p, msg); + if (data != null) { - Player.Message(p, "&9User: &e" + message); - Player.Message(p, "&9Banned by: &e" + data[0]); - Player.Message(p, "&9Reason: &e" + data[1]); - Player.Message(p, "&9Date and time: &e" + data[2]); - Player.Message(p, "&9Old rank: &e" + data[3]); - string stealth = data[4] == "true" ? "&aYes" : "&cNo"; - Player.Message(p, "&9Stealth banned: " + stealth); - } else if (!Group.findPerm(LevelPermission.Banned).playerList.Contains(message)) { - Player.Message(p, "That player isn't banned"); - } else if (data == null) { - Player.Message(p, "Couldn't find ban info about " + message + "."); + string[] date = data[2].Split(' '); + data[2] = date[1] + "-" + date[2] + "-" + date[3] + " at " + date[5]; + data[2] = data[2].Replace(",", ""); + + Player.Message(p, "Banned on {0} by {1}", data[2], data[0]); + Player.Message(p, "Reason: {0}", data[1]); + } else { + Player.Message(p, "No ban data found for " + message + "."); } } diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index fccdcd782..bdca8f910 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -230,6 +230,7 @@ + @@ -269,7 +270,6 @@ -