本文整理汇总了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;
}