/** * Creates a ComponentBuilder with the given component as the first part. * * @param component the first component element */ public ComponentBuilder(BaseComponent component) { current = component.duplicate(); }
/** * Creates a ComponentBuilder from the other given ComponentBuilder to clone * it. * * @param original the original for the new ComponentBuilder. */ public ComponentBuilder(ComponentBuilder original) { current = original.current.duplicate(); for ( BaseComponent baseComponent : original.parts ) { parts.add( baseComponent.duplicate() ); } }
/** * Clones the BaseComponent without formatting and returns the clone. * * @return The duplicate of this BaseComponent * @deprecated API use discouraged, use traditional duplicate */ @Deprecated public BaseComponent duplicateWithoutFormatting() { BaseComponent component = duplicate(); component.retain( FormatRetention.NONE ); return component; }
/** * Appends a component to the builder and makes it the current target for * formatting. You can specify the amount of formatting retained from * previous part. * * @param component the component to append * @param retention the formatting to retain * @return this ComponentBuilder for chaining */ public ComponentBuilder append(BaseComponent component, FormatRetention retention) { parts.add( current ); BaseComponent previous = current; current = component.duplicate(); current.copyFormatting( previous, retention, false ); return this; }
/** * Appends the components to the builder and makes the last element the * current target for formatting. You can specify the amount of formatting * retained from previous part. * * @param components the components to append * @param retention the formatting to retain * @return this ComponentBuilder for chaining */ public ComponentBuilder append(BaseComponent[] components, FormatRetention retention) { Preconditions.checkArgument( components.length != 0, "No components to append" ); BaseComponent previous = current; for ( BaseComponent component : components ) { parts.add( current ); current = component.duplicate(); current.copyFormatting( previous, retention, false ); } return this; }
/** * Creates a translatable component from the original to clone it. * * @param original the original for the new translatable component. */ public TranslatableComponent(TranslatableComponent original) { super( original ); setTranslate( original.getTranslate() ); if ( original.getWith() != null ) { List<BaseComponent> temp = new ArrayList<BaseComponent>(); for ( BaseComponent baseComponent : original.getWith() ) { temp.add( baseComponent.duplicate() ); } setWith( temp ); } }
BaseComponent(BaseComponent old) { copyFormatting( old, FormatRetention.ALL, true ); if ( old.getExtra() != null ) { for ( BaseComponent extra : old.getExtra() ) { addExtra( extra.duplicate() ); } } }
/** * Creates a ComponentBuilder from the other given ComponentBuilder to clone * it. * * @param original the original for the new ComponentBuilder. */ public ComponentBuilder(ComponentBuilder original) { current = new TextComponent( original.current ); for ( BaseComponent baseComponent : original.parts ) { parts.add( baseComponent.duplicate() ); } }
/** * Creates a translatable component from the original to clone it. * * @param original the original for the new translatable component. */ public TranslatableComponent(TranslatableComponent original) { super( original ); setTranslate( original.getTranslate() ); if ( original.getWith() != null ) { List<BaseComponent> temp = new ArrayList<BaseComponent>(); for ( BaseComponent baseComponent : original.getWith() ) { temp.add( baseComponent.duplicate() ); } setWith( temp ); } }
BaseComponent(BaseComponent old) { setColor( old.getColorRaw() ); setBold( old.isBoldRaw() ); setItalic( old.isItalicRaw() ); setUnderlined( old.isUnderlinedRaw() ); setStrikethrough( old.isStrikethroughRaw() ); setObfuscated( old.isObfuscatedRaw() ); setInsertion( old.getInsertion() ); setClickEvent( old.getClickEvent() ); setHoverEvent( old.getHoverEvent() ); if ( old.getExtra() != null ) { for ( BaseComponent component : old.getExtra() ) { addExtra( component.duplicate() ); } } }