/** * Converts a {@link Title} to 3 instances of {@link TitleMessage}. * * @param title the title to convert * @return 3 messages: the first sets the title, the second sets the subtitle, and the third * sets the fade/stay/fade durations */ public static TitleMessage[] fromTitle(Title title) { TextMessage titleMessage = asTextMessage(BaseComponent.toLegacyText(title.getTitle())); TextMessage subTitleMessage = title.getSubtitle() != null ? asTextMessage( BaseComponent.toLegacyText(title.getSubtitle())) : asTextMessage(null); return new TitleMessage[]{ new TitleMessage(Action.TITLE, titleMessage), new TitleMessage(Action.SUBTITLE, subTitleMessage), new TitleMessage(Action.TIMES, title.getFadeIn(), title.getStay(), title .getFadeOut()) }; }
void toLegacyText(StringBuilder builder) { if ( extra != null ) { for ( BaseComponent e : extra ) { e.toLegacyText( builder ); } } } }
@Deprecated public String getDescription() { return BaseComponent.toLegacyText( description ); }
@Override protected void toLegacyText(StringBuilder builder) { builder.append( this.selector ); super.toLegacyText( builder ); } }
@Deprecated public String getKickReason() { return BaseComponent.toLegacyText( kickReasonComponent ); }
@Override protected void toLegacyText(StringBuilder builder) { builder.append( this.value ); super.toLegacyText( builder ); } }
/** * Converts the component to a string that uses the old formatting codes * ({@link net.md_5.bungee.api.ChatColor#COLOR_CHAR} * * @return the string in the old format */ public String toLegacyText() { StringBuilder builder = new StringBuilder(); toLegacyText( builder ); return builder.toString(); }
/** * Converts the components to a string that uses the old formatting codes * ({@link net.md_5.bungee.api.ChatColor#COLOR_CHAR} * * @param components the components to convert * @return the string in the old format */ public static String toLegacyText(BaseComponent... components) { StringBuilder builder = new StringBuilder(); for ( BaseComponent msg : components ) { builder.append( msg.toLegacyText() ); } return builder.toString(); }
/** * @return reason to be displayed * @deprecated Use component methods instead. */ @Deprecated public String getCancelReason() { return BaseComponent.toLegacyText( getCancelReasonComponents() ); }
@Override public void sendMessage(BaseComponent message) { sendMessage( message.toLegacyText() ); }
/** * @return reason to be displayed * @deprecated Use component methods instead. */ @Deprecated public String getCancelReason() { return BaseComponent.toLegacyText( getCancelReasonComponents() ); }
@Override public void sendMessage(BaseComponent... message) { sendMessage( BaseComponent.toLegacyText( message ) ); }
case 'd': String withIndex = matcher.group( 1 ); with.get( withIndex != null ? Integer.parseInt( withIndex ) - 1 : i++ ).toLegacyText( builder ); break; case '%': builder.append( trans.substring( position, trans.length() ) ); super.toLegacyText( builder );
@Override protected void toLegacyText(StringBuilder builder) { builder.append( getColor() ); if ( isBold() ) { builder.append( ChatColor.BOLD ); } if ( isItalic() ) { builder.append( ChatColor.ITALIC ); } if ( isUnderlined() ) { builder.append( ChatColor.UNDERLINE ); } if ( isStrikethrough() ) { builder.append( ChatColor.STRIKETHROUGH ); } if ( isObfuscated() ) { builder.append( ChatColor.MAGIC ); } builder.append( text ); super.toLegacyText( builder ); }
@Override protected void toLegacyText(StringBuilder builder) { builder.append( getColor() ); if ( isBold() ) { builder.append( ChatColor.BOLD ); } if ( isItalic() ) { builder.append( ChatColor.ITALIC ); } if ( isUnderlined() ) { builder.append( ChatColor.UNDERLINE ); } if ( isStrikethrough() ) { builder.append( ChatColor.STRIKETHROUGH ); } if ( isObfuscated() ) { builder.append( ChatColor.MAGIC ); } builder.append( getKeybind() ); super.toLegacyText( builder ); } }
@Override public void broadcast(BaseComponent message) { getConsole().sendMessage( message.toLegacyText() ); broadcast( new Chat( ComponentSerializer.toString( message ) ) ); }
@Override public void broadcast(BaseComponent... message) { getConsole().sendMessage( BaseComponent.toLegacyText( message ) ); broadcast( new Chat( ComponentSerializer.toString( message ) ) ); }
public void disconnect0(final BaseComponent... reason) { if ( !ch.isClosing() ) { bungee.getLogger().log( Level.INFO, "[{0}] disconnected with: {1}", new Object[] { getName(), BaseComponent.toLegacyText( reason ) } ); ch.delayedClose( new Kick( ComponentSerializer.toString( reason ) ) ); if ( server != null ) { server.setObsolete( true ); server.disconnect( "Quitting" ); } } }
@Override public void sendMessage(ChatMessageType position, BaseComponent... message) { // transform score components message = ChatComponentTransformer.getInstance().transform( this, message ); // Action bar doesn't display the new JSON formattings, legacy works - send it using this for now if ( position == ChatMessageType.ACTION_BAR ) { sendMessage( position, ComponentSerializer.toString( new TextComponent( BaseComponent.toLegacyText( message ) ) ) ); } else { sendMessage( position, ComponentSerializer.toString( message ) ); } }
@Override public void sendMessage(ChatMessageType position, BaseComponent message) { message = ChatComponentTransformer.getInstance().transform( this, message )[0]; // Action bar doesn't display the new JSON formattings, legacy works - send it using this for now if ( position == ChatMessageType.ACTION_BAR ) { sendMessage( position, ComponentSerializer.toString( new TextComponent( BaseComponent.toLegacyText( message ) ) ) ); } else { sendMessage( position, ComponentSerializer.toString( message ) ); } }