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


Java ChatColor.translateAlternateColorCodes方法代码示例

本文整理汇总了Java中org.bukkit.ChatColor.translateAlternateColorCodes方法的典型用法代码示例。如果您正苦于以下问题:Java ChatColor.translateAlternateColorCodes方法的具体用法?Java ChatColor.translateAlternateColorCodes怎么用?Java ChatColor.translateAlternateColorCodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.ChatColor的用法示例。


在下文中一共展示了ChatColor.translateAlternateColorCodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.bukkit.ChatColor; //导入方法依赖的package包/类
@Override
public void execute(CommandSender sender, String[] args) {
    String[] lines = new String[] { "", "" };
    if (args.length > 0) {
        StringBuilder sb = new StringBuilder();
        for (int k = 0; k < args.length; k++)
            sb.append(args[k] + " ");
        String[] data = sb.toString().trim().split("@");
        for (int k = 0; k < data.length; k++) {
            lines[k] = ChatColor.translateAlternateColorCodes('&', data[k]);
        }
    }
    for (Player p2 : plugin.getServer().getOnlinePlayers()) {
        RMessages.sendTitle(p2, lines[0], lines[1], 20, 100, 20);
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:17,代码来源:AnnounceCommand.java

示例2: get

import org.bukkit.ChatColor; //导入方法依赖的package包/类
/**
 * Get text from the yml file for this locale
 * @param reference - the YAML node where the text is
 * @return Text for this locale reference or the reference is nothing has been found
 */
public String get(String reference) {
    // TODO: add placeholder conversion?
    //plugin.getLogger().info("DEBUG: default lang = " + Settings.defaultLanguage);
    //plugin.getLogger().info("DEBUG: this locale = " + languageTag);
    //plugin.getLogger().info("DEBUG: reference = " + reference);
    if (rb.containsKey(reference)) {
        //plugin.getLogger().info("DEBUG: contains key");
        return ChatColor.translateAlternateColorCodes('&', rb.getString(reference));
    } else if (!Settings.defaultLanguage.equals(languageTag)){
        //plugin.getLogger().info("DEBUG: try default");
        // TODO: Try default lang
        return reference;
    }
    plugin.getLogger().severe(reference + " not found in " + languageTag + " or default lang " + Settings.defaultLanguage);
    return reference; // Return reference for debug purposes, like for the mods.
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:22,代码来源:BSBLocale.java

示例3: onPlaceholderRequest

import org.bukkit.ChatColor; //导入方法依赖的package包/类
@Override
public String onPlaceholderRequest(Player player, String s) {
    if (player == null)
        return "";
    try {
        if (PlaceHolderType.getTypeFromName(s) != null) {
            final PlaceHolderRequestEvent event;
            if (s.split("_")[0].equals("player")) {
                event = new PlaceHolderRequestEvent(player, PlaceHolderType.getTypeFromName(s), -1);
            } else {
                event = new PlaceHolderRequestEvent(player, PlaceHolderType.getTypeFromName(s), Integer.parseInt(s.split("_")[0]));
            }
            Bukkit.getPluginManager().callEvent(event);
            return ChatColor.translateAlternateColorCodes('&', event.getResult());
        }

    } catch (final Exception ignored) {
    }
    return "";
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:21,代码来源:PlaceHolderApiConnection.java

示例4: executePlayer

import org.bukkit.ChatColor; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerDataRPG pd, String[] args) {
    ItemStack item = p.getInventory().getItemInMainHand();
    if (item.hasItemMeta()) {
        ItemMeta im = item.getItemMeta();
        StringBuilder sb = new StringBuilder();
        for (int k = 1; k < args.length; k++) {
            sb.append(args[k]);
            sb.append(' ');
        }
        String name = ChatColor.translateAlternateColorCodes('&', sb.toString().trim());
        im.setDisplayName(name);
        item.setItemMeta(im);
        p.sendMessage("Updated item.");
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:17,代码来源:EditNameCommand.java

示例5: onEnable

import org.bukkit.ChatColor; //导入方法依赖的package包/类
@Override
protected void onEnable() {
    EventExecutor.getInstance().register(this);

    // load config
    this.config = Moo.getInstance().loadConfig(Lightning.getInstance().getDataFolder());
    this.languageManager = new LanguageManager(Lightning.getInstance().getDataFolder(),
            s -> ChatColor.translateAlternateColorCodes('&', s));
    this.languageManager.load("language");

    // if disabled stop enabling
    if(!((boolean) config.get("activated"))) {
        Lightning.getInstance().getLogs().info("*** Lightning disabled. ***");
        return;
    }

    // register handler
    Moo.getInstance().registerHandler(o -> {
        if(o instanceof Listener) Bukkit.getServer().getPluginManager().registerEvents((Listener) o, Lightning.getInstance());
    }, new ChatListener(), new ServerListener());

    // connect to cloud
    if(config.isLoaded()) {
        Moo.getInstance().connect(config.get("group-id"), ClientType.SERVER, config.get("cloud-ip"), config.get("cloud-port"));
    }
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:27,代码来源:LightningPluginModule.java

示例6: onChat

import org.bukkit.ChatColor; //导入方法依赖的package包/类
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
    event.setCancelled(true);
    Player player = event.getPlayer();
    String message = event.getMessage();
    String playerNameWithPrefixSuffix = ChatColor.RED + "(ERROR FORMATTING NAME) " + ChatColor.WHITE + player.getName() + ": ";
    try {
        if (RankManager.isPrisoner(player)) {
            RankManager.updateWantedLevel(player);
        } else if (RankManager.isGuard(player) || RankManager.isWarden(player)) {
            RankManager.setWantedLevel(player, 0);
        }
        playerNameWithPrefixSuffix = ChatColor.translateAlternateColorCodes('&', (!RankManager.getRankPrefix(player).equals(" ") ? RankManager.getRankPrefix(player) : "") + ChatColor.GRAY + RankManager.wantedLevelParser(RankManager.getWantedLevel(player)) + ChatColor.GOLD + RankManager.guardLevelParser(RankManager.getGuardLevel(player)) + RankManager.getRankNameColor(player) + " " + player.getName() + (!RankManager.getRankSuffix(player).equals(" ") ? " " + RankManager.getRankSuffix(player) : "") + ChatColor.GRAY + ": ");
    } catch (SQLException e) {
        e.printStackTrace();
    }
    for (Player p : event.getRecipients()) {
        p.sendMessage(playerNameWithPrefixSuffix + ChatColor.WHITE + message);
    }
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:21,代码来源:RankListener.java

示例7: onCommand

import org.bukkit.ChatColor; //导入方法依赖的package包/类
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
  if (args.length < 1)
  {
    sender.sendMessage(ChatColor.RED + "Usage: " + "/rawcast");
    return true;
  }
  String arg;
  String requiredNode;
  int position = 0;
  if ((args.length > 2) && ((arg = args[0]).startsWith("-p")))
  {
    int position1 = 1;
    requiredNode = arg.substring(2, arg.length());
  }
  else
  {
    position = 0;
    requiredNode = null;
  }
  String message = StringUtils.join(args, ' ', position, args.length);
  if (message.length() < 3)
  {
    sender.sendMessage(ChatColor.RED + "Broadcasts must be at least 3 characters.");
    return true;
  }
  message = ChatColor.translateAlternateColorCodes('&', message);
  if (requiredNode != null) {
    Bukkit.broadcast(message, requiredNode);
  } else {
    Bukkit.broadcastMessage(message);
  }
  return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:35,代码来源:RawcastCommand.java

示例8: DragonTemplate

import org.bukkit.ChatColor; //导入方法依赖的package包/类
/**
 * Construct a new DragonTemplate object
 * 
 * @param file the file holding this template data
 * @param name the name of the dragon. Can be null
 * @param barStyle the style of the bar. Can be null
 * @param barColour the colour of the bar. Can be null
 */
public DragonTemplate(File file, String name, BarStyle barStyle, BarColor barColour) {
	Validate.notNull(file, "File cannot be null. See DragonTemplate(String, String, BarStyle, BarColor) for null files");
	
	this.file = file;
	this.configFile = YamlConfiguration.loadConfiguration(file);
	this.identifier = file.getName().substring(0, file.getName().lastIndexOf('.'));
	
	this.name = (name != null ? ChatColor.translateAlternateColorCodes('&', name) : null);
	this.barStyle = (barStyle != null ? barStyle : BarStyle.SOLID);
	this.barColour = (barColour != null ? barColour : BarColor.PINK);
	this.loot = new DragonLoot(this);
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:21,代码来源:DragonTemplate.java

示例9: initMessages

import org.bukkit.ChatColor; //导入方法依赖的package包/类
public void initMessages(CustomConfig config){
    karmaResetSender = ChatColor.translateAlternateColorCodes('&', config.getCustomFile().getString("karmareset.sender"));
    karmaResetReceiver = ChatColor.translateAlternateColorCodes('&', config.getCustomFile().getString("karmareset.receiver"));
    karmaAddSender = ChatColor.translateAlternateColorCodes('&', config.getCustomFile().getString("karmaadd.sender"));
    karmaAddReceiver = ChatColor.translateAlternateColorCodes('&', config.getCustomFile().getString("karmaadd.receiver"));
    karmaRemoveSender = ChatColor.translateAlternateColorCodes('&', config.getCustomFile().getString("karmaremove.sender"));
    karmaRemoveReceiver = ChatColor.translateAlternateColorCodes('&', config.getCustomFile().getString("karmaremove.receiver"));

    illegalKarmaAmmount = ChatColor.translateAlternateColorCodes('&', config.getCustomFile().getString("commanderrors.illegalkarmaammount"));

    karmaLoss = ChatColor.translateAlternateColorCodes('&', config.getCustomFile().getString("karmaloss"));
    karmaGain = ChatColor.translateAlternateColorCodes('&', config.getCustomFile().getString("karmagain"));
    karmaLevelChange = ChatColor.translateAlternateColorCodes('&', config.getCustomFile().getString("karmalevelchange"));
}
 
开发者ID:AsunaY,项目名称:Karma,代码行数:15,代码来源:Messages.java

示例10: getGeneralTopics

import org.bukkit.ChatColor; //导入方法依赖的package包/类
/**
 * Extracts a list of all general help topics from help.yml
 *
 * @return A list of general topics.
 */
public List<HelpTopic> getGeneralTopics() {
    List<HelpTopic> topics = new LinkedList<HelpTopic>();
    ConfigurationSection generalTopics = helpYaml.getConfigurationSection("general-topics");
    if (generalTopics != null) {
        for (String topicName : generalTopics.getKeys(false)) {
            ConfigurationSection section = generalTopics.getConfigurationSection(topicName);
            String shortText = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("shortText", ""));
            String fullText = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("fullText", ""));
            String permission = section.getString("permission", "");
            topics.add(new CustomHelpTopic(topicName, shortText, fullText, permission));
        }
    }
    return topics;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:20,代码来源:HelpYamlReader.java

示例11: getTopicAmendments

import org.bukkit.ChatColor; //导入方法依赖的package包/类
/**
 * Extracts a list of topic amendments from help.yml
 *
 * @return A list of amendments.
 */
public List<HelpTopicAmendment> getTopicAmendments() {
    List<HelpTopicAmendment> amendments = new LinkedList<HelpTopicAmendment>();
    ConfigurationSection commandTopics = helpYaml.getConfigurationSection("amended-topics");
    if (commandTopics != null) {
        for (String topicName : commandTopics.getKeys(false)) {
            ConfigurationSection section = commandTopics.getConfigurationSection(topicName);
            String description = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("shortText", ""));
            String usage = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("fullText", ""));
            String permission = section.getString("permission", "");
            amendments.add(new HelpTopicAmendment(topicName, description, usage, permission));
        }
    }
    return amendments;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:20,代码来源:HelpYamlReader.java

示例12: sendCenteredMessage

import org.bukkit.ChatColor; //导入方法依赖的package包/类
public static void sendCenteredMessage(Player player, String message){
    if(message == null || message.equals("")) player.sendMessage("");
    message = ChatColor.translateAlternateColorCodes('&', message);

    int messagePxSize = 0;
    boolean previousCode = false;
    boolean isBold = false;

    for(char c : message.toCharArray()){
        if(c == '§'){
            previousCode = true;
            continue;
        }else if(previousCode == true){
            previousCode = false;
            if(c == 'l' || c == 'L'){
                isBold = true;
                continue;
            }else isBold = false;
        }else{
            DefaultFontInfo dFI = DefaultFontInfo.getDefaultFontInfo(c);
            messagePxSize += isBold ? dFI.getBoldLength() : dFI.getLength();
            messagePxSize++;
        }
    }

    int halvedMessageSize = messagePxSize / 2;
    int toCompensate = CENTER_PX - halvedMessageSize;
    int spaceLength = DefaultFontInfo.SPACE.getLength() + 1;
    int compensated = 0;
    StringBuilder sb = new StringBuilder();
    while(compensated < toCompensate){
        sb.append(" ");
        compensated += spaceLength;
    }
    player.sendMessage(sb.toString() + message);
}
 
开发者ID:Chazmondo,项目名称:RankVouchers,代码行数:37,代码来源:CenterUtil.java

示例13: colorize

import org.bukkit.ChatColor; //导入方法依赖的package包/类
public static String colorize(String str) {
	return ChatColor.translateAlternateColorCodes('&', str);
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:4,代码来源:I18n.java

示例14: toJson

import org.bukkit.ChatColor; //导入方法依赖的package包/类
private static String toJson(Collection<String> text) {
    return "{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', StringUtils.join(text, "\n")) + "\"}";
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:4,代码来源:PlayerNms.java

示例15: getAlias

import org.bukkit.ChatColor; //导入方法依赖的package包/类
@Override
public String getAlias() {
    if (this.alias != null)
        return ChatColor.translateAlternateColorCodes('&', this.alias) + ChatColor.RESET;
    return null;
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:7,代码来源:ArenaEntity.java


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