From 84e56d21d32f364578bbe8536c228f5b4641a722 Mon Sep 17 00:00:00 2001 From: tahmid-23 <60953955+tahmid-23@users.noreply.github.com> Date: Sun, 25 Jun 2023 19:01:14 -0400 Subject: [PATCH 1/4] add list dynamic replacement --- source/minimessage/dynamic-replacements.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/source/minimessage/dynamic-replacements.rst b/source/minimessage/dynamic-replacements.rst index 3f23592..09ec8ff 100644 --- a/source/minimessage/dynamic-replacements.rst +++ b/source/minimessage/dynamic-replacements.rst @@ -134,6 +134,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 !", 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 .", Formatter.joining(Component.text("John"), Component.text("Emma"), Component.text("Alex"))); + +This will result in ``Please meet John, Emma and Alex``. + Complex placeholders ^^^^^^^^^^^^^^^^^^^^ From 7e634c803bee1b5559b3012c2e2d8055c06ef223 Mon Sep 17 00:00:00 2001 From: Kieran Wallbanks Date: Wed, 30 Oct 2024 17:41:46 +0000 Subject: [PATCH 2/4] update docs with latest changes --- source/minimessage/dynamic-replacements.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/minimessage/dynamic-replacements.rst b/source/minimessage/dynamic-replacements.rst index 09ec8ff..3d7da10 100644 --- a/source/minimessage/dynamic-replacements.rst +++ b/source/minimessage/dynamic-replacements.rst @@ -139,13 +139,17 @@ 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. +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: +1. The separator to use between components (defaults to no separator). +1. The separator to use between the last two components (defaults to the first argument). +1. 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 !", 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!``. +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. @@ -155,7 +159,6 @@ If you want to use a different separator between the last two components, you ca This will result in ``Please meet John, Emma and Alex``. - Complex placeholders ^^^^^^^^^^^^^^^^^^^^ From a1595e8af55e6039b08615520d855350b0c97ed4 Mon Sep 17 00:00:00 2001 From: Kieran Wallbanks Date: Wed, 30 Oct 2024 17:44:49 +0000 Subject: [PATCH 3/4] learn how to write lists in rst --- source/minimessage/dynamic-replacements.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/minimessage/dynamic-replacements.rst b/source/minimessage/dynamic-replacements.rst index 3d7da10..e340455 100644 --- a/source/minimessage/dynamic-replacements.rst +++ b/source/minimessage/dynamic-replacements.rst @@ -141,9 +141,9 @@ 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: -1. The separator to use between components (defaults to no separator). -1. The separator to use between the last two components (defaults to the first argument). -1. The separator to use between the last two components if there are more than two components (defaults to the second argument). +#. 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 From b5d3c567c482772c9b950af61879843a89010316 Mon Sep 17 00:00:00 2001 From: Kieran Wallbanks Date: Wed, 30 Oct 2024 17:52:08 +0000 Subject: [PATCH 4/4] add a newline perhaps --- source/minimessage/dynamic-replacements.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/source/minimessage/dynamic-replacements.rst b/source/minimessage/dynamic-replacements.rst index e340455..dfa4930 100644 --- a/source/minimessage/dynamic-replacements.rst +++ b/source/minimessage/dynamic-replacements.rst @@ -141,6 +141,7 @@ 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).