Search in sources :

Example 81 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project VotingPlugin by Ben12345rocks.

the class VoteHelp method helpText.

public ArrayList<TextComponent> helpText(CommandSender sender) {
    ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
    HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
    boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
    String colorStr = plugin.getConfigFile().getFormatCommandsVoteHelpHoverColor();
    ChatColor hoverColor = null;
    try {
        hoverColor = ChatColor.of(colorStr);
    } catch (Exception e) {
        plugin.getLogger().warning("Failed to get color for hover help message");
        e.printStackTrace();
        hoverColor = ChatColor.AQUA;
    }
    for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
        if (!requirePerms || cmdHandle.hasPerm(sender)) {
            unsorted.put(cmdHandle.getHelpLineCommand("/vote"), cmdHandle.getHelpLine("/vote", plugin.getConfigFile().getFormatCommandsVoteHelpLine(), hoverColor));
        }
    }
    ArrayList<String> unsortedList = new ArrayList<String>();
    unsortedList.addAll(unsorted.keySet());
    Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
    for (String cmd : unsortedList) {
        msg.add(unsorted.get(cmd));
    }
    return msg;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CommandHandler(com.bencodez.advancedcore.api.command.CommandHandler) ChatColor(net.md_5.bungee.api.ChatColor)

Aggregations

TextComponent (net.md_5.bungee.api.chat.TextComponent)78 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)21 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)15 Player (org.bukkit.entity.Player)14 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)12 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)12 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)12 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)11 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)6 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)6 Configuration (net.md_5.bungee.config.Configuration)6 YamlConfiguration (net.md_5.bungee.config.YamlConfiguration)6 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)5 ChatColor (net.md_5.bungee.api.ChatColor)5 ItemStack (org.bukkit.inventory.ItemStack)5 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)4 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)4 DecimalFormat (java.text.DecimalFormat)4 HashMap (java.util.HashMap)4