diff --git a/cloud-core/src/main/java/org/incendo/cloud/context/CommandContext.java b/cloud-core/src/main/java/org/incendo/cloud/context/CommandContext.java index e2b50d5ec..3e74baa84 100644 --- a/cloud-core/src/main/java/org/incendo/cloud/context/CommandContext.java +++ b/cloud-core/src/main/java/org/incendo/cloud/context/CommandContext.java @@ -171,6 +171,54 @@ public CommandContext( ); } + /** + * Formats a {@code caption} using the given {@code formatter} and {@code recipient}. + * + * @param the message type produced by the formatter + * @param formatter the formatter + * @param recipient the recipient of the message. + * @param caption the caption key + * @param variables the variables to use during formatting + * @return the formatted caption + */ + public @NonNull T formatCaption( + final @NonNull CaptionFormatter formatter, + final @NonNull C recipient, + final @NonNull Caption caption, + final @NonNull CaptionVariable @NonNull... variables + ) { + return formatter.formatCaption( + caption, + recipient, + this.captionRegistry.caption(caption, recipient), + variables + ); + } + + /** + * Formats a {@code caption} using the given {@code formatter} and {@code recipient}. + * + * @param the message type produced by the formatter + * @param formatter the formatter + * @param recipient the recipient of the message. + * @param caption the caption key + * @param variables the variables to use during formatting + * @return the formatted caption + */ + public @NonNull T formatCaption( + final @NonNull CaptionFormatter formatter, + final @NonNull C recipient, + final @NonNull Caption caption, + final @NonNull List<@NonNull CaptionVariable> variables + ) { + return formatter.formatCaption( + caption, + recipient, + this.captionRegistry.caption(caption, recipient), + variables + ); + } + /** * Returns the sender that executed the command. *