/** * Appends the text to the builder and makes it the current target for * formatting. The text will have all the formatting from previous part. * * @param text the text to append * @return this ComponentBuilder for chaining */ public ComponentBuilder append(String text) { return append( text, FormatRetention.ALL ); }
/** * Appends a component to the builder and makes it the current target for * formatting. The component will have all the formatting from previous * part. * * @param component the component to append * @return this ComponentBuilder for chaining */ public ComponentBuilder append(BaseComponent component) { return append( component, FormatRetention.ALL ); }
/** * Appends the components to the builder and makes the last element the * current target for formatting. The components will have all the * formatting from previous part. * * @param components the components to append * @return this ComponentBuilder for chaining */ public ComponentBuilder append(BaseComponent[] components) { return append( components, FormatRetention.ALL ); }
/** * Parse text to BaseComponent[] with colors and format, appends the text to * the builder and makes it the current target for formatting. The component * will have all the formatting from previous part. * * @param text the text to append * @return this ComponentBuilder for chaining */ public ComponentBuilder appendLegacy(String text) { return append( TextComponent.fromLegacyText( text ) ); }
} else sender.sendMessage( new ComponentBuilder( "An error occurred while parsing your message: " ).color( ChatColor.RED ).append( error.getMessage() ).create() );
/** * Appends the text to the builder and makes it the current target for * formatting. The text will have all the formatting from the previous part. * * @param text the text to append * @return this ComponentBuilder for chaining */ public ComponentBuilder append(String text) { return append( text, FormatRetention.ALL ); }
@Override public ComponentBuilder append(String text) { builder.append(text); return this; }
@Override public void execute(CommandSender sender, String[] args) { if ( args.length != 1 ) { sender.sendMessage( new ComponentBuilder( "Please follow this command by a user name" ).color( ChatColor.RED ).create() ); } else { ProxiedPlayer player = ProxyServer.getInstance().getPlayer( args[0] ); if ( player == null || player.getServer() == null ) { sender.sendMessage( new ComponentBuilder( "That user is not online" ).color( ChatColor.RED ).create() ); } else { sender.sendMessage( new ComponentBuilder( args[0] ).color( ChatColor.GREEN ).append( " is online at " ).append( player.getServer().getInfo().getName() ).create() ); } } } }
ComponentBuilder serverList = new ComponentBuilder( "" ).append( TextComponent.fromLegacyText( ProxyServer.getInstance().getTranslation( "server_list" ) ) ); boolean first = true; for ( ServerInfo server : servers.values() ) serverTextComponent.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( count + ( count == 1 ? " player" : " players" ) + "\n" ) .append( "Click to connect to the server" ).italic( true ) .create() ) ); serverTextComponent.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/server " + server.getName() ) ); serverList.append( serverTextComponent ); first = false;
private static ComponentBuilder getNewComponentBuilder(String skillName) { ComponentBuilder componentBuilder = new ComponentBuilder(skillName); componentBuilder.append("\n"); return componentBuilder; }
private static void addLocked(ChatColor ccLocked, ChatColor ccLevelRequirement, ComponentBuilder componentBuilder) { componentBuilder.append(LocaleLoader.getString("JSON.Locked")).color(ccLocked).bold(true); componentBuilder.append("\n").append("\n").bold(false); componentBuilder.append(LocaleLoader.getString("JSON.LevelRequirement") + ": ").color(ccLevelRequirement); }
@Override public ComponentBuilder append(String text, ChatColor color) { builder.append(text, net.md_5.bungee.api.chat.ComponentBuilder.FormatRetention.FORMATTING).color(color.asBungee()); return this; }
private static void addRanked(ChatColor ccRank, ChatColor ccCurRank, ChatColor ccPossessive, ChatColor ccNumRanks, ComponentBuilder componentBuilder, int numRanks, int rank, int nextRank) { if (numRanks > 0) { //Rank: x componentBuilder.append(LocaleLoader.getString("JSON.Hover.Rank", String.valueOf(rank))).append("\n") .bold(false).italic(false).strikethrough(false).underlined(false); //Next Rank: x if(nextRank > rank) componentBuilder.append(LocaleLoader.getString("JSON.Hover.NextRank", String.valueOf(nextRank))).append("\n") .bold(false).italic(false).strikethrough(false).underlined(false); /*componentBuilder.append(" " + LocaleLoader.getString("JSON.RankPossesive") + " ").color(ccPossessive); componentBuilder.append(String.valueOf(numRanks)).color(ccNumRanks);*/ } }
private static void addLocked(SubSkillType subSkillType, ChatColor ccLocked, ChatColor ccLevelRequirement, ChatColor ccLevelRequired, ComponentBuilder componentBuilder) { addLocked(ccLocked, ccLevelRequirement, componentBuilder); componentBuilder.append(String.valueOf(RankConfig.getInstance().getSubSkillUnlockLevel(subSkillType, 1))).color(ccLevelRequired); //componentBuilder.append("\n"); }
private static void addLocked(AbstractSubSkill abstractSubSkill, ChatColor ccLocked, ChatColor ccLevelRequirement, ChatColor ccLevelRequired, ComponentBuilder componentBuilder) { addLocked(ccLocked, ccLevelRequirement, componentBuilder); componentBuilder.append(String.valueOf(RankConfig.getInstance().getSubSkillUnlockLevel(abstractSubSkill, 1))).color(ccLevelRequired); //componentBuilder.append("\n"); }
private ComponentBuilder getPrefix() { return new ComponentBuilder("[").color(ChatColor.BLUE).append( "BungeeTabListPlus").color(ChatColor.YELLOW).event( new ClickEvent(ClickEvent.Action.OPEN_URL, "http://www.spigotmc.org/resources/bungeetablistplus.313/")). append("] ").color(ChatColor.BLUE).event((ClickEvent) null); }
public static void sendHoverTip(Player player) { player.sendMessage(""); player.spigot().sendMessage(new ComponentBuilder("TIP").color(ChatColor.YELLOW).bold(true) .append(" Try to ", FormatRetention.NONE).color(ChatColor.GRAY) .append("hover").color(ChatColor.WHITE).italic(true).underlined(true) .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.LIGHT_PURPLE + "Hover on the commands to get info about them."))) .append(" or ", FormatRetention.NONE).color(ChatColor.GRAY) .append("click").color(ChatColor.WHITE).italic(true).underlined(true) .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.LIGHT_PURPLE + "Click on the commands to insert them in the chat."))) .append(" on the commands!", FormatRetention.NONE).color(ChatColor.GRAY) .create()); }
public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted) { if(!Config.getInstance().getUrlLinksEnabled()) return; Player.Spigot spigotPlayer = player.spigot(); TextComponent wikiLinkComponent = new TextComponent(LocaleLoader.getString("Overhaul.mcMMO.MmoInfo.Wiki")); wikiLinkComponent.setUnderlined(true); String wikiUrl = "https://mcmmo.org/wiki/"+subskillformatted; wikiLinkComponent.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, wikiUrl)); ComponentBuilder componentBuilder = new ComponentBuilder(subskillformatted).append("\n").append(wikiUrl).color(ChatColor.GRAY).italic(true); wikiLinkComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, componentBuilder.create())); spigotPlayer.sendMessage(ChatMessageType.SYSTEM, wikiLinkComponent); }
private BaseComponent[] formatTask(BukkitTask pendingTask) { Plugin owner = pendingTask.getOwner(); int taskId = pendingTask.getTaskId(); boolean sync = pendingTask.isSync(); String id = Integer.toString(taskId); if (sync) { id += "-Sync"; } else if (Bukkit.getScheduler().isCurrentlyRunning(taskId)) { id += "-Running"; } return new ComponentBuilder(owner.getName()) .color(PRIMARY_COLOR.asBungee()) .append('-' + id) .color(SECONDARY_COLOR.asBungee()) .create(); }