Search in sources :

Example 91 with ChatColor

use of org.bukkit.ChatColor in project UltimateChat by FabioZumbi12.

the class ReflectionUtil method addColorToArray.

private JSONArray addColorToArray(String text) {
    JSONArray extraArr = new JSONArray();
    ChatColor color = ChatColor.WHITE;
    for (String part : text.split("(?=" + ChatColor.COLOR_CHAR + "[0-9a-fA-Fk-oK-ORr])")) {
        JSONObject objExtraTxt = new JSONObject();
        Matcher match = Pattern.compile("^" + ChatColor.COLOR_CHAR + "([0-9a-fA-Fk-oK-ORr]).*$").matcher(part);
        if (match.find()) {
            color = ChatColor.getByChar(match.group(1).charAt(0));
            if (part.length() == 2)
                continue;
        }
        objExtraTxt.put("text", UChatColor.stripColor(part));
        if (color.isColor()) {
            objExtraTxt.put("color", color.name().toLowerCase());
            objExtraTxt.remove("obfuscated");
            objExtraTxt.remove("underlined");
            objExtraTxt.remove(ChatColor.STRIKETHROUGH.name().toLowerCase());
        }
        if (color.equals(ChatColor.RESET)) {
            objExtraTxt.put("color", "white");
            objExtraTxt.remove("obfuscated");
            objExtraTxt.remove("underlined");
            objExtraTxt.remove(ChatColor.STRIKETHROUGH.name().toLowerCase());
        }
        if (color.isFormat()) {
            if (color.equals(ChatColor.MAGIC)) {
                objExtraTxt.put("obfuscated", true);
            } else if (color.equals(ChatColor.UNDERLINE)) {
                objExtraTxt.put("underlined", true);
            } else {
                objExtraTxt.put(color.name().toLowerCase(), true);
            }
        }
        extraArr.add(objExtraTxt);
    }
    return extraArr;
}
Also used : JSONObject(org.json.simple.JSONObject) Matcher(java.util.regex.Matcher) JSONArray(org.json.simple.JSONArray) ChatColor(org.bukkit.ChatColor)

Example 92 with ChatColor

use of org.bukkit.ChatColor in project Denizen by DenizenScript.

the class Messaging method prettify.

private static String prettify(String message) {
    String trimmed = message.trim();
    String messageColor = Colorizer.parseColors(MESSAGE_COLOUR);
    if (!trimmed.isEmpty()) {
        if (trimmed.charAt(0) == ChatColor.COLOR_CHAR) {
            ChatColor test = ChatColor.getByChar(trimmed.substring(1, 2));
            if (test == null) {
                message = messageColor + message;
            }
        } else {
            message = messageColor + message;
        }
    }
    return message;
}
Also used : ChatColor(org.bukkit.ChatColor)

Example 93 with ChatColor

use of org.bukkit.ChatColor in project Towny by TownyAdvanced.

the class MapHUD method toggleOn.

public static void toggleOn(Player player) {
    Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
    Objective objective = board.registerNewObjective("MAP_HUD_OBJ", "dummy", "maphud");
    objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    int score = lineHeight + 2;
    ChatColor[] colors = ChatColor.values();
    for (int i = 0; i < lineHeight; i++) {
        board.registerNewTeam("mapTeam" + i).addEntry(colors[i].toString());
        objective.getScore(colors[i].toString()).setScore(score);
        score--;
    }
    String townEntry = ChatColor.DARK_GREEN + Translatable.of("town_sing").forLocale(player) + ": ";
    String ownerEntry = ChatColor.DARK_GREEN + Translatable.of("owner_status").forLocale(player) + ": ";
    board.registerNewTeam("townTeam").addEntry(townEntry);
    objective.getScore(townEntry).setScore(2);
    board.registerNewTeam("ownerTeam").addEntry(ownerEntry);
    objective.getScore(ownerEntry).setScore(1);
    player.setScoreboard(board);
    updateMap(player);
}
Also used : Objective(org.bukkit.scoreboard.Objective) Scoreboard(org.bukkit.scoreboard.Scoreboard) ChatColor(org.bukkit.ChatColor)

Example 94 with ChatColor

use of org.bukkit.ChatColor in project AllMiniGames by MiniGameWorlds.

the class UpdateChecker method check.

/*
	 * Check version with file in the download directory
	 */
public static boolean check() {
    PluginDescriptionFile desc = AllMiniGamesMain.getInstance().getDescription();
    String currentVersion = desc.getVersion();
    String pluginName = desc.getName();
    String latestVersion = getLatestVersion(pluginName);
    if (latestVersion == null) {
        Utils.warning(pluginName + " is not exist in the download directory");
        return false;
    }
    boolean isLatest = false;
    isLatest = currentVersion.equals(latestVersion);
    ChatColor currentVersionColor = isLatest ? ChatColor.GREEN : ChatColor.RED;
    ChatColor latestVersionColor = ChatColor.GREEN;
    // print update checkers
    Utils.info("                Update Checker                ");
    Utils.info(" - Current version: " + currentVersionColor + currentVersion);
    Utils.info(" - Latest  version: " + latestVersionColor + latestVersion);
    if (!isLatest) {
        Utils.warning("");
        Utils.warning("Your version is " + currentVersionColor + "outdated");
        Utils.warning("Download latest version: " + "https://github.com/MiniGameWorlds/AllMiniGames/tree/main/download");
    }
    Utils.info(ChatColor.GREEN + "=============================================");
    return isLatest;
}
Also used : PluginDescriptionFile(org.bukkit.plugin.PluginDescriptionFile) ChatColor(org.bukkit.ChatColor)

Example 95 with ChatColor

use of org.bukkit.ChatColor in project PCGF_PluginLib by GeorgH93.

the class MessageBuilder method style.

/**
 * Sets the style of the current component.
 *
 * @param styles The array of styles to apply to the current component.
 * @return The message builder instance (for chaining).
 * @deprecated Use {@link at.pcgamingfreaks.Message.MessageBuilder#format(MessageFormat...)} or {@link at.pcgamingfreaks.Message.MessageBuilder#color(MessageColor)} instead!
 */
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "1.0.40")
public MessageBuilder style(ChatColor... styles) {
    for (ChatColor style : styles) {
        if (style == ChatColor.RESET) {
            color(MessageColor.RESET);
            format(MessageFormat.RESET);
        } else if (style.isColor())
            color(style);
        else
            format(style);
    }
    return this;
}
Also used : ChatColor(org.bukkit.ChatColor)

Aggregations

ChatColor (org.bukkit.ChatColor)182 ArrayList (java.util.ArrayList)34 Player (org.bukkit.entity.Player)31 World (org.bukkit.World)12 Team (org.bukkit.scoreboard.Team)11 Matcher (java.util.regex.Matcher)10 ItemStack (org.bukkit.inventory.ItemStack)10 List (java.util.List)9 JSONObject (org.json.simple.JSONObject)9 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)8 DyeColor (org.bukkit.DyeColor)7 Material (org.bukkit.Material)7 ItemMeta (org.bukkit.inventory.meta.ItemMeta)7 HashMap (java.util.HashMap)6 Scoreboard (org.bukkit.scoreboard.Scoreboard)6 IOException (java.io.IOException)4 DecimalFormat (java.text.DecimalFormat)4 UUID (java.util.UUID)4 OfflinePlayer (org.bukkit.OfflinePlayer)4 Score (org.bukkit.scoreboard.Score)4