From e0512d3f6cb2adffb8b7e4cdb168ba0bc2b9c1a8 Mon Sep 17 00:00:00 2001 From: Benford Whitaker Date: Mon, 9 Dec 2019 22:25:56 -0500 Subject: [PATCH] Fix NPE in help command (#1032) ## Fixes * Fixes NPE in help command by removing unnecessary side-plugin usage strings. --- .../projectkorra/command/HelpCommand.java | 26 ++----------------- .../configuration/ConfigManager.java | 3 --- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/src/com/projectkorra/projectkorra/command/HelpCommand.java b/src/com/projectkorra/projectkorra/command/HelpCommand.java index 81093262..5d3194d5 100644 --- a/src/com/projectkorra/projectkorra/command/HelpCommand.java +++ b/src/com/projectkorra/projectkorra/command/HelpCommand.java @@ -35,9 +35,6 @@ public class HelpCommand extends PKCommand { private final String avatar; private final String invalidTopic; private final String usage; - private final String rpgUsage; - private final String spiritsUsage; - private final String itemsUsage; public HelpCommand() { super("help", "/bending help ", ConfigManager.languageConfig.get().getString("Commands.Help.Description"), new String[] { "help", "h" }); @@ -54,9 +51,6 @@ public class HelpCommand extends PKCommand { this.avatar = ConfigManager.languageConfig.get().getString("Commands.Help.Elements.Avatar"); this.invalidTopic = ConfigManager.languageConfig.get().getString("Commands.Help.InvalidTopic"); this.usage = ConfigManager.languageConfig.get().getString("Commands.Help.Usage"); - this.rpgUsage = ConfigManager.languageConfig.get().getString("Command.Help.RPGUsage"); - this.spiritsUsage = ConfigManager.languageConfig.get().getString("Commands.Help.SpiritsUsage"); - this.itemsUsage = ConfigManager.languageConfig.get().getString("Commands.Help.ItemsUsage"); } @Override @@ -72,15 +66,7 @@ public class HelpCommand extends PKCommand { strings.add(command.getProperUse()); } } - if (GeneralMethods.hasItems()) { - strings.add(this.itemsUsage); - } - if (GeneralMethods.hasRPG()) { - strings.add(this.rpgUsage); - } - if (GeneralMethods.hasSpirits()) { - strings.add(this.spiritsUsage); - } + Collections.sort(strings); Collections.reverse(strings); strings.add(instances.get("help").getProperUse()); @@ -104,15 +90,7 @@ public class HelpCommand extends PKCommand { for (final PKCommand command : instances.values()) { strings.add(command.getProperUse()); } - if (GeneralMethods.hasItems()) { - strings.add(this.itemsUsage); - } - if (GeneralMethods.hasRPG()) { - strings.add(this.rpgUsage); - } - if (GeneralMethods.hasSpirits()) { - strings.add(this.spiritsUsage); - } + for (final String s : this.getPage(strings, ChatColor.GOLD + "Commands: <" + this.required + "> [" + this.optional + "]", Integer.valueOf(arg), true)) { if (firstMessage) { GeneralMethods.sendBrandingMessage(sender, s); diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index 231d9b9f..f3408e79 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -166,9 +166,6 @@ public class ConfigManager { config.addDefault("Commands.Help.Elements.LearnMore", "Learn more at our website! "); config.addDefault("Commands.Help.InvalidTopic", "That isn't a valid help topic. Use /bending help for more information."); config.addDefault("Commands.Help.Usage", "Usage: "); - config.addDefault("Commands.Help.RPGUsage", "/bending rpg [argument]"); - config.addDefault("Commands.Help.ItemsUsage", "/bending items [argument]"); - config.addDefault("Commands.Help.SpiritsUsage", "/bending spirits [argument]"); config.addDefault("Commands.Display.Description", "This command will show you all of the elements you have bound if you do not specify an element. If you do specify an element (Air, Water, Earth, Fire, or Chi), it will show you all of the available abilities of that element installed on the server.");