Java Code Examples for org.bukkit.ChatColor#valueOf()

The following examples show how to use org.bukkit.ChatColor#valueOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Crate.java    From CratesPlus with GNU General Public License v3.0 5 votes vote down vote up
private void loadCrateBase() {
    CratesPlus cratesPlus = configHandler.getCratesPlus();
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Hide Percentages"))
        this.hidePercentages = cratesPlus.getConfig().getBoolean("Crates." + name + ".Hide Percentages");
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Color"))
        this.color = ChatColor.valueOf(cratesPlus.getConfig().getString("Crates." + name + ".Color").toUpperCase());
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Block"))
        this.block = Material.valueOf(cratesPlus.getConfig().getString("Crates." + name + ".Block").toUpperCase());
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Block Data"))
        this.blockData = cratesPlus.getConfig().getInt("Crates." + name + ".Block Data", 0);
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Permission"))
        this.permission = cratesPlus.getConfig().getString("Crates." + name + ".Permission");
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Firework"))
        this.firework = cratesPlus.getConfig().getBoolean("Crates." + name + ".Firework");
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Broadcast"))
        this.broadcast = cratesPlus.getConfig().getBoolean("Crates." + name + ".Broadcast");
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Opener"))
        this.opener = cratesPlus.getConfig().getString("Crates." + name + ".Opener");
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Cooldown"))
        this.cooldown = cratesPlus.getConfig().getInt("Crates." + name + ".Cooldown");

    if (!cratesPlus.getConfig().isSet("Crates." + name + ".Winnings"))
        return;

    if (cratesPlus.getConfig().getConfigurationSection("Crates." + name + ".Winnings") != null) {
        for (String id : cratesPlus.getConfig().getConfigurationSection("Crates." + name + ".Winnings").getKeys(false)) {
            String path = "Crates." + name + ".Winnings." + id;
            Winning winning = new Winning(this, path, cratesPlus, null);
            if (!winning.isValid()) {
                Bukkit.getLogger().warning(path + " is an invalid winning.");
                continue;
            }
            totalPercentage = totalPercentage + winning.getPercentage();
            winnings.add(winning);
        }
    }
}
 
Example 2
Source File: BaseState.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
public ChatColor getStatusColor(Party viewer) {
  return ChatColor.valueOf(this.flag.getChatColor().name());
}
 
Example 3
Source File: ChatWriter.java    From MineTinker with GNU General Public License v3.0 4 votes vote down vote up
public static ChatColor getColor(String input) throws IllegalArgumentException, ArrayIndexOutOfBoundsException {
	return ChatColor.valueOf(input.split("%")[1]);
}
 
Example 4
Source File: Config.java    From ClaimChunk with MIT License 4 votes vote down vote up
private ChatColor getColor(String name) {
    return ChatColor.valueOf(getString("colors", name));
}
 
Example 5
Source File: ConversationColors.java    From BetonQuest with GNU General Public License v3.0 4 votes vote down vote up
public ConversationColors() {
    try {
        String[] text = Config.getString("config.conversation_colors.text").split(",");
        textColors = new ChatColor[text.length];
        for (int i = 0; i < text.length; i++) {
            textColors[i] = ChatColor.valueOf(text[i].toUpperCase().trim().replace(" ", "_"));
        }
        String[] npc = Config.getString("config.conversation_colors.npc").split(",");
        npcColors = new ChatColor[npc.length];
        for (int i = 0; i < npc.length; i++) {
            npcColors[i] = ChatColor.valueOf(npc[i].toUpperCase().trim().replace(" ", "_"));
        }
        String[] player = Config.getString("config.conversation_colors.player").split(",");
        playerColors = new ChatColor[player.length];
        for (int i = 0; i < player.length; i++) {
            playerColors[i] = ChatColor.valueOf(player[i].toUpperCase().trim().replace(" ", "_"));
        }
        String[] number = Config.getString("config.conversation_colors.number").split(",");
        numberColors = new ChatColor[number.length];
        for (int i = 0; i < number.length; i++) {
            numberColors[i] = ChatColor.valueOf(number[i].toUpperCase().trim().replace(" ", "_"));
        }
        String[] answer = Config.getString("config.conversation_colors.answer").split(",");
        answerColors = new ChatColor[answer.length];
        for (int i = 0; i < answer.length; i++) {
            answerColors[i] = ChatColor.valueOf(answer[i].toUpperCase().trim().replace(" ", "_"));
        }
        String[] option = Config.getString("config.conversation_colors.option").split(",");
        optionColors = new ChatColor[option.length];
        for (int i = 0; i < option.length; i++) {
            optionColors[i] = ChatColor.valueOf(option[i].toUpperCase().trim().replace(" ", "_"));
        }
    } catch (IllegalArgumentException e) {
        textColors = new ChatColor[]{};
        npcColors = new ChatColor[]{};
        playerColors = new ChatColor[]{};
        optionColors = new ChatColor[]{};
        answerColors = new ChatColor[]{};
        numberColors = new ChatColor[]{};
        LogUtils.getLogger().log(Level.WARNING, "Could not parse conversation colors, everything will be white!");
        LogUtils.logThrowable(e);
        return;
    }
}