Fix help for plugins which miss command descriptions.

This commit is contained in:
KHobbits 2011-08-11 06:56:33 +01:00
parent 576b48c08c
commit b851cd10f2

View file

@ -117,16 +117,20 @@ public class Commandhelp extends EssentialsCommand
{ {
final PluginDescriptionFile desc = p.getDescription(); final PluginDescriptionFile desc = p.getDescription();
final HashMap<String, HashMap<String, String>> cmds = (HashMap<String, HashMap<String, String>>)desc.getCommands(); final HashMap<String, HashMap<String, String>> cmds = (HashMap<String, HashMap<String, String>>)desc.getCommands();
pluginName = p.getDescription().getName().toLowerCase();
for (Entry<String, HashMap<String, String>> k : cmds.entrySet()) for (Entry<String, HashMap<String, String>> k : cmds.entrySet())
{ {
if ((!match.equalsIgnoreCase("")) && (!k.getKey().toLowerCase().contains(match)) try
{
if ((!match.equalsIgnoreCase(""))
&& (!k.getKey().toLowerCase().contains(match))
&& (!k.getValue().get("description").toLowerCase().contains(match)) && (!k.getValue().get("description").toLowerCase().contains(match))
&& (!p.getDescription().getName().contains(match))) && (!pluginName.contains(match)))
{ {
continue; continue;
} }
if (p.getDescription().getName().toLowerCase().contains("essentials")) if (pluginName.contains("essentials"))
{ {
final String node = "essentials." + k.getKey(); final String node = "essentials." + k.getKey();
if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node)) if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node))
@ -138,7 +142,6 @@ public class Commandhelp extends EssentialsCommand
{ {
if (ess.getSettings().showNonEssCommandsInHelp()) if (ess.getSettings().showNonEssCommandsInHelp())
{ {
pluginName = p.getDescription().getName();
final HashMap<String, String> value = k.getValue(); final HashMap<String, String> value = k.getValue();
if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals(""))) if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals("")))
{ {
@ -166,7 +169,11 @@ public class Commandhelp extends EssentialsCommand
} }
} }
} }
}
}
catch (NullPointerException ex)
{
continue;
} }
} }
} }