package me.libraryaddict.disguise.commands; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.utilities.BaseDisguiseCommand; import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; public class DisguiseHelpCommand extends BaseDisguiseCommand { private class EnumHelp { private String enumDescription; private String enumName; private String[] enums; private String readableEnum; public EnumHelp(String enumName, String enumReadable, String enumDescription, Enum[] enums) { String[] strings = new String[enums.length]; for (int i = 0; i < strings.length; i++) { strings[i] = toReadable(enums[i].name()); } this.enumName = enumName; this.enumDescription = enumDescription; this.enums = strings; this.readableEnum = enumReadable; } public EnumHelp(String enumName, String enumReadable, String enumDescription, String[] enums) { this.enumName = enumName; this.enumDescription = enumDescription; this.enums = enums; this.readableEnum = enumReadable; } public String getEnumDescription() { return enumDescription; } public String getEnumName() { return enumName; } public String[] getEnums() { return enums; } public String getReadableEnum() { return readableEnum; } } private ArrayList enumHelp = new ArrayList(); public DisguiseHelpCommand() { try { enumHelp.add(new EnumHelp("AnimalColor", "Animal colors", ChatColor.RED + "/disguisehelp AnimalColors " + ChatColor.GREEN + "- View all the colors you can use for a animal color", AnimalColor.values())); } catch (Exception ex) { ex.printStackTrace(); } try { enumHelp.add(new EnumHelp("HorseColor", "Horse colors", ChatColor.RED + "/disguisehelp HorseColors " + ChatColor.GREEN + "- View all the colors you can use for a horses color", (Enum[]) Class.forName( "org.bukkit.entity.Horse$Color").getEnumConstants())); } catch (Exception ex) { } try { enumHelp.add(new EnumHelp("HorseStyle", "Horse styles", ChatColor.RED + "/disguisehelp HorseStyles " + ChatColor.GREEN + "- View all the styles you can use for a horses style", (Enum[]) Class.forName( "org.bukkit.entity.Horse$Style").getEnumConstants())); } catch (Exception ex) { } try { enumHelp.add(new EnumHelp("OcelotType", "Ocelot types", ChatColor.RED + "/disguisehelp OcelotTypes " + ChatColor.GREEN + "- View all the ocelot types you can use for ocelots", (Enum[]) Class.forName( "org.bukkit.entity.Ocelot$Type").getEnumConstants())); } catch (Exception ex) { } try { enumHelp.add(new EnumHelp("Profession", "Villager professions", ChatColor.RED + "/disguisehelp Professions " + ChatColor.GREEN + "- View all the professions you can set on a villager", (Enum[]) Class.forName( "org.bukkit.entity.Villager$Profession").getEnumConstants())); } catch (Exception ex) { } try { ArrayList enumReturns = new ArrayList(); for (PotionEffectType potionType : PotionEffectType.values()) { if (potionType != null) enumReturns.add(toReadable(potionType.getName()) + ChatColor.RED + "(" + ChatColor.GREEN + potionType.getId() + ChatColor.RED + ")"); } enumHelp.add(new EnumHelp("PotionEffect", "PotionEffect", ChatColor.RED + "/disguisehelp PotionEffect " + ChatColor.GREEN + "- View all the potion effects you can set", enumReturns.toArray(new String[enumReturns .size()]))); } catch (Exception ex) { ex.printStackTrace(); } } @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { for (String node : new String[] { "disguise", "disguiseradius", "disguiseentity", "disguiseplayer" }) { ArrayList allowedDisguises = getAllowedDisguises(sender, "libsdisguises." + node + "."); if (!allowedDisguises.isEmpty()) { if (args.length == 0) { sendCommandUsage(sender); return true; // sender.sendMessage(ChatColor.RED + "/disguisehelp