Skip to content

Commit

Permalink
add list dynamic replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
tahmid-23 committed Jun 25, 2023
1 parent d29262c commit 6bc9884
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion source/minimessage/dynamic-replacements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,27 @@ 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 with a separator.
.. 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 with your 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``.
Custom placeholders
^^^^^^^^^^^^^^^^^^^
Expand All @@ -125,4 +146,4 @@ Create your own styling tags:
TagResolver.resolver("myhover", Tag.styling(HoverEvent.showText(Component.text("test")))); // will display your custom text as hover
TagResolver.resolver("mycmd", Tag.styling(ClickEvent.runCommand("/mycmd is cool"))); // will create a clickable text which will run your specified command.
You can use those tags instead of using the parsed placeholder.
You can use those tags instead of using the parsed placeholder.

0 comments on commit 6bc9884

Please sign in to comment.