From 5c0402d8b36b98519eef0cbdfdeea3094273ed2e Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 24 Dec 2018 23:47:55 +1100 Subject: [PATCH] Fix /help (am major idiot) --- MCGalaxy/Commands/Information/CmdCommands.cs | 18 ++++++++++-------- MCGalaxy/Commands/Information/CmdHelp.cs | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/MCGalaxy/Commands/Information/CmdCommands.cs b/MCGalaxy/Commands/Information/CmdCommands.cs index 355e20381..5d17f401b 100644 --- a/MCGalaxy/Commands/Information/CmdCommands.cs +++ b/MCGalaxy/Commands/Information/CmdCommands.cs @@ -112,6 +112,7 @@ namespace MCGalaxy.Commands.Info { p.Message("Type %T/Help %Sfor more help on a command."); } + // common shortcuts people tend to use static string GetCategory(string type) { if (type.CaselessEq("building")) return CommandTypes.Building; if (type.CaselessEq("eco")) return CommandTypes.Economy; @@ -126,21 +127,22 @@ namespace MCGalaxy.Commands.Info { static bool PrintCategoryCommands(Player p, string sort, string modifier, string type) { List cmds = new List(); string category = GetCategory(type); - bool any = false; - + bool foundAny = false; + foreach (Command c in Command.allCmds) { string disabled = Command.GetDisabledReason(c.Enabled); - if (!c.type.CaselessContains(category)) continue; + if (!c.type.CaselessEq(category)) continue; if (disabled == null && p.CanUse(c)) cmds.Add(c); - any = true; - } + foundAny = true; + } + if (!foundAny) return false; if (cmds.Count == 0) { - p.Message("You cannot use any of the " + category + " commands."); return any; + p.Message("You cannot use any of the " + category + " commands."); return true; } SortCommands(cmds, sort); - p.Message(category + " commands you may use:"); + p.Message(category.Capitalize() + " commands you may use:"); type = "Commands " + type; if (sort.Length > 0) type += " " + sort; @@ -149,7 +151,7 @@ namespace MCGalaxy.Commands.Info { type, "commands", modifier, false); p.Message("Type %T/Help %Sfor more help on a command."); - return any; + return true; } static void SortCommands(List cmds, string sort) { diff --git a/MCGalaxy/Commands/Information/CmdHelp.cs b/MCGalaxy/Commands/Information/CmdHelp.cs index 6d41d465e..045aa8aa6 100644 --- a/MCGalaxy/Commands/Information/CmdHelp.cs +++ b/MCGalaxy/Commands/Information/CmdHelp.cs @@ -37,7 +37,7 @@ namespace MCGalaxy.Commands.Info { PrintColors(p); } else if (message.CaselessEq("emotes") || message.CaselessStarts("emotes ")) { PrintEmotes(p, message); - } else { + } else { if (CmdCommands.ListCommands(p, message)) return; if (ParseCommand(p, message) || ParseBlock(p, message) || ParsePlugin(p, message)) return; p.Message("Could not find command, plugin or block specified.");