本文整理汇总了Java中org.bukkit.ChatColor.getByChar方法的典型用法代码示例。如果您正苦于以下问题:Java ChatColor.getByChar方法的具体用法?Java ChatColor.getByChar怎么用?Java ChatColor.getByChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.ChatColor
的用法示例。
在下文中一共展示了ChatColor.getByChar方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translateCustom
import org.bukkit.ChatColor; //导入方法依赖的package包/类
public static String translateCustom(String text) {
char[] b = text.toCharArray();
if (b.length == 0) return text;
if (b.length >= 2 && b[0] == CUSTOM_CONTROL_CHAR) {
ChatColor color = ChatColor.getByChar(b[1]);
if (color != null)
return separator(color);
switch (b[1]) {
case '|':
return center(b, 2, false);
case '>':
return leftPad(b, 2, false);
case '<':
return new String(b, 2, b.length - 2);
case CUSTOM_CONTROL_CHAR:
return new String(b, 1, b.length - 1);
}
}
return text;
}
示例2: translate
import org.bukkit.ChatColor; //导入方法依赖的package包/类
public static String translate(String text) {
char[] b = text.toCharArray();
if (b.length == 0) return text;
if (b.length >= 2 && b[0] == CUSTOM_CONTROL_CHAR) {
ChatColor color = ChatColor.getByChar(b[1]);
if (color != null)
return separator(color);
switch (b[1]) {
case '|':
return center(b, 2, true);
case '>':
return leftPad(b, 2, true);
case '<':
return translatePlain(b, 2);
case CUSTOM_CONTROL_CHAR:
return translatePlain(b, 1);
}
}
return translatePlain(b, 0);
}
示例3: translateAndMeasure
import org.bukkit.ChatColor; //导入方法依赖的package包/类
private static int translateAndMeasure(char[] b, int offset) {
boolean isBold = false;
int size = 0;
for (int i = offset, len = b.length; i < len; i++) {
char c = b[i];
if (c == CONFIG_CONTROL_CHAR || c == CONTROL_CHAR) {
ChatColor color = ChatColor.getByChar(Character.toLowerCase(b[i + 1]));
if (color != null) {
b[i] = CONTROL_CHAR;
isBold = color == BOLD;
i++;
}
} else {
DefaultFontInfo info = DefaultFontInfo.getDefaultFontInfo(c);
size += isBold ? info.getBoldLength() : info.getLength();
size++;
}
}
return size;
}
示例4: condense
import org.bukkit.ChatColor; //导入方法依赖的package包/类
/**
* Removes any unnecessary color codes from a string.
*
* @param str The string to condense
* @return The condensed string
*/
public static String condense(String str) {
StringBuilder result = new StringBuilder();
boolean nextColor = false;
ChatColor color = null;
for (char c : str.toCharArray()) {
if (c == '§') {
nextColor = true;
} else if (nextColor) {
ChatColor currentColor = ChatColor.getByChar(c);
//Append this color to the condensed string if it actually changes the color and appearance of the original
if (currentColor != null && !currentColor.equals(color)) {
color = currentColor;
result.append(currentColor);
}
} else {
result.append(c);
}
}
return result.toString();
}
示例5: getFirstColors
import org.bukkit.ChatColor; //导入方法依赖的package包/类
public static String getFirstColors(String input) {
StringBuilder result = new StringBuilder();
int length = input.length();
for (int index = 0; index < length; index++) {
char section = input.charAt(index);
if (section == ChatColor.COLOR_CHAR && index < length - 1) {
char c = input.charAt(index + 1);
ChatColor color = ChatColor.getByChar(c);
if (color != null) {
result.insert(0, color.toString());
if (color.isColor() || color.equals(ChatColor.RESET)) {
break;
}
}
}
}
return result.toString();
}
示例6: next
import org.bukkit.ChatColor; //导入方法依赖的package包/类
@Override
public String next() {
StringBuilder sb = getNext();
if (sb.charAt(sb.length() - 1) == '&') {
sb.setCharAt(sb.length() - 1, ' ');
}
if (sb.charAt(0) == '&') {
ChatColor c = ChatColor.getByChar(sb.charAt(1));
if (c != null) {
color = c;
sb = getNext();
if (sb.charAt(0) != ' ')
sb.setCharAt(0, ' ');
}
}
return color + sb.toString();
}
示例7: next
import org.bukkit.ChatColor; //导入方法依赖的package包/类
/**
* @return Gets the next String to display
*/
public String next(Player p)
{
StringBuilder sb = getNext();
if (sb.charAt(sb.length() - 1) == COLOUR_CHAR)
sb.setCharAt(sb.length() - 1, ' ');
if (sb.charAt(0) == COLOUR_CHAR)
{
ChatColor c = ChatColor.getByChar(sb.charAt(1));
if (c != null)
{
colour = c;
sb = getNext();
if (sb.charAt(0) != ' ')
sb.setCharAt(0, ' ');
}
}
return colour + sb.toString();
}
示例8: deserialize
import org.bukkit.ChatColor; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static MessagePart deserialize(Map<String, Object> serialized) {
MessagePart part = new MessagePart((TextualComponent) serialized.get("text"));
part.styles = (ArrayList<ChatColor>) serialized.get("styles");
part.color = ChatColor.getByChar(serialized.get("color").toString());
part.hoverActionName = (String) serialized.get("hoverActionName");
part.hoverActionData = (JsonRepresentedObject) serialized.get("hoverActionData");
part.clickActionName = (String) serialized.get("clickActionName");
part.clickActionData = (String) serialized.get("clickActionData");
part.insertionData = (String) serialized.get("insertion");
part.translationReplacements = (ArrayList<JsonRepresentedObject>) serialized.get("translationReplacements");
return part;
}
示例9: build
import org.bukkit.ChatColor; //导入方法依赖的package包/类
/**
* Create an instance of a message with a given sender
* and message
*
* @param sender Sender of the moderator message
* @param modChannel Channel of the moderator message
* @param message Prefix color of the sender
*
* @return New instance
*/
public static JsonModMessage build(CommandSender sender, ModChannel modChannel, String message)
{
if (sender instanceof Player)
{
String prefix ="";//TODO SamaGamesAPI.get().getPermissionsManager().getPrefix(SamaGamesAPI.get().getPermissionsManager().getApi().getUser(((Player) sender).getUniqueId()));
ChatColor pr = (prefix == null) ? ChatColor.AQUA : ChatColor.getByChar(prefix.charAt(prefix.length() - 1));
return new JsonModMessage(sender.getName(), modChannel, pr, message);
}
else
{
return new JsonModMessage(sender.getName(), modChannel, ChatColor.AQUA, message);
}
}
示例10: deserialize
import org.bukkit.ChatColor; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static MessagePart deserialize(Map<String, Object> serialized){
MessagePart part = new MessagePart((TextualComponent)serialized.get("text"));
part.styles = (ArrayList<ChatColor>)serialized.get("styles");
part.color = ChatColor.getByChar(serialized.get("color").toString());
part.hoverActionName = (String)serialized.get("hoverActionName");
part.hoverActionData = (JsonRepresentedObject)serialized.get("hoverActionData");
part.clickActionName = (String)serialized.get("clickActionName");
part.clickActionData = (String)serialized.get("clickActionData");
part.insertionData = (String)serialized.get("insertion");
part.translationReplacements = (ArrayList<JsonRepresentedObject>)serialized.get("translationReplacements");
return part;
}
示例11: reloadConfigs
import org.bukkit.ChatColor; //导入方法依赖的package包/类
static void reloadConfigs()
{
YamlConfiguration mainConfig = load(configFolder + "/" + MAIN_CONFIG);
WORLDGUARD_DEFAULT = mainConfig.getBoolean("worldguard_flag_enable");
PRISON_PICK_FLAG = new StateFlag("prison-picks", WORLDGUARD_DEFAULT);
EXPLOSIVE_COLOR = ChatColor.getByChar(mainConfig.getString("explosive_color").charAt(1));
PICK_O_PLENTY_COLOR = ChatColor.getByChar(mainConfig.getString("pick_o_plenty_color").charAt(1));
FAKE_EXPLOSIVE_PICK_O_PLENTY_COLOR = ChatColor.getByChar(mainConfig.getString("fake_xpop_color").charAt(1));
CHAT_SUCCESS_COLOR = ChatColor.getByChar(mainConfig.getString("success_color").charAt(1));
CHAT_FAIL_COLOR = ChatColor.getByChar(mainConfig.getString("fail_color").charAt(1));
CHAT_PICK_BREAK = ChatColor.getByChar(mainConfig.getString("pick_break_color").charAt(1));
CHAT_EXPLOSIVE_REPAIR = ChatColor.getByChar(mainConfig.getString("explosive_repair_msg").charAt(1));
CHAT_POP_REPAIR = ChatColor.getByChar(mainConfig.getString("pop_repair_msg").charAt(1));
CHAT_XPOP_REPAIR = ChatColor.getByChar(mainConfig.getString("xpop_repair_msg").charAt(1));
COAL_PRIORITY = mainConfig.getInt("coal_priority");
IRON_PRIORITY = mainConfig.getInt("iron_priority");
REDSTONE_PRIORITY = mainConfig.getInt("redstone_priority");
LAPIS_PRIORITY = mainConfig.getInt("lapis_priority");
GOLD_PRIORITY = mainConfig.getInt("gold_priority");
QUARTZ_PRIORITY = mainConfig.getInt("quartz_priority");
DIAMOND_PRIORITY = mainConfig.getInt("diamond_priority");
DIAMOND_BLOCK_PRIORITY = mainConfig.getInt("diamond_block_priority");
EMERALD_PRIORITY = mainConfig.getInt("emerald_priority");
}
示例12: deserialize
import org.bukkit.ChatColor; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static MessagePart deserialize(Map<String, Object> serialized) {
MessagePart part = new MessagePart((TextualComponent) serialized.get("text"));
part.styles = (ArrayList<ChatColor>) serialized.get("styles");
part.color = ChatColor.getByChar(serialized.get("color").toString());
part.hoverActionName = (String) serialized.get("hoverActionName");
part.hoverActionData = (JsonRepresentedObject) serialized.get("hoverActionData");
part.clickActionName = (String) serialized.get("clickActionName");
part.clickActionData = (String) serialized.get("clickActionData");
part.insertionData = (String) serialized.get("insertion");
part.translationReplacements = (ArrayList<JsonRepresentedObject>) serialized.get("translationReplacements");
return part;
}
示例13: convertColor
import org.bukkit.ChatColor; //导入方法依赖的package包/类
public static ChatColor convertColor(net.md_5.bungee.api.ChatColor color) {
return ChatColor.getByChar(color.toString().charAt(1));
}