geforkt von Mirrors/Paper
SPIGOT-2646: MapFont.getWidth with coloured text
By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
a037aff506
Commit
aaf720af60
@ -1,6 +1,7 @@
|
||||
package org.bukkit.map;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* Represents a bitmap font drawable to a map.
|
||||
@ -58,7 +59,9 @@ public class MapFont {
|
||||
|
||||
int result = 0;
|
||||
for (int i = 0; i < text.length(); ++i) {
|
||||
result += chars.get(text.charAt(i)).getWidth();
|
||||
char ch = text.charAt(i);
|
||||
if (ch == ChatColor.COLOR_CHAR) continue;
|
||||
result += chars.get(ch).getWidth();
|
||||
}
|
||||
result += text.length() - 1; // Account for 1px spacing between characters
|
||||
|
||||
@ -84,7 +87,7 @@ public class MapFont {
|
||||
public boolean isValid(String text) {
|
||||
for (int i = 0; i < text.length(); ++i) {
|
||||
char ch = text.charAt(i);
|
||||
if (ch == '\u00A7' || ch == '\n') continue;
|
||||
if (ch == ChatColor.COLOR_CHAR || ch == '\n') continue;
|
||||
if (chars.get(ch) == null) return false;
|
||||
}
|
||||
return true;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren