private String color(String text) { return text == null ? null : ChatColor.translateAlternateColorCodes('&', text); }
@Override public String getMotd() { return ChatColor.translateAlternateColorCodes('&', config.getString(Key.MOTD)); }
/** * Replace color definitions with '&' by ChatColor for the given text. * * @param text * the text * @return the string */ public static String replaceColors(final String text) { return text == null ? null : ChatColor.translateAlternateColorCodes('&', text); }
/** * Colourises a string (using '&' character) * * @param string String to colourise * @return Colourised string */ public static String getColoured(String string) { return ChatColor.translateAlternateColorCodes('&', string); }
/** * Returns the text * * @return text */ public String getText() { return ChatColor.translateAlternateColorCodes('&', this.text.toString()); }
public static String getTimeLeft(int l) { String timeleft = ""; final int minutes = (int) (l / 60L); if (minutes > 0) { timeleft = String.valueOf(timeleft) + minutes + "m "; } l -= minutes * 60; final int seconds = (int)l; timeleft = String.valueOf(timeleft) + seconds + "s"; return ChatColor.translateAlternateColorCodes('&', "&7" + timeleft + " left"); }
public String getFormatString(String path, Map<String, String> params) { String str = this.getString(path); for (String key : params.keySet()) { str = str.replace("$" + key.toLowerCase() + "$", params.get(key)); } return ChatColor.translateAlternateColorCodes('&', str); }
public void setTitle(CommandSender sender, String title) { // Check if the setter has it. if (sender.hasPermission(Permission.TITLE_COLOR.node)) { title = ChatColor.translateAlternateColorCodes('&', title); } this.title = title; }
@Override public void run() { ArmorStand hologram = getArmorStand(b); hologram.setCustomName(ChatColor.translateAlternateColorCodes('&', name)); } });
private String formatLobbyScoreboardString(String str) { String finalStr = str; finalStr = finalStr.replace("$regionname$", this.region.getName()); finalStr = finalStr.replace("$gamename$", this.name); finalStr = finalStr.replace("$players$", String.valueOf(this.getPlayerAmount())); finalStr = finalStr.replace("$maxplayers$", String.valueOf(this.getMaxPlayers())); return ChatColor.translateAlternateColorCodes('&', finalStr); }
@SuppressWarnings("unchecked") private void parseLore() { List<String> lores = new ArrayList<String>(); ItemMeta im = this.finalStack.getItemMeta(); for (Object lore : (List<String>) this.linkedSection.get("lore")) { lores.add(ChatColor.translateAlternateColorCodes('&', lore.toString())); } im.setLore(lores); this.finalStack.setItemMeta(im); }
private void parseCustomName() { String name = ChatColor.translateAlternateColorCodes('&', this.linkedSection.get("name").toString()); ItemMeta im = this.finalStack.getItemMeta(); im.setDisplayName(name); this.finalStack.setItemMeta(im); }
private void sendHelp(CommandSender sender) { sender.sendMessage(""); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aSlimefun &2v" + plugin.getDescription().getVersion())); sender.sendMessage(""); for (int i = 0; i < arguments.size(); i++) { sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&3" + arguments.get(i) + " &b") + descriptions.get(i)); } }
public static float getStoredEnergy(ItemStack item) { if (item == null || item.getType() == null || item.getType().equals(Material.AIR)) return 0F; if (!item.hasItemMeta() || !item.getItemMeta().hasLore()) return 0F; for (String line: item.getItemMeta().getLore()) { if (line.startsWith(ChatColor.translateAlternateColorCodes('&', "&c&o&8\u21E8 &e\u26A1 &7")) && line.contains(" / ") && line.endsWith(" J")) { return Float.valueOf(line.split(" / ")[0].replace(ChatColor.translateAlternateColorCodes('&', "&c&o&8\u21E8 &e\u26A1 &7"), "")); } } return 0F; }
private String formatScoreboardTitle() { String format = BedwarsRel.getInstance() .getStringConfig("scoreboard.format-title", "&e$region$&f - $time$"); // replaces format = format.replace("$region$", this.getRegion().getName()); format = format.replace("$game$", this.name); format = format.replace("$time$", this.getFormattedTimeLeft()); return ChatColor.translateAlternateColorCodes('&', format); }
public static String pluginMessage(String str) { return ChatColor.translateAlternateColorCodes('&', BedwarsRel.getInstance().getConfig().getString("chat-prefix", ChatColor.GRAY + "[" + ChatColor.AQUA + "BedWars" + ChatColor.GRAY + "]")) + " " + ChatColor.WHITE + str; }
private String[] getSignLines() { String[] sign = new String[4]; sign[0] = this.replacePlaceholder(ChatColor.translateAlternateColorCodes('&', BedwarsRel.getInstance().getConfig().getString("sign.first-line"))); sign[1] = this.replacePlaceholder(ChatColor.translateAlternateColorCodes('&', BedwarsRel.getInstance().getConfig().getString("sign.second-line"))); sign[2] = this.replacePlaceholder(ChatColor.translateAlternateColorCodes('&', BedwarsRel.getInstance().getConfig().getString("sign.third-line"))); sign[3] = this.replacePlaceholder(ChatColor.translateAlternateColorCodes('&', BedwarsRel.getInstance().getConfig().getString("sign.fourth-line"))); return sign; }
@Override public void onReload() { if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) { getLogger().severe("ViaVersion is already loaded, we're going to kick all the players... because otherwise we'll crash because of ProtocolLib."); for (Player player : Bukkit.getOnlinePlayers()) { player.kickPlayer(ChatColor.translateAlternateColorCodes('&', getConf().getReloadDisconnectMsg())); } } else { getLogger().severe("ViaVersion is already loaded, this should work fine. If you get any console errors, try rebooting."); } }
@Override public String getString(String path) { if (super.get(path) == null) { BedwarsRel.getInstance().getServer().getConsoleSender() .sendMessage(ChatWriter .pluginMessage(ChatColor.GOLD + "No translation found for: \"" + path + "\"")); return "LOCALE_NOT_FOUND"; } return ChatColor.translateAlternateColorCodes('&', super.getString(path)); }
@Override public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) { p.closeInventory(); p.sendMessage(""); p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + Slimefun.getItemConfig().getString(sfItem.getID() + ".wiki"))); p.sendMessage(""); return false; } });