From b851cd10f25c357651fc3fbe42aee939b7bb82ab Mon Sep 17 00:00:00 2001 From: KHobbits Date: Thu, 11 Aug 2011 06:56:33 +0100 Subject: [PATCH] Fix help for plugins which miss command descriptions. --- .../essentials/commands/Commandhelp.java | 99 ++++++++++--------- 1 file changed, 53 insertions(+), 46 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java index d73a2706b..53ed22a23 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java @@ -117,57 +117,64 @@ public class Commandhelp extends EssentialsCommand { final PluginDescriptionFile desc = p.getDescription(); final HashMap> cmds = (HashMap>)desc.getCommands(); + pluginName = p.getDescription().getName().toLowerCase(); for (Entry> k : cmds.entrySet()) { - if ((!match.equalsIgnoreCase("")) && (!k.getKey().toLowerCase().contains(match)) - && (!k.getValue().get("description").toLowerCase().contains(match)) - && (!p.getDescription().getName().contains(match))) + try + { + if ((!match.equalsIgnoreCase("")) + && (!k.getKey().toLowerCase().contains(match)) + && (!k.getValue().get("description").toLowerCase().contains(match)) + && (!pluginName.contains(match))) + { + continue; + } + + if (pluginName.contains("essentials")) + { + final String node = "essentials." + k.getKey(); + if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node)) + { + retval.add("§c" + k.getKey() + "§7: " + k.getValue().get("description")); + } + } + else + { + if (ess.getSettings().showNonEssCommandsInHelp()) + { + final HashMap value = k.getValue(); + if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals(""))) + { + if (user.isAuthorized(value.get("permission"))) + { + retval.add("§c" + k.getKey() + "§7: " + value.get("description")); + } + } + else if (value.containsKey("permissions") && value.get("permissions") != null && !(value.get("permissions").equals(""))) + { + if (user.isAuthorized(value.get("permissions"))) + { + retval.add("§c" + k.getKey() + "§7: " + value.get("description")); + } + } + else if (user.isAuthorized("essentials.help." + pluginName)) + { + retval.add("§c" + k.getKey() + "§7: " + value.get("description")); + } + else + { + if (!ess.getSettings().hidePermissionlessHelp()) + { + retval.add("§c" + k.getKey() + "§7: " + value.get("description")); + } + } + } + } + } + catch (NullPointerException ex) { continue; } - - if (p.getDescription().getName().toLowerCase().contains("essentials")) - { - final String node = "essentials." + k.getKey(); - if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node)) - { - retval.add("§c" + k.getKey() + "§7: " + k.getValue().get("description")); - } - } - else - { - if (ess.getSettings().showNonEssCommandsInHelp()) - { - pluginName = p.getDescription().getName(); - final HashMap value = k.getValue(); - if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals(""))) - { - if (user.isAuthorized(value.get("permission"))) - { - retval.add("§c" + k.getKey() + "§7: " + value.get("description")); - } - } - else if (value.containsKey("permissions") && value.get("permissions") != null && !(value.get("permissions").equals(""))) - { - if (user.isAuthorized(value.get("permissions"))) - { - retval.add("§c" + k.getKey() + "§7: " + value.get("description")); - } - } - else if (user.isAuthorized("essentials.help." + pluginName)) - { - retval.add("§c" + k.getKey() + "§7: " + value.get("description")); - } - else - { - if (!ess.getSettings().hidePermissionlessHelp()) - { - retval.add("§c" + k.getKey() + "§7: " + value.get("description")); - } - } - } - - } } } catch (NullPointerException ex)