Solved Strikethrough Colored Message

Discussion in 'Spigot Plugin Development' started by Electro2560, May 9, 2017.

  1. I've been trying to make a method which attempts to strike through chat which already contains colors. I'm currently trying this but it doesn't always work correctly. Is there anything in the TextComponent API that would help iterate character by character and setting it to be strike through?
     
  2. Something like this?

    Code (Text):
    String msg; // colored message

    for (ChatColor color : ChatColor.values()) {
        msg = msg.replace(color, color + "" + ChatColor.STRIKETHROUGH);
    }
    • Goes through all chat colors
    • Replace every occurrence of the color with the same color PLUS a strikethrough
      • ex: msg = "§ah§bi" (hi), §a will become §a§m and §b will become §b§m, so finally it will be: §a§mh§b§mi or hi
     
    • Useful Useful x 1
  3. Exactly! Thank you so much!
     
    • Like Like x 1