Add support for RGB colors using the color char

Examples include:
`&x00002a00002b&lText`
This commit is contained in:
games647
2022-06-24 16:21:53 +02:00
parent 5e159cac64
commit f182adc3bc
2 changed files with 28 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
package com.github.games647.fastlogin.bukkit;
import com.github.games647.fastlogin.core.CommonUtil;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.chat.ComponentSerializer;
import junit.framework.TestCase;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
public class FastLoginBukkitTest extends TestCase {
@Test
public void testRGB() {
var message = "&x00002a00002b&lText";
var msg = CommonUtil.translateColorCodes(message);
assertThat(msg, is("§x00002a00002b§lText"));
var components = TextComponent.fromLegacyText(msg);
var expected = """
{"bold":true,"color":"#00a00b","text":"Text"}""";
assertThat(ComponentSerializer.toString(components), is(expected));
}
}