Multi Line Config Messages with color code support

Discussion in 'Plugin Development' started by superchris05326, May 8, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    superchris05326

    I want to be able to define messages in a config file with color codes then be able to send them to a player who did /vote.
    Here is my code:
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            if(cmd.getName().equalsIgnoreCase("vote")){
                String coloredstring = null;
                if(sender.hasPermission("vm.vote")){
                    List<String> list = this.getConfig().getStringList("VoteMessage");
                    sender.sendMessage(list.toArray(new String[list.size()]));
                    return true;
                }
            }
            return false;
        }
    This code takes these:
    1. messages:
    2. - 'msg1'
    3. - 'msg2'
    And it would send the player:
    msg1
    msg2
    I want to be able to use color codes like:
    &bmsg1
    &cmsg2
    to send the player:
    msg1
    msg2
    but I cant seem to find the code to do that.
     
  2. Offline

    TGRHavoc

    superchris05326
    ChatColor.translateAlternateColorCodes('&', "&a String to translate here");
    If you need more info look HERE.
     
  3. Offline

    superchris05326

    TGRHavoc that doesnt work with a list of strings
     
  4. Offline

    TGRHavoc

    superchris05326
    Like AdamQpzm said...
    Code:java
    1. List<String> translatedColors = new ArrayList<String>();
    2.  
    3. For(String stringToTranslate: List<String){
    4.  
    5. translatedColors.add(ChatColor.translateAlternateColorCodes('&',stringToTranslate);
    6.  
    7. }
     
Thread Status:
Not open for further replies.

Share This Page