package fr.pandacube.lib.util; public class MinecraftWebUtil { /** Convert a legacy Minecraft color coded String into HTML Format. */ // TODO update to support RGB colors (Bungee and Essentials notation). // See JavaScript implementation at https://www.pandacube.fr/assets/js/global.js public static String fromMinecraftColorCodeToHTML(char code_prefix, String ligne) { String color_char = "0123456789abcdefr"; StringBuilder builder = new StringBuilder(); char currentColor = 'r'; boolean bold = false, italic = false, underlined = false, strikethrough = false; for (int i=0; i"); bold = false; } if (italic) { builder.append(""); italic = false; } if (underlined) { builder.append(""); underlined = false; } if (strikethrough) { builder.append(""); strikethrough = false; } if (Character.toLowerCase(c) != currentColor) { if (currentColor != 'r') builder.append(""); if (Character.toLowerCase(c) != 'r') builder.append(""); currentColor = Character.toLowerCase(c); } } else if (Character.toLowerCase(c) == 'l') { if (!bold) { builder.append(""); bold = true; } } else if (Character.toLowerCase(c) == 'm') { if (!strikethrough) { builder.append(""); strikethrough = true; } } else if (Character.toLowerCase(c) == 'n') { if (!underlined) { builder.append(""); underlined = true; } } else if (Character.toLowerCase(c) == 'o') { if (!italic) { builder.append(""); italic = true; } } else { builder.append(code_prefix + c); } } else builder.append(c); } return builder.toString(); } }