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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations