mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-23 18:55:22 +01:00
#2436: Extend chat module with Joiner functional interface support
This commit is contained in:
parent
fa542c70df
commit
ceb9ea1e52
@ -166,6 +166,37 @@ public final class ComponentBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows joining additional components to this builder using the given
|
||||
* {@link Joiner} and {@link FormatRetention#ALL}.
|
||||
*
|
||||
* Simply executes the provided joiner on this instance to facilitate a
|
||||
* chain pattern.
|
||||
*
|
||||
* @param joiner joiner used for operation
|
||||
* @return this ComponentBuilder for chaining
|
||||
*/
|
||||
public ComponentBuilder append(Joiner joiner)
|
||||
{
|
||||
return joiner.join( this, FormatRetention.ALL );
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows joining additional components to this builder using the given
|
||||
* {@link Joiner}.
|
||||
*
|
||||
* Simply executes the provided joiner on this instance to facilitate a
|
||||
* chain pattern.
|
||||
*
|
||||
* @param joiner joiner used for operation
|
||||
* @param retention the formatting to retain
|
||||
* @return this ComponentBuilder for chaining
|
||||
*/
|
||||
public ComponentBuilder append(Joiner joiner, FormatRetention retention)
|
||||
{
|
||||
return joiner.join( this, retention );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color of the current part.
|
||||
*
|
||||
@ -332,4 +363,25 @@ public final class ComponentBuilder
|
||||
*/
|
||||
ALL
|
||||
}
|
||||
|
||||
/**
|
||||
* Functional interface to join additional components to a ComponentBuilder.
|
||||
*/
|
||||
public interface Joiner
|
||||
{
|
||||
|
||||
/**
|
||||
* Joins additional components to the provided {@link ComponentBuilder}
|
||||
* and then returns it to fulfill a chain pattern.
|
||||
*
|
||||
* Retention may be ignored and is to be understood as an optional
|
||||
* recommendation to the Joiner and not as a guarantee to have a
|
||||
* previous component in builder unmodified.
|
||||
*
|
||||
* @param componentBuilder to which to append additional components
|
||||
* @param retention the formatting to possibly retain
|
||||
* @return input componentBuilder for chaining
|
||||
*/
|
||||
ComponentBuilder join(ComponentBuilder componentBuilder, FormatRetention retention);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user