本文整理匯總了Java中org.bukkit.ChatColor.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java ChatColor.toString方法的具體用法?Java ChatColor.toString怎麽用?Java ChatColor.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.ChatColor
的用法示例。
在下文中一共展示了ChatColor.toString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: imageToText
import org.bukkit.ChatColor; //導入方法依賴的package包/類
/**
* Converts a {@link java.awt.image.BufferedImage} to a multi-line text message, using {@link #COLOR_MAP}.
*
* @return A {@link java.lang.String[]} containing the message
*/
public static String[] imageToText(BufferedImage image, boolean trim) {
int height = Preconditions.checkNotNull(image, "Image").getHeight();
int width = image.getWidth();
String[][] message = new String[height][width];
LinkedList<Integer> pendingAlpha = new LinkedList<>();
for (int y = 0; y < height; y++) {
boolean fillAlpha = !trim;
boolean left = false;
for (int x = 0; x < width; x++) {
Color color = new Color(image.getRGB(x, y), true);
if (trim) {
if (color.getAlpha() < 1) {
pendingAlpha.add(x);
left = (left || x == 0);
} else {
if (!left) {
applyPendingAlpha(pendingAlpha, message[y]);
} else {
pendingAlpha.clear();
left = false;
}
}
}
ChatColor minecraftColor = rgbToMinecraft(closestColorMatch(color, COLOR_MAP.keySet()));
message[y][x] = minecraftColor == null ? (fillAlpha ? ALPHA_FILLER_CONTENT : "") : minecraftColor.toString() + PIXEL_CHAR;
}
if (!trim) {
applyPendingAlpha(pendingAlpha, message[y]);
}
}
String[] messageFinal = new String[height];
for (int y = 0; y < height; y++) {
messageFinal[y] = StringUtils.join(message[y]);
}
return messageFinal;
}
示例2: getTeam
import org.bukkit.ChatColor; //導入方法依賴的package包/類
private Team getTeam(int id, ScoreboardIndexableObject object)
{
Team team;
if (scoreboard.getScoreboard().getTeam(String.valueOf(id)) == null)
{
team = scoreboard.getScoreboard().registerNewTeam(String.valueOf(id));
}
else
{
team = scoreboard.getScoreboard().getTeam(String.valueOf(id));
}
String value = object.getValue();
if (object.getWatcher() != null)
{
value = value.replaceAll("%v%", object.getWatcher().get(scoreboard).toString());
}
String prefix = "", entry = "", suffix = "";
if (value.length() >= 31)
{
value = value.substring(0, 30);
}
ChatColor color = nextColor();
if (value.length() <= 16)
{
prefix = value;
suffix = "";
entry = color.toString();
}
else
{
if (value.charAt(15) == '&' || value.charAt(15) == '§')
{
prefix = value.substring(0, 15);
suffix = value.substring(15, value.length() >= 29 ? 29 : value.length());
}
else
{
prefix = value.substring(0, 16);
suffix = value.substring(16, value.length());
}
entry = color.toString();
}
while (suffix.length() != (16 - ChatColor.getLastColors(prefix).length()))
{
suffix += " ";
}
team.setPrefix(prefix);
team.setDisplayName(entry);
team.setSuffix(ChatColor.getLastColors(prefix) + suffix);
return team;
}