当前位置: 首页>>代码示例>>Java>>正文


Java ChatColor.getByChar方法代码示例

本文整理汇总了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;
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:21,代码来源:TextUtil.java

示例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);
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:21,代码来源:TextUtil.java

示例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;
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:21,代码来源:TextUtil.java

示例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();
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:29,代码来源:Colors.java

示例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();
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:23,代码来源:Util.java

示例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();
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:18,代码来源:ScrollableString.java

示例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();

}
 
开发者ID:WheezyGold7931,项目名称:skLib,代码行数:25,代码来源:Scroller.java

示例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;
}
 
开发者ID:Slaymd,项目名称:CaulCrafting,代码行数:14,代码来源:MessagePart.java

示例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);
    }
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:25,代码来源:JsonModMessage.java

示例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;
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:14,代码来源:MessagePart.java

示例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");
      
  }
 
开发者ID:ThePhilderbeast,项目名称:prisonPicks,代码行数:30,代码来源:Config.java

示例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;
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:14,代码来源:MessagePart.java

示例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));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:BukkitUtils.java


注:本文中的org.bukkit.ChatColor.getByChar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。