/** * 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 text to the builder and makes it the current target for * formatting. You can specify the amount of formatting retained from * previous part. * * @param text the text to append * @param retention the formatting to retain * @return this ComponentBuilder for chaining */ public ComponentBuilder Append(string text, FormatRetention retention) { _parts.Add(_current); BaseComponent old = _current; _current = new TextComponent(text); _current.CopyFormatting(old, 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) { if (components.Length == 0) { return(this); } //Preconditions.checkArgument(components.Length != 0, "No components to append"); BaseComponent previous = _current; foreach (BaseComponent component in components) { _parts.Add(_current); _current = component.Duplicate(); _current.CopyFormatting(previous, retention, false); } return(this); }