From ea833ebfcae4fff9b6d58cdf0e5f57cd88a905c6 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 17 Feb 2016 12:41:41 +1100 Subject: [PATCH] Cleanup /help and make it have one consistent style, also add /help commandsall which also shows min rank colours. --- Commands/Chat/CmdGlobalCLS.cs | 83 +++++++++------------ Commands/Chat/CmdPlayerCLS.cs | 65 +++++++---------- Commands/Information/CmdHelp.cs | 123 +++++++++++--------------------- Commands/other/CmdServer.cs | 1 - Network/Player.Networking.cs | 7 ++ Player/Player.Handlers.cs | 2 +- Server/Properties.cs | 11 --- Server/Server.cs | 2 - 8 files changed, 110 insertions(+), 184 deletions(-) diff --git a/Commands/Chat/CmdGlobalCLS.cs b/Commands/Chat/CmdGlobalCLS.cs index ee8eb872f..c4195a1c6 100644 --- a/Commands/Chat/CmdGlobalCLS.cs +++ b/Commands/Chat/CmdGlobalCLS.cs @@ -1,52 +1,37 @@ /* - Copyright 2011 MCGalaxy - - 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. -*/ -namespace MCGalaxy.Commands -{ - public sealed class CmdGlobalCLS : Command - { - public override string name { get { return "globalcls"; } } - public override string shortcut { get { return "gcls"; } } - public override string type { get { return CommandTypes.Chat; } } - public override bool museumUsable { get { return true; } } - public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } + Copyright 2011 MCGalaxy + + 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. + */ +namespace MCGalaxy.Commands { + + public sealed class CmdGlobalCLS : Command { + public override string name { get { return "globalcls"; } } + public override string shortcut { get { return "gcls"; } } + public override string type { get { return CommandTypes.Chat; } } + public override bool museumUsable { get { return true; } } + public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } - public override void Use(Player p, string message) - { - int i = 0; - for (i = 0; i < 20; i++) - { - PlayerInfo.players.ForEach(delegate(Player p1) { BlankMessage(p1); }); - } - Player.GlobalMessage("%4Global Chat Cleared."); - } - //Yes this does work - //Trust me...I'm a doctor - public void BlankMessage(Player p) - { - byte[] buffer = new byte[66]; - buffer[0] = Opcode.Message; - NetUtils.WriteAscii("", buffer, 2); - p.SendRaw(buffer); - buffer = null; - } - public override void Help(Player p) - { - Player.SendMessage(p, "/globalcls - Clears the chat for all users."); - } - } + public override void Use(Player p, string message) { + for (int i = 0; i < 20; i++) + PlayerInfo.players.ForEach(pl => pl.SendBlankMessage()); + Player.GlobalMessage("%4Global Chat Cleared."); + } + + public override void Help(Player p) { + Player.SendMessage(p, "/globalcls - Clears the chat for all users."); + } + } } diff --git a/Commands/Chat/CmdPlayerCLS.cs b/Commands/Chat/CmdPlayerCLS.cs index 6e7657c61..a47c72ab5 100644 --- a/Commands/Chat/CmdPlayerCLS.cs +++ b/Commands/Chat/CmdPlayerCLS.cs @@ -1,51 +1,36 @@ /* - Copyright 2011 MCGalaxy - - 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. -*/ -namespace MCGalaxy.Commands -{ - public sealed class CmdPlayerCLS : Command - { + Copyright 2011 MCGalaxy + + 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. + */ +namespace MCGalaxy.Commands { + + public sealed class CmdPlayerCLS : Command { public override string name { get { return "playercls"; } } public override string shortcut { get { return "cls"; } } public override string type { get { return CommandTypes.Chat; } } public override bool museumUsable { get { return true; } } public override LevelPermission defaultRank { get { return LevelPermission.Guest; } } - public override void Use(Player p, string message) - { - int i = 0; - for (i = 0; i < 20; i++) - { - BlankMessage(p); - } - Player.SendMessage(p, "%4Chat cleared."); + public override void Use(Player p, string message) { + for (int i = 0; i < 20; i++) + p.SendBlankMessage(); + Player.SendMessage(p, "%4Chat cleared."); } - //Yes this does work - //Trust me...I'm a doctor - public void BlankMessage(Player p) - { - byte[] buffer = new byte[66]; - buffer[0] = Opcode.Message; - NetUtils.WriteAscii("", buffer, 2); - p.SendRaw(buffer); - buffer = null; - } - public override void Help(Player p) - { + + public override void Help(Player p) { Player.SendMessage(p, "/playercls - Clears your chat."); } } diff --git a/Commands/Information/CmdHelp.cs b/Commands/Information/CmdHelp.cs index 0e170b5b8..36becb3db 100644 --- a/Commands/Information/CmdHelp.cs +++ b/Commands/Information/CmdHelp.cs @@ -29,97 +29,50 @@ namespace MCGalaxy.Commands { switch (message.ToLower()) { - case "": - if (Server.oldHelp) - { - goto case "old"; - } - if (Server.menustyle != 1) - { - Player.SendMessage(p, "Use &b/help ranks" + Server.DefaultColor + " for a list of ranks."); - Player.SendMessage(p, "Use &b/help build" + Server.DefaultColor + " for a list of building commands."); - Player.SendMessage(p, "Use &b/help chat" + Server.DefaultColor + " for a list of chat commands."); - Player.SendMessage(p, "Use &b/help economy" + Server.DefaultColor + " for a list of economy commands."); - Player.SendMessage(p, "Use &b/help games" + Server.DefaultColor + " for a list of game commands."); - Player.SendMessage(p, "Use &b/help information" + Server.DefaultColor + " for a list of information commands."); - Player.SendMessage(p, "Use &b/help mod" + Server.DefaultColor + " for a list of moderation commands."); - Player.SendMessage(p, "Use &b/help other" + Server.DefaultColor + " for a list of other commands."); - Player.SendMessage(p, "Use &b/help world" + Server.DefaultColor + " for a list of world/map commands."); - - Player.SendMessage(p, "Use &b/help colors" + Server.DefaultColor + " to view the color codes."); - Player.SendMessage(p, "Use &b/help shortcuts" + Server.DefaultColor + " for a list of shortcuts."); - Player.SendMessage(p, "Use &b/help old" + Server.DefaultColor + " to view the Old help menu."); - Player.SendMessage(p, "Use &b/help [command] or /help [block] " + Server.DefaultColor + "to view more info."); - } - else - { - Player.SendMessage(p, Server.DefaultColor + " To see a list of all commands, write %a/Help List"); - Player.SendMessage(p, Server.DefaultColor + " To see detailed help for a command, write %a/Help Command"); - Player.SendMessage(p, Server.DefaultColor + " To see your stats, write %a/Whois"); - Player.SendMessage(p, Server.DefaultColor + " To see loaded maps, write %a/Maps"); - Player.SendMessage(p, Server.DefaultColor + " To view your personal world options, use %a/OS"); - Player.SendMessage(p, Server.DefaultColor + " To join a Map, write %a/Goto WorldName"); - Player.SendMessage(p, Server.DefaultColor + " To send private messages, write %a@PlayerName Message"); - - } - break; - case "list": - message = ""; - Player.SendMessage(p, Server.DefaultColor + " To view all commands in a category, write %a/Help Category"); - Player.SendMessage(p, Server.DefaultColor + "Command Categories:"); - Player.SendMessage(p, " %aBuilding"); - Player.SendMessage(p, " %aChat"); - Player.SendMessage(p, " %aEconomy"); - Player.SendMessage(p, " %aGames"); - Player.SendMessage(p, " %aInfo"); - Player.SendMessage(p, " %aModeration"); - Player.SendMessage(p, " %aOther"); - Player.SendMessage(p, " %aWorld"); - - Player.SendMessage(p, " %aRanks"); - Player.SendMessage(p, " %aColors"); - Player.SendMessage(p, " %aShortcuts"); - Player.SendMessage(p, " %aOldMenu"); + case "": + Player.SendMessage(p, "Command Categories:"); + Player.SendMessage(p, " %aBuilding Chat Economy Games Info Moderation Other World"); + Player.SendMessage(p, "Other Categories:"); + Player.SendMessage(p, " %aRanks Colors Shortcuts Commands"); + Player.SendMessage(p, "To view help for a category, type %T/help CategoryName"); + Player.SendMessage(p, "To see detailed help for a command, type %T/help CommandName"); + Player.SendMessage(p, "To see your stats, type %T/whois"); + Player.SendMessage(p, "To see loaded maps, type %T/maps"); + Player.SendMessage(p, "To view your personal world options, use %T/OS"); + Player.SendMessage(p, "To join a map, type %T/goto WorldName"); + Player.SendMessage(p, "To send private messages, type %T@PlayerName Message"); break; case "ranks": message = ""; foreach (Group grp in Group.GroupList) { - if (grp.name != "nobody") // Note that -1 means max undo. Undo anything and everything. + if (grp.Permission < LevelPermission.Nobody) // Note that -1 means max undo. Undo anything and everything. Player.SendMessage(p, grp.color + grp.name + " - &bCmd: " + grp.maxBlocks + " - &2Undo: " + ((grp.maxUndo != -1) ? grp.maxUndo.ToString() : "max") + " - &cPerm: " + (int)grp.Permission); } break; case "build": case "building": - PrintHelpForGroup(p, "build", "Building" ); - break; + PrintHelpForGroup(p, "build", "Building" ); break; case "chat": - PrintHelpForGroup(p, "chat", "Chat" ); - break; + PrintHelpForGroup(p, "chat", "Chat" ); break; case "eco": case "economy": - PrintHelpForGroup(p, "eco", "Economy" ); - break; + PrintHelpForGroup(p, "eco", "Economy" ); break; case "mod": case "moderation": - PrintHelpForGroup(p, "mod", "Moderation" ); - break; + PrintHelpForGroup(p, "mod", "Moderation" ); break; case "info": case "information": - PrintHelpForGroup(p, "info", "Information" ); - break; + PrintHelpForGroup(p, "info", "Information" ); break; case "game": case "games": - PrintHelpForGroup(p, "game", "Game" ); - break; + PrintHelpForGroup(p, "game", "Game" ); break; case "other": case "others": - PrintHelpForGroup(p, "other", "Other" ); - break; + PrintHelpForGroup(p, "other", "Other" ); break; case "maps": case "world": - PrintHelpForGroup(p, "world", "World" ); - break; + PrintHelpForGroup(p, "world", "World" ); break; case "short": case "shortcut": case "shortcuts": @@ -129,13 +82,12 @@ namespace MCGalaxy.Commands case "short 2": case "shortcut 2": case "shortcuts 2": - bool list1 = true; - try { if (message.Split()[1] == "2") list1 = false; } catch { } + bool list1 = message[message.Length - 1] != '2'; message = ""; List shortcuts = new List(); foreach (Command comm in Command.all.commands) if (p == null || p.group.commands.All().Contains(comm)) - if (comm.shortcut != "") shortcuts.Add(", &b" + comm.shortcut + " " + Server.DefaultColor + "[" + comm.name + "]"); + if (comm.shortcut != "") shortcuts.Add(", &b" + comm.shortcut + " %S[" + comm.name + "]"); int top = list1 ? shortcuts.Count / 2 : shortcuts.Count; for (int i = list1 ? 0 : shortcuts.Count / 2; i < top; i++) message += shortcuts[i]; @@ -153,14 +105,14 @@ namespace MCGalaxy.Commands case "colors": Player.SendMessage(p, "&fTo use a color simply put a '%' sign symbol before you put the color code."); Player.SendMessage(p, "Colors Available:"); - Player.SendMessage(p, "0 - &0Black " + Server.DefaultColor + "| 8 - &8Gray"); - Player.SendMessage(p, "1 - &1Navy " + Server.DefaultColor + "| 9 - &9Blue"); - Player.SendMessage(p, "2 - &2Green " + Server.DefaultColor + "| a - &aLime"); - Player.SendMessage(p, "3 - &3Teal " + Server.DefaultColor + "| b - &bAqua"); - Player.SendMessage(p, "4 - &4Maroon " + Server.DefaultColor + "| c - &cRed"); - Player.SendMessage(p, "5 - &5Purple " + Server.DefaultColor + "| d - &dPink"); - Player.SendMessage(p, "6 - &6Gold " + Server.DefaultColor + "| e - &eYellow"); - Player.SendMessage(p, "7 - &7Silver " + Server.DefaultColor + "| f - &fWhite"); + Player.SendMessage(p, "0 - &0Black %S| 8 - &8Gray"); + Player.SendMessage(p, "1 - &1Navy %S| 9 - &9Blue"); + Player.SendMessage(p, "2 - &2Green %S| a - &aLime"); + Player.SendMessage(p, "3 - &3Teal %S| b - &bAqua"); + Player.SendMessage(p, "4 - &4Maroon %S| c - &cRed"); + Player.SendMessage(p, "5 - &5Purple %S| d - &dPink"); + Player.SendMessage(p, "6 - &6Gold %S| e - &eYellow"); + Player.SendMessage(p, "7 - &7Silver %S| f - &fWhite"); break; case "old": case "oldmenu": @@ -174,8 +126,19 @@ namespace MCGalaxy.Commands Player.SendMessage(p, commandsFound.Remove(0, 2)); Player.SendMessage(p, "Type \"/help \" for more help."); Player.SendMessage(p, "Type \"/help shortcuts\" for shortcuts."); - if (!Server.oldHelp) Player.SendMessage(p, "%bIf you can't see all commands, type %f/help %band choose a help type."); + Player.SendMessage(p, "%bIf you can't see all commands, type %f/help %band choose a help category."); break; + case "commandsall": + case "commandall": + string commandsAllFound = ""; + foreach (Command comm in Command.all.commands) + try { commandsAllFound += ", " + getColor(comm.name) + comm.name; } catch { } + Player.SendMessage(p, "All commands:"); + Player.SendMessage(p, commandsAllFound.Remove(0, 2)); + Player.SendMessage(p, "Type \"/help \" for more help."); + Player.SendMessage(p, "Type \"/help shortcuts\" for shortcuts."); + Player.SendMessage(p, "%bIf you can't see all commands, type %f/help %band choose a help category."); + break; default: Command cmd = Command.all.Find(message); if (cmd != null) diff --git a/Commands/other/CmdServer.cs b/Commands/other/CmdServer.cs index 8675fed18..18cc78fad 100644 --- a/Commands/other/CmdServer.cs +++ b/Commands/other/CmdServer.cs @@ -249,7 +249,6 @@ namespace MCGalaxy.Commands Server.physUndo = 20000; Server.totalUndo = 200; Server.rankSuper = true; - Server.oldHelp = false; Server.parseSmiley = true; Server.useWhitelist = false; Server.forceCuboid = false; diff --git a/Network/Player.Networking.cs b/Network/Player.Networking.cs index 57ab04030..9ceae3586 100644 --- a/Network/Player.Networking.cs +++ b/Network/Player.Networking.cs @@ -152,6 +152,13 @@ namespace MCGalaxy { #endif } } + + public void SendBlankMessage() { + byte[] buffer = new byte[66]; + buffer[0] = Opcode.Message; + NetUtils.WriteAscii("", buffer, 2); + SendRaw(buffer); + } public static void SendMessage(Player p, string message) { SendMessage(p, message, true); diff --git a/Player/Player.Handlers.cs b/Player/Player.Handlers.cs index deba38ba3..3c0a5c33c 100644 --- a/Player/Player.Handlers.cs +++ b/Player/Player.Handlers.cs @@ -1556,7 +1556,7 @@ return; case "box": cmd = "cuboid"; return true; case "sphere": cmd = "spheroid"; return true; case "cmdlist": - case "commands": cmd = "help"; message = "old"; return true; + case "commands": cmd = "help"; message = "commands"; return true; case "cmdhelp": cmd = "help"; return true; case "worlds": case "mapsave": cmd = "save"; return true; diff --git a/Server/Properties.cs b/Server/Properties.cs index c161084cb..c318f9cc3 100644 --- a/Server/Properties.cs +++ b/Server/Properties.cs @@ -239,10 +239,6 @@ namespace MCGalaxy { } Server.IRCColour = color; break; - case "old-help": - try { Server.oldHelp = bool.Parse(value); } - catch { Server.s.Log("Invalid " + key + ". Using default."); break; } - break; case "opchat-perm": try { sbyte parsed = sbyte.Parse(value); @@ -629,11 +625,6 @@ namespace MCGalaxy { Server.IgnoreOmnibans = false; } break; - - case "menu-style": - try { Server.menustyle = Convert.ToInt32(value); } - catch { Server.s.Log("menu-style value invalid! setting to default."); } - break; } } } @@ -771,7 +762,6 @@ namespace MCGalaxy { w.WriteLine("auto-restart = " + Server.autorestart.ToString().ToLower()); w.WriteLine("restarttime = " + Server.restarttime.ToShortTimeString()); w.WriteLine("restart-on-error = " + Server.restartOnError); - w.WriteLine("menu-style = " + Server.menustyle.ToString()); w.WriteLine("main-name = " + Server.level); w.WriteLine("default-texture-url = " + Server.defaultTerrainUrl); w.WriteLine("default-texture-pack-url = " + Server.defaultTexturePackUrl); @@ -792,7 +782,6 @@ namespace MCGalaxy { w.WriteLine("rplimit = " + Server.rpLimit.ToString().ToLower()); w.WriteLine("rplimit-norm = " + Server.rpNormLimit.ToString().ToLower()); w.WriteLine("physicsrestart = " + Server.physicsRestart.ToString().ToLower()); - w.WriteLine("old-help = " + Server.oldHelp.ToString().ToLower()); w.WriteLine("deathcount = " + Server.deathcount.ToString().ToLower()); w.WriteLine("afk-minutes = " + Server.afkminutes.ToString()); w.WriteLine("afk-kick = " + Server.afkkick.ToString()); diff --git a/Server/Server.cs b/Server/Server.cs index 43a90f392..3b9a575db 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -232,7 +232,6 @@ namespace MCGalaxy public static string name = "[MCGalaxy] Default"; public static string motd = "Welcome!"; public static byte players = 12; - public static int menustyle = 0; //for the limiting no. of guests: public static byte maxGuests = 10; @@ -287,7 +286,6 @@ namespace MCGalaxy public static int physUndo = 20000; public static int totalUndo = 200; public static bool rankSuper = true; - public static bool oldHelp = false; public static bool parseSmiley = true; public static bool useWhitelist = false; public static bool PremiumPlayersOnly = false;