Java Code Examples for org.bukkit.ChatColor#translateAlternateColorCodes()
The following examples show how to use
org.bukkit.ChatColor#translateAlternateColorCodes() .
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: CommandHandler.java From NyaaUtils with MIT License | 6 votes |
@SubCommand(value = "setlore", permission = "nu.setlore") public void setlore(CommandSender sender, Arguments args) { if (!(args.length() > 1)) { msg(sender, "manual.setlore.usage"); return; } String lore = args.next().replace("ยง", ""); Player p = asPlayer(sender); lore = ChatColor.translateAlternateColorCodes('&', lore); ItemStack item = p.getInventory().getItemInMainHand(); if (item == null || item.getType().equals(Material.AIR)) { msg(sender, "user.info.no_item_hand"); return; } String[] line = lore.split("/n"); List<String> lines = new ArrayList<>(); for (String s : line) { lines.add(ChatColor.translateAlternateColorCodes('&', s)); } ItemMeta itemStackMeta = item.getItemMeta(); itemStackMeta.setLore(lines); item.setItemMeta(itemStackMeta); msg(sender, "user.setlore.success", lore); }
Example 2
Source File: Utils.java From NametagEdit with GNU General Public License v3.0 | 6 votes |
public static String format(String input, boolean limitChars) { String colored = ChatColor.translateAlternateColorCodes('&', input); if(VersionChecker.getBukkitVersion() == BukkitVersion.v1_13_R1) { return limitChars && colored.length() > 128 ? colored.substring(0, 128) : colored; } else if(VersionChecker.getBukkitVersion() == BukkitVersion.v1_14_R1) { return limitChars && colored.length() > 128 ? colored.substring(0, 128) : colored; } else if(VersionChecker.getBukkitVersion() == BukkitVersion.v1_14_R2) { return limitChars && colored.length() > 128 ? colored.substring(0, 128) : colored; } else if(VersionChecker.getBukkitVersion() == BukkitVersion.v1_15_R1) { return limitChars && colored.length() > 128 ? colored.substring(0, 128) : colored; } else if(VersionChecker.getBukkitVersion() == BukkitVersion.v1_15_R2) { return limitChars && colored.length() > 128 ? colored.substring(0, 128) : colored; } else if(VersionChecker.getBukkitVersion() == BukkitVersion.v1_16_R1) { return limitChars && colored.length() > 128 ? colored.substring(0, 128) : colored; } else { return limitChars && colored.length() > 16 ? colored.substring(0, 16) : colored; } }
Example 3
Source File: MessageAPI.java From DiscordMC with GNU General Public License v2.0 | 5 votes |
private static String getFormattedMessage(final IChannel origin, final String username) { String format = (String) DiscordMC.getUserFormats().get(username, "-"); String formattedMessage; if (!useIngameFormat || Objects.equals(format, "-")) { formattedMessage = ChatColor.translateAlternateColorCodes('&', DiscordMC.get().getConfig().getString("settings.templates.chat_message_minecraft") .replace("%user", username) .replace("%channel", origin.getName())); } else { formattedMessage = format.replace("%1$s", username).replace("%2$s", "%message"); } return formattedMessage; }
Example 4
Source File: GridManager.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * Get name of the island owned by owner * @param owner island owner UUID * @return Returns the name of owner's island, or the owner's name if there is none. */ public String getIslandName(UUID owner) { if (owner == null) { return ""; } return ChatColor.translateAlternateColorCodes('&', islandNames.getString(owner.toString(), plugin.getPlayers().getName(owner))) + ChatColor.RESET; }
Example 5
Source File: BukkitTranslateContainer.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
@Override public String translate(String key, String def) { if (config.isSet(key)) { return ChatColor.translateAlternateColorCodes('&', config.getString(key)); } else if (fallback != null) { return fallback.translate(key, def); } else if (def != null) { return ChatColor.translateAlternateColorCodes('&', def); } return ChatColor.RED.toString() + key; }
Example 6
Source File: TutorialBuilder.java From CardinalPGM with MIT License | 5 votes |
private Stage parseStage(Element stage) { String title = ChatColor.translateAlternateColorCodes('`', stage.getAttributeValue("title")); List<String> lines = new ArrayList<>(); RegionModule region = null; for (Element line : stage.getChild("message").getChildren("line")) { lines.add(ChatColor.translateAlternateColorCodes('`', line.getValue())); } Element teleport = stage.getChild("teleport"); if (teleport != null) { region = RegionModuleBuilder.getRegion(teleport.getChildren().get(0)); } return new Stage(title, lines, region); }
Example 7
Source File: Christmas.java From CS-CoreLib with GNU General Public License v3.0 | 5 votes |
public static String color(String string) { StringBuilder xmas = new StringBuilder(""); for (int i = 0; i < string.length(); i++) { xmas.append((i % 2 == 0 ? "&a": "&c")); xmas.append(string.charAt(i)); } return ChatColor.translateAlternateColorCodes('&', xmas.toString()); }
Example 8
Source File: UCDiscord.java From UltimateChat with GNU General Public License v3.0 | 5 votes |
private String formatTags(String format, UCChannel ch, MessageReceivedEvent e, String sender, String message) { format = format.replace("{ch-color}", ch.getColor()) .replace("{ch-alias}", ch.getAlias()) .replace("{ch-name}", ch.getName()); if (e != null) { sender = ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', e.getMember().getEffectiveName())); format = format.replace("{sender}", sender) .replace("{dd-channel}", e.getChannel().getName()) .replace("{message}", e.getMessage().getContentRaw()); if (!e.getMember().getRoles().isEmpty()) { Role role = e.getMember().getRoles().get(0); if (role.getColor() != null) { format = format.replace("{dd-rolecolor}", fromRGB( role.getColor().getRed(), role.getColor().getGreen(), role.getColor().getBlue()).toString()); } format = format.replace("{dd-rolename}", role.getName()); } if (e.getMember().getNickname() != null) { format = format.replace("{nickname}", ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', e.getMember().getNickname()))); } else { format = format.replace("{nickname}", sender); } } //if not filtered format = format .replace("{sender}", sender) .replace("{message}", message); format = format.replaceAll("\\{.*\\}", ""); return ChatColor.translateAlternateColorCodes('&', format); }
Example 9
Source File: Utils.java From Shopkeepers with GNU General Public License v3.0 | 4 votes |
public static String colorize(String message) { if (message == null || message.isEmpty()) return message; return ChatColor.translateAlternateColorCodes('&', message); }
Example 10
Source File: Locale.java From PlayTimeTracker with MIT License | 4 votes |
private static String getConfigStringWithColor(ConfigurationSection section, String key) { return ChatColor.translateAlternateColorCodes('&', section.getString(key)); }
Example 11
Source File: Message.java From StaffPlus with GNU General Public License v3.0 | 4 votes |
public String colorize(String message) { return ChatColor.translateAlternateColorCodes('&', message); }
Example 12
Source File: ActionBar.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
public static void sendActionBar(Player player, String message) { String s = ChatColor.translateAlternateColorCodes('&', message.replace("_", " ")); IChatBaseComponent icbc = ChatSerializer.a("{\"text\": \"" + s + "\"}"); PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte) 2); ((CraftPlayer) player).getHandle().playerConnection.sendPacket(bar); }
Example 13
Source File: GameKit.java From SkyWarsReloaded with GNU General Public License v3.0 | 4 votes |
public String getColoredLockedLore() { return ChatColor.translateAlternateColorCodes('&', lockedLore); }
Example 14
Source File: Hawk.java From Hawk with GNU General Public License v3.0 | 4 votes |
public void loadModules() { getLogger().info("Loading modules..."); USING_PLIB = getServer().getPluginManager().isPluginEnabled("ProtocolLib"); new File(plugin.getDataFolder().getAbsolutePath()).mkdirs(); messages = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "messages.yml")); checksConfig = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "checks.yml")); FLAG_PREFIX = ChatColor.translateAlternateColorCodes('&', ConfigHelper.getOrSetDefault("&cHAWK: &7", messages, "prefix")); sendJSONMessages = ConfigHelper.getOrSetDefault(false, getConfig(), "sendJSONMessages"); playSoundOnFlag = ConfigHelper.getOrSetDefault(false, getConfig(), "playSoundOnFlag"); FLAG_CLICK_COMMAND = ConfigHelper.getOrSetDefault("tp %player%", getConfig(), "flagClickCommand"); if (sendJSONMessages && getServerVersion() == 7) { sendJSONMessages = false; Bukkit.getLogger().warning("Hawk cannot send JSON flag messages on a 1.7.10 server! Please use 1.8.8 to use this feature."); } hawkSyncTaskScheduler = new HawkSyncTaskScheduler(this); Bukkit.getScheduler().scheduleSyncRepeatingTask(this, hawkSyncTaskScheduler, 0L, 1L); profiles = new ConcurrentHashMap<>(); getServer().getPluginManager().registerEvents(new PlayerEventListener(this), this); sqlModule = new SQLModule(this); sqlModule.createTableIfNotExists(); commandExecutor = new CommandExecutor(this); punishmentScheduler = new PunishmentScheduler(this); punishmentScheduler.load(); punishmentScheduler.start(); guiManager = new GUIManager(this); lagCompensator = new LagCompensator(this); banManager = new BanManager(this); banManager.loadBannedPlayers(); muteManager = new MuteManager(this); muteManager.loadMutedPlayers(); startLoggerFile(); bungeeBridge = new BungeeBridge(this, ConfigHelper.getOrSetDefault(false, getConfig(), "enableBungeeAlerts")); checkManager = new CheckManager(plugin); checkManager.loadChecks(); packetHandler = new PacketHandler(this); packetHandler.startListener(); packetHandler.setupListenerForOnlinePlayers(); mouseRecorder = new MouseRecorder(this); registerCommand(); saveConfigs(); }
Example 15
Source File: UCConfig.java From UltimateChat with GNU General Public License v3.0 | 4 votes |
public String getProtMsg(String key) { return ChatColor.translateAlternateColorCodes('&', Prots.getString(key)); }
Example 16
Source File: SidebarConfig.java From ScoreboardStats with MIT License | 4 votes |
public SidebarConfig(String displayName) { this.displayName = ChatColor.translateAlternateColorCodes('&', displayName); }
Example 17
Source File: TextLine.java From Holograms with MIT License | 4 votes |
TextLine(Hologram parent, String raw, String text) { super(parent, raw); this.text = ChatColor.translateAlternateColorCodes('&', text); }
Example 18
Source File: Strings.java From ScoreboardLib with GNU Lesser General Public License v3.0 | 4 votes |
public static String format(String string) { return ChatColor.translateAlternateColorCodes('&', string); }
Example 19
Source File: YAMLNode.java From skript-yaml with MIT License | 3 votes |
/** * Gets a string at a location. This will either return a String or null, with * null meaning that no configuration value exists at that location. If the * object at the particular location is not actually a string, it will be * converted to its string representation. * * @param path * path to node (dot notation) * @return string or null */ public String getString(String path) { Object o = getProperty(path); if (o == null) { return null; } //return o.toString(); return ChatColor.translateAlternateColorCodes('&', o.toString()); }
Example 20
Source File: UltimateFancy.java From RedProtect with GNU General Public License v3.0 | 2 votes |
/** * Root text to show with the colors parsed, close the last text properties and start a new text block. * * @param text * @return instance of same {@link UltimateFancy}. */ public UltimateFancy coloredTextAndNext(String text) { text = ChatColor.translateAlternateColorCodes('&', text); return this.textAndNext(text); }