Skip to content

add list dynamic replacement #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main/4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions source/minimessage/dynamic-replacements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,31 @@ This will accept a ChoiceFormat pattern.

This will format your input based on the provided ChoiceFormat. In this case it will be ``I met many developers!``

Insert a list
-------------

To insert a list of components, you can use the list formatter.

This tag resolver will join components together.
It will accept three arguments, all of which are optional but must be provided in order and with all preceding arguments present:

#. The separator to use between components (defaults to no separator).
#. The separator to use between the last two components (defaults to the first argument).
#. The separator to use between the last two components if there are more than two components (defaults to the second argument).

.. code:: java

MiniMessage.miniMessage().deserialize("Let's play <moves:, >!", Formatter.joining(Component.text("rock"), Component.text("paper"), Component.text("scissors")));

This will format your list of components by joining them together the designated separator. In this case, it will be ``Let's play rock, paper, scissors!``.

If you want to use a different separator between the last two components, you can add another argument for the last separator.

.. code:: java

MiniMessage.miniMessage().deserialize("Please meet <names:, : and >.", Formatter.joining(Component.text("John"), Component.text("Emma"), Component.text("Alex")));

This will result in ``Please meet John, Emma and Alex``.

Complex placeholders
^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading