Solved [Help] [Again] TranslateAlternateColorCodes with lists

Discussion in 'Spigot Plugin Development' started by SwagiWagi, Jun 14, 2016.

  1. Hey there,
    How do I add TranslateAlternateColorCode to a list?
    Code (Text):
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            List<String> ms = this.plugin.getConfig().getStringList("List");
            Player p = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("hey")) {
                  for (String List : ms) {
                      p.sendMessage(List);
     
     
  2. Code (Text):
    for (String string : someList) {
        ChatColor.translateAlternateColorCode(string);
    }
     
  3. Instead of sending the player the String variable directly, just wrap it in ChatColor#translateAlternateColourCodes
     
  4. How do I continue it?
    Code (Text):
                      p.sendMessage(ChatColor.translateAlternateColorCode('&',)(List));
     
     
  5. You aren't using the method correctly at all. Go look at the ChatColor javadocs for the correct method usage please
     
  6. Add ChatColor.translateAlternateColorCodes before you send them the message.
     
  7. You're going to get an error with this: "String List : ms" lowercase the L(it's because you already imported List so yeah). and for ChatColor.translateAlternativeColorCodes just put the arguments as a char first(the color you wanna replace ex. &) then the String to add color into
     
  8. I did it!
    Code (Text):
     p.sendMessage(ChatColor.translateAlternateColorCodes('&', list));