From df696d99a314f51e5425d5beb781d49686889da2 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Thu, 4 Aug 2016 17:37:11 +0200 Subject: [PATCH] Classe convertissant les textes en couleurs Minecraft en code HTML --- .../pandacube/java/util/MinecraftWebUtil.java | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/fr/pandacube/java/util/MinecraftWebUtil.java diff --git a/src/fr/pandacube/java/util/MinecraftWebUtil.java b/src/fr/pandacube/java/util/MinecraftWebUtil.java new file mode 100644 index 0000000..a22723e --- /dev/null +++ b/src/fr/pandacube/java/util/MinecraftWebUtil.java @@ -0,0 +1,93 @@ +package fr.pandacube.java.util; + +public class MinecraftWebUtil { + + + + + /** + Convert a legacy Minecraft color coded String into HTML Format. + + @param + */ + public static String fromMinecraftColorCodeToHTML(char code_prefix, String ligne) + { + String color_char = "0123456789abcdefr"; + + String builder = ""; + char currentColor = 'r'; + boolean bold = false, italic = false, underlined = false, strikethrough = false; + + for (int i=0; i"; + currentColor = Character.toLowerCase(c); + } + + } + else if (Character.toLowerCase(c) == 'l') { + if (!bold) { + builder += ""; + bold = true; + } + } + else if (Character.toLowerCase(c) == 'm') { + if (!strikethrough) { + builder += ""; + strikethrough = true; + } + } + else if (Character.toLowerCase(c) == 'n') { + if (!underlined) { + builder += ""; + underlined = true; + } + } + else if (Character.toLowerCase(c) == 'o') { + if (!italic) { + builder += ""; + italic = true; + } + } + else { + builder += code_prefix + c; + } + + + } + else + builder += c; + } + + return builder; + + } + + + +}