Cleaned up the code slightly to be smaller

This commit is contained in:
Andrew 2013-11-06 21:30:14 +13:00
parent 9b8279e981
commit 897d6410d2

View File

@ -34,6 +34,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
} else { } else {
Enum[] enums = null; Enum[] enums = null;
String enumName = null; String enumName = null;
ArrayList<String> enumReturns = new ArrayList<String>();
if (args[0].equalsIgnoreCase("animalcolor") || args[0].equalsIgnoreCase("animalcolors")) { if (args[0].equalsIgnoreCase("animalcolor") || args[0].equalsIgnoreCase("animalcolors")) {
enums = AnimalColor.values(); enums = AnimalColor.values();
enumName = "Animal colors"; enumName = "Animal colors";
@ -50,21 +51,19 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
enums = Profession.values(); enums = Profession.values();
enumName = "Villager professions"; enumName = "Villager professions";
} else if (args[0].equalsIgnoreCase("PotionEffect") || args[0].equalsIgnoreCase("PotionEffects")) { } else if (args[0].equalsIgnoreCase("PotionEffect") || args[0].equalsIgnoreCase("PotionEffects")) {
ArrayList<String> potionTypes = new ArrayList<String>(); enumName = "Potioneffect types";
for (PotionEffectType potionType : PotionEffectType.values()) { for (PotionEffectType potionType : PotionEffectType.values()) {
if (potionType != null) if (potionType != null)
potionTypes.add(toReadable(potionType.getName()) + ChatColor.RED + "(" + ChatColor.GREEN enumReturns.add(toReadable(potionType.getName()) + ChatColor.RED + "(" + ChatColor.GREEN
+ potionType.getId() + ChatColor.RED + ")"); + potionType.getId() + ChatColor.RED + ")");
} }
sender.sendMessage(ChatColor.RED + "Potioneffect types: " + ChatColor.GREEN
+ StringUtils.join(potionTypes, ChatColor.RED + ", " + ChatColor.GREEN));
return true;
} }
if (enums != null) { if (enums != null) {
ArrayList<String> enumReturns = new ArrayList<String>();
for (Enum enumType : enums) { for (Enum enumType : enums) {
enumReturns.add(toReadable(enumType.name())); enumReturns.add(toReadable(enumType.name()));
} }
}
if (!enumReturns.isEmpty()) {
sender.sendMessage(ChatColor.RED + enumName + ": " + ChatColor.GREEN sender.sendMessage(ChatColor.RED + enumName + ": " + ChatColor.GREEN
+ StringUtils.join(enumReturns, ChatColor.RED + ", " + ChatColor.GREEN)); + StringUtils.join(enumReturns, ChatColor.RED + ", " + ChatColor.GREEN));
return true; return true;