package gd.rf.adrianvictor.lib;

import org.bukkit.ChatColor;

public class Color {
  public static String formatColors(String message) {
    return message.replaceAll("&", "§");
  }
  
  public static Object[] ignoreColors(String message) {
    String parsed = message.replaceAll("&([0-9a-fk-or])", "");
    Boolean changed = parsed.equals(message);
    return new Object[] {parsed, changed};
  }
  
  public static String rainbow(String message) {
      ChatColor[] rainbowColors = { ChatColor.RED, ChatColor.GOLD, ChatColor.YELLOW, ChatColor.GREEN, ChatColor.AQUA, ChatColor.BLUE, ChatColor.LIGHT_PURPLE };
      int colorIndex = 0;
      String coloredMessage = "";

      for (char c : message.toCharArray()) {
          ChatColor currentColor = rainbowColors[colorIndex];
          coloredMessage += currentColor + String.valueOf(c);
          colorIndex++;
          if (colorIndex >= rainbowColors.length) {
              colorIndex = 0;
          }
      }
      return coloredMessage;
  }
}
