Skip to content

Language Config

plazmer edited this page Nov 9, 2023 · 3 revisions

Each plugin depends on PLAZMER-ENGINE has a /lang/ folder with configs of translatable messages for different languages. There are some tips and features you can use to customize your messages and redefine the plugin style.

Creating Language

To create a new language config, use the following filename pattern: messages_ + your language code. For example, messages_ru.yml. Then, in plugin config.yml in Plugin.Language option set your language code, ru in this example.

Custom Placeholders

In the messages config, it's possible to create your own placeholders for internal usage. Add the following section at a top of the messages config:

Placeholders:
  # Placeholder: 'Text'
  <sl_gray>: '#b3b6b1'
  <sl_dark_gray>: '#6c6c62'
  <sl_yellow>: '#fff35d'
  <sl_orange>: '#b3ff5d'

Now, we can use <sl_gray>, <sl_yellow>, <sl_orange> placeholders in all our messages that will give us predefined colors!

Note: Placeholder will be the same as you put it in placeholder section. So make sure to add some brackets to it for best results and avoid regular word replacing.

Message Options

For almost every message (except a few special ones) you can set options to change it for your needs.
Use the following pattern before the message to set options: <! option1:"value" option2:"value" !>, Where option1 and option2 are option names, and value is option value. Note, that every option value must be in quotes (double " ", or single ones ' '). For YAML files it's more clear to use double quotes, as they don't have to be escaped like single ones.

List of Options:

  • Type. Sets the message output type.
    Allowed values: chat, none, action_bar, titles. If this option is missed, chat type will be used.

    Test_Message: '<! type:"action_bar" !>&eHello!'

    For titles type, you have to provide times (fade in, stay, fade out):

    Test_Message: '<! type:"titles:20:60:20" !>&eHello!'
  • Prefix. Sets if message will have a plugin prefix.
    By default, every message will have a plugin prefix until you set prefix option to false. Allowed values: true, false.

    Test_Message: '<! prefix:"false" !>&eHello!'
  • Sound: Plays a specified sound to the message receiver.
    Navigate to the Sound page for a list of all sound names.

    Test_Message: '<! sound:"ENTITY_PLAYER_LEVEL_UP" !>&eHello!'
  • PAPI: Tells plugin to use PlaceholderAPI placeholders in the message.
    Allowed values: true, false.

    Test_Message: '<! papi:"true" !>Hello, %player_name%. Your balance: $%vault_eco_balance_formatted%.'

JSON Formatting

For almost every message (except a few special ones) you can apply custom JSON formatting. You can use as many json formats in the same message as you want.
Use the following pattern somewhere in message to apply JSON formatting:

Sample message with <? option1:"value" option2:"value" ?>Custom Text</>

Note, that options are inside the <? ?> tag, then your text, and closing </> tag.

Where option1 and option2 are option names, and value is option value. Note, that every option value must be in quotes (double " ", or single ones ' '). For YAML files it's more clear to use double quotes, as they don't have to be escaped like single ones.

You can use only one Hover and Click options for each JSON element.

Hover Options:

  • Show Text. Shows a text when you hover cursor over the message.
    Use <newline> tag to break the line.

    Test_Message: '<? show_text:"&eHover Text<newline>&aLine 1<newline>&bLine 2" ?>&e&lHello!</>'
  • Show Item. Displays itemstack info/meta when you hover cursor over the message.
    Note: You need a Base64 value of the item stack to display it. In this example we used base64 value of the Air item.

    Test_Message: '<? show_item:"k00010004qb4006mqqbeclhn4ob6egt62qbi0400agrfeln78080" ?>&e&lAir Item</>'

Click Options:

  • Run Command. Force player to run a /command or send a chat message (No longer works since 1.19).

    Test_Message: '<? run_command:"/spawn" ?>&bClick me to /spawn!</>'
  • Suggest Command. Insert text into the player's chat box.

    Test_Message: '<? suggest_command:"/spawn" ?>&bClick me to /spawn!</>'
  • Open URL. Promts the player to open specified link.
    Note: Make sure your link starts with www or http(s):// otherwise it will not work!

    Test_Message: '<? open_url:"http://google.com/" ?>&bClick to &lGoogle</>'
  • Copy to Clipboard. Copies text to player's clipboard.

    Test_Message: '<? copy_to_clipboard:"Text to be copied" ?>&bCopy Text!</>'

Other Options:

  • Font. Sets a font for the selected text.

    Test_Message: '<? font:"uniform" ?>Uniform Text Font</>'
  • Insertion.

    Test_Message: '<? insertion:"Text to insert" ?>Click to Insert</>'

Split Message into Lines

You can split messages into multiple lines and vice versa - set multi-line messages to a single line. This can be done through two ways: Adding the line breaker \n, and using the YAML list syntax.

Let's consider an example:

Test_Message: '<! titles:"10:30:20" !>&eHello! \n &7Have a nice day!'

Here we used the line breaker \n, spaces will be trimmed, and on plugin load it will be converted to a list like this:

Test_Message:
  - '<! titles:"10:30:20" !>'
  - '&eHello!'
  - '&7Have a nice day!'

Examples

Send message with url and copy:

Test_Message:
  - '<? open_url:"https://example.com/" show_text:"Open"?>Open site</> or'
  - '<? copy_to_clipboard:"https://example.com/" show_text:"Copy"?>Copy link</>'

As you can see, we put message options on it's own line. It will be converted to an empty line and will be skipped in game. As we set message type to TITLES, it can't display more than 2 lines.

Please note: If you want to use empty lines in your messages, leave at least one color code in them instead of making it completely empty, otherwise they won't be displayed.

Support:

Donate
TELEGRAM
Discord channel
Discord: p1azmer

Clone this wiki locally