SPIGOT-6825: MapFont#getWidth ignores §, but not the color-byte and semicolon following it

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2021-12-01 14:58:04 +11:00
parent 62f79aa905
commit 926db7c30b

View File

@ -63,7 +63,14 @@ public class MapFont {
int result = 0;
for (int i = 0; i < text.length(); ++i) {
char ch = text.charAt(i);
if (ch == ChatColor.COLOR_CHAR) continue;
if (ch == ChatColor.COLOR_CHAR) {
int j = text.indexOf(';', i);
if (j >= 0) {
i = j;
continue;
}
throw new IllegalArgumentException("Text contains unterminated color string");
}
result += chars.get(ch).getWidth();
}
result += text.length() - 1; // Account for 1px spacing between characters