From 08186c876c1575faed839fd0ef4d2b9b206c9959 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 28 May 2016 15:37:39 +1000 Subject: [PATCH] Remove /deltemprank, /temprankinfo, /tempranklist and combine them into /temprank. --- Commands/CommandKeywords.cs | 5 +- Commands/Information/CmdServerInfo.cs | 1 + Commands/Moderation/CmdDelTempRank.cs | 55 ------------ Commands/Moderation/CmdTempRank.cs | 113 ++++++++++++++++++++++--- Commands/Moderation/CmdTempRankInfo.cs | 61 ------------- Commands/Moderation/CmdTempRankList.cs | 43 ---------- MCGalaxy_.csproj | 3 - 7 files changed, 105 insertions(+), 176 deletions(-) delete mode 100644 Commands/Moderation/CmdDelTempRank.cs delete mode 100644 Commands/Moderation/CmdTempRankInfo.cs delete mode 100644 Commands/Moderation/CmdTempRankList.cs diff --git a/Commands/CommandKeywords.cs b/Commands/CommandKeywords.cs index f77bd275e..65bcf8de4 100644 --- a/Commands/CommandKeywords.cs +++ b/Commands/CommandKeywords.cs @@ -84,7 +84,6 @@ namespace MCGalaxy.Commands { new CommandKeywords((new CmdCuboid()), "box set area block"); new CommandKeywords((new CmdDelete()), "del mode"); new CommandKeywords((new CmdDeleteLvl()), "delete remove level lvl"); - new CommandKeywords((new CmdDelTempRank()), "del remove temp rank"); new CommandKeywords((new CmdDemote()), "rank lower"); new CommandKeywords((new CmdDevs()), "dev MCGalaxy forgeware forgecraft"); new CommandKeywords((new CmdDisagree()), "no rules"); @@ -212,7 +211,7 @@ namespace MCGalaxy.Commands { new CommandKeywords((new CmdSay()), "speak broad cast"); new CommandKeywords((new CmdSearch()), "find block command player rank"); new CommandKeywords((new CmdSeen()), "saw last user"); - new CommandKeywords((new CmdServerReport()), "report server"); + new CommandKeywords((new CmdServerInfo()), "report server"); new CommandKeywords((new CmdServer()), "setting option"); new CommandKeywords((new CmdSetRank()), "rank set user player"); new CommandKeywords((new CmdSetspawn()), "spawn set map level lvl"); @@ -228,8 +227,6 @@ namespace MCGalaxy.Commands { new CommandKeywords((new CmdTColor()), "title color set"); new CommandKeywords((new CmdTempBan()), "temp ban"); new CommandKeywords((new CmdTempRank()), "temp rank"); - new CommandKeywords((new CmdTempRankInfo()), "temp rank info"); - new CommandKeywords((new CmdTempRankList()), "temp rank list"); new CommandKeywords((new CmdTime()), "server"); new CommandKeywords((new CmdTimer()), "count down"); new CommandKeywords((new CmdTitle()), "set user"); diff --git a/Commands/Information/CmdServerInfo.cs b/Commands/Information/CmdServerInfo.cs index b632ee737..dd263d313 100644 --- a/Commands/Information/CmdServerInfo.cs +++ b/Commands/Information/CmdServerInfo.cs @@ -71,6 +71,7 @@ namespace MCGalaxy.Commands { Server.ProcessCounter = new PerformanceCounter("Process", "% Processor Time", proc.ProcessName); Server.ProcessCounter.BeginInit(); Server.ProcessCounter.NextValue(); + System.Threading.Thread.Sleep(500); } // Private Bytes because it is what the process has reserved for itself diff --git a/Commands/Moderation/CmdDelTempRank.cs b/Commands/Moderation/CmdDelTempRank.cs deleted file mode 100644 index 340253886..000000000 --- a/Commands/Moderation/CmdDelTempRank.cs +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright 2011 MCForge -Dual-licensed under the Educational Community License, Version 2.0 and -the GNU General Public License, Version 3 (the "Licenses"); you may -not use this file except in compliance with the Licenses. You may -obtain a copy of the Licenses at -http://www.opensource.org/licenses/ecl2.php -http://www.gnu.org/licenses/gpl-3.0.html -Unless required by applicable law or agreed to in writing, -software distributed under the Licenses are distributed on an "AS IS" -BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -or implied. See the Licenses for the specific language governing -permissions and limitations under the Licenses. - */ -using System; -using System.IO; -using System.Text; - -namespace MCGalaxy.Commands.Moderation { - public sealed class CmdDelTempRank : Command { - public override string name { get { return "deltemprank"; } } - public override string shortcut { get { return "dtr"; } } - public override string type { get { return CommandTypes.Moderation; } } - public override bool museumUsable { get { return true; } } - public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } - const StringComparison comp = StringComparison.OrdinalIgnoreCase; - - public override void Use(Player p, string message) { - bool assigned = false; - StringBuilder all = new StringBuilder(); - Player who = PlayerInfo.Find(message); - - foreach (string line in File.ReadAllLines("text/tempranks.txt")) { - if (!line.StartsWith(message, comp)) { all.AppendLine(line); continue; } - - string[] parts = line.Split(' '); - Group newgroup = Group.Find(parts[2]); - Command.all.Find("setrank").Use(null, message + " " + newgroup.name + " temp rank unassigned"); - Player.Message(p, "&eTemp rank of &a" + message + "&e has been unassigned"); - if (who != null) - Player.Message(who, "&eYour temp rank has been unassigned"); - assigned = true; - } - - if (!assigned) { - Player.Message(p, "&a" + message + "&c has not been assigned a temp rank."); return; - } - File.WriteAllText("text/tempranks.txt", all.ToString()); - } - - public override void Help(Player p) { - Player.Message(p, "/dtr - Deletes that player's temp rank"); - } - } -} diff --git a/Commands/Moderation/CmdTempRank.cs b/Commands/Moderation/CmdTempRank.cs index c100298d4..70ee1cf89 100644 --- a/Commands/Moderation/CmdTempRank.cs +++ b/Commands/Moderation/CmdTempRank.cs @@ -14,18 +14,42 @@ permissions and limitations under the Licenses. */ using System; using System.IO; +using System.Text; -namespace MCGalaxy.Commands.Moderation { - public sealed class CmdTempRank : Command { +namespace MCGalaxy.Commands.Moderation { + public sealed class CmdTempRank : Command { public override string name { get { return "temprank"; } } public override string shortcut { get { return "tr"; } } public override string type { get { return CommandTypes.Moderation; } } public override bool museumUsable { get { return true; } } - public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } - + public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } + public override CommandAlias[] Aliases { + get { return new[] { new CommandAlias("deltemprank", null, "delete"), + new CommandAlias("dtr", null, "delete"), new CommandAlias("temprankinfo", null, "info"), + new CommandAlias("trl", null, "list"), new CommandAlias("tempranklist", null, "list") }; } + } + const StringComparison comp = StringComparison.OrdinalIgnoreCase; + public override void Use(Player p, string message) { string[] args = message.Split(' '); - if (args.Length < 3) { Help(p); return; } + if (args.Length >= 3) { + Assign(p, args); + } else if (args.Length == 1) { + if (args[0].CaselessEq("list")) { + List(p); + } else { + Help(p); + } + } else if (args[1].CaselessEq("delete") || args[1].CaselessEq("remove")) { + Delete(p, args[0]); + } else if (args[1].CaselessEq("information") || args[1].CaselessEq("info")) { + Info(p, args[0]); + } else { + Help(p); + } + } + + static void Assign(Player p, string[] args) { string player = args[0], rank = args[1], period = args[2]; Player who = PlayerInfo.Find(player); if (who == null) { @@ -60,16 +84,85 @@ namespace MCGalaxy.Commands.Moderation { DateTime now = DateTime.Now; string assigner = p == null ? "Console" : p.name; string data = player + " " + rank + " " + pGroup.name + " " + period + " " + now.Minute + " " + - now.Hour + " " + now.Day + " " + now.Month + " " + now.Year + " " + assigner; + now.Hour + " " + now.Day + " " + now.Month + " " + now.Year + " " + assigner; Server.TempRanks.Append(data); - Command.all.Find("setrank").Use(null, who.name + " " + group.name + " assigning temp rank"); - Player.Message(p, "Temporary rank (" + rank + ") assigned succesfully to " + player + " for " + period + " hours"); - Player.Message(who, "Your Temporary rank (" + rank + ") is assigned succesfully for " + period + " hours"); + Command.all.Find("setrank").Use(null, player + " " + group.name + " assigning temp rank"); + Player.Message(p, "Temp ranked {0} to {1}%S for {2} hours", player, group.ColoredName, period); + if (who != null) + Player.Message(who, "You have been temp ranked to {0}%S for {1} hours", group.ColoredName, period); + } + + static void Delete(Player p, string name) { + bool assigned = false; + StringBuilder all = new StringBuilder(); + Player who = PlayerInfo.Find(name); + + foreach (string line in File.ReadAllLines("text/tempranks.txt")) { + if (!line.StartsWith(name, comp)) { all.AppendLine(line); continue; } + + string[] parts = line.Split(' '); + Group newgroup = Group.Find(parts[2]); + Command.all.Find("setrank").Use(null, name + " " + newgroup.name + " temp rank unassigned"); + Player.Message(p, "&eTemp rank of &a{0}&e has been unassigned", name); + if (who != null) + Player.Message(who, "&eYour temp rank has been unassigned"); + assigned = true; + } + + if (!assigned) { + Player.Message(p, "&a{0}&c has not been assigned a temp rank.", name); return; + } + File.WriteAllText("text/tempranks.txt", all.ToString()); + } + + static void Info(Player p, string name) { + foreach (string line in File.ReadAllLines("text/tempranks.txt")) { + if (!line.StartsWith(name, comp)) continue; + PrintTempRankInfo(p, line); return; + } + Player.Message(p, "&cPlayer &a{0}&chas not been assigned a temporary rank.", name); + } + + static void List(Player p) { + int count = 0; + foreach (string line in File.ReadAllLines("text/tempranks.txt")) { + if (count == 0) + Player.Message(p, "&ePlayers with a temporary rank assigned:"); + PrintTempRankInfo(p, line); + count++; + } + if (count == 0) + Player.Message(p, "&cThere are no players with a temporary rank assigned."); + } + + static void PrintTempRankInfo(Player p, string line) { + string[] args = line.Split(' '); + string temprank = args[1], oldrank = args[2], tempranker = args[9]; + int minutes = Convert.ToInt32(args[4]), hours = Convert.ToInt32(args[5]); + int days = Convert.ToInt32(args[6]), months = Convert.ToInt32(args[7]); + int years = Convert.ToInt32(args[8]); + + int period = Convert.ToInt32(args[3]); + Group oldGrp = Group.Find(oldrank), tempGrp = Group.Find(temprank); + string oldCol = oldGrp == null ? "" : oldGrp.color; + string tempCol = tempGrp == null ? "" : tempGrp.color; + + DateTime assignmentDate = new DateTime(years, months, days, hours, minutes, 0); + DateTime expireDate = assignmentDate.AddHours(Convert.ToDouble(period)); + Player.Message(p, "Temp rank information for {0}:", args[0]); + Player.Message(p, " From {0} %Sto {1}%S, by {2} on &a{3}%S, expires on &a{4}", + oldCol + oldrank, tempCol + temprank, tempranker, + assignmentDate, expireDate); } public override void Help(Player p) { - Player.Message(p, "/temprank - Sets a temporary rank for the specified player."); + Player.Message(p, "%T/temprank "); + Player.Message(p, "%HSets a temporary rank for the specified player."); + Player.Message(p, "%T/temprank info"); + Player.Message(p, "%HLists information about the temp rank for the given player."); + Player.Message(p, "%T/temprank delete %H- Removes player's temp rank."); + Player.Message(p, "%T/temprank list %H- Lists all current temp ranks."); } } } diff --git a/Commands/Moderation/CmdTempRankInfo.cs b/Commands/Moderation/CmdTempRankInfo.cs deleted file mode 100644 index c5d7ddc6e..000000000 --- a/Commands/Moderation/CmdTempRankInfo.cs +++ /dev/null @@ -1,61 +0,0 @@ -/* -Copyright 2011 MCForge -Dual-licensed under the Educational Community License, Version 2.0 and -the GNU General Public License, Version 3 (the "Licenses"); you may -not use this file except in compliance with the Licenses. You may -obtain a copy of the Licenses at -http://www.opensource.org/licenses/ecl2.php -http://www.gnu.org/licenses/gpl-3.0.html -Unless required by applicable law or agreed to in writing, -software distributed under the Licenses are distributed on an "AS IS" -BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -or implied. See the Licenses for the specific language governing -permissions and limitations under the Licenses. - */ -using System; -using System.IO; - -namespace MCGalaxy.Commands.Moderation { - public sealed class CmdTempRankInfo : Command { - public override string name { get { return "temprankinfo"; } } - 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 override void Use(Player p, string message) { - if (message == "") { Help(p); return; } - - foreach (string line in File.ReadAllLines("text/tempranks.txt")) { - if (!line.Contains(message)) continue; - PrintTempRankInfo(p, line); return; - } - Player.Message(p, "&cPlayer &a" + message + "&chas not been assigned a temporary rank."); - } - - internal static void PrintTempRankInfo(Player p, string line) { - string[] args = line.Split(' '); - string temprank = args[1], oldrank = args[2], tempranker = args[9]; - int minutes = Convert.ToInt32(args[4]), hours = Convert.ToInt32(args[5]); - int days = Convert.ToInt32(args[6]), months = Convert.ToInt32(args[7]); - int years = Convert.ToInt32(args[8]); - - int period = Convert.ToInt32(args[3]); - Group oldGrp = Group.Find(oldrank), tempGrp = Group.Find(temprank); - string oldCol = oldGrp == null ? "" : oldGrp.color; - string tempCol = tempGrp == null ? "" : tempGrp.color; - - DateTime assignmentDate = new DateTime(years, months, days, hours, minutes, 0); - DateTime expireDate = assignmentDate.AddHours(Convert.ToDouble(period)); - Player.Message(p, "Temp rank information for " + args[0] + ":"); - Player.Message(p, "From " + oldCol + oldrank + " %Sto " - + tempCol + temprank + "%S, by " + tempranker); - Player.Message(p, "Ranked on &a" + assignmentDate.ToString() + - "%S, expires &a" + expireDate.ToString()); - } - - public override void Help(Player p) { - Player.Message(p, "/tri - Lists the info about the temp rank of the given player"); - } - } -} diff --git a/Commands/Moderation/CmdTempRankList.cs b/Commands/Moderation/CmdTempRankList.cs deleted file mode 100644 index 3c65de1ab..000000000 --- a/Commands/Moderation/CmdTempRankList.cs +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright 2011 MCForge -Dual-licensed under the Educational Community License, Version 2.0 and -the GNU General Public License, Version 3 (the "Licenses"); you may -not use this file except in compliance with the Licenses. You may -obtain a copy of the Licenses at -http://www.opensource.org/licenses/ecl2.php -http://www.gnu.org/licenses/gpl-3.0.html -Unless required by applicable law or agreed to in writing, -software distributed under the Licenses are distributed on an "AS IS" -BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -or implied. See the Licenses for the specific language governing -permissions and limitations under the Licenses. -*/ -using System.IO; - -namespace MCGalaxy.Commands.Moderation { - public sealed class CmdTempRankList : Command { - public override string name { get { return "tempranklist"; } } - public override string shortcut { get { return "trl"; } } - public override string type { get { return CommandTypes.Moderation; } } - public override bool museumUsable { get { return true; } } - public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } - - public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } - - int count = 0; - foreach (string line in File.ReadAllLines("text/tempranks.txt")) { - if (count == 0) - Player.Message(p, "&ePlayers with a temporary rank assigned:"); - CmdTempRankInfo.PrintTempRankInfo(p, line); - count++; - } - if (count == 0) - Player.Message(p, "&cThere are no players with a temporary rank assigned."); - } - - public override void Help(Player p) { - Player.Message(p, "/trl - Lists every user with a temporary rank"); - } - } -} diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index f49d49543..01fa15449 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -276,7 +276,6 @@ - @@ -312,8 +311,6 @@ - -