Skip to content

Templates

What is 'template' in this plugin context?

Template - this is a special configuration file, that can be used for configure every chat without changes in global config.
You can use .yml or .json. Second option is experimental, so, if you use it - you may see bugs.

Modifing exists templates

For modify, we can use any file, in this example we're use one of defaults - global.yml

yml
config:
  # <prefix> - Prefix from LuckPerms, <suffix> - same, but with suffix
  # <nickname> - player nickname. <m> - message
  prompt: "<dark_gray>[<green>+</green>]</dark_gray> <prefix><reset><gold><nickname></gold><suffix> <gray> >>> <m><reset>"
  cooldown: 1 # Cooldown in seconds.
blacklist:
  global: true #if set to false, plugin will read blacklist from this place. Else, it will read from config.yml
  # config:
  #   minimessage: false # Disables able for players for use minimessage. By default, set to false or Minimessage can be used.
  #   gradients: false # Disables able for players for use gradients. By default, disabled.
  #   tags: # Disables custom (and not only) tags.
  #     - newline
  #     - obf

As you can see, here we have config and blacklist. Every in their order. Inside config we can see prompt for global chat. Inside it it's uses some custom prefixes - <prefix>, <suffix> (both from LuckPerms), <nickname> with player nickname and <m> with player message.
For example we can try to change it to something like it

yml
config:
  # <prefix> - Prefix from LuckPerms, <suffix> - same, but with suffix
  # <nickname> - player nickname. <m> - message
  prompt: "<dark_gray>[<green>GLOBAL</green>]</dark_gray> >>> <m><reset> - <prefix><reset><gold><nickname></gold><suffix>"
  cooldown: 1 # Cooldown in seconds.
# ... other sections ...

Here we changed order, and inside game we see it:
IMAGE - BEFORE RELOAD Why? Because you need to reload plugin before see changes. We can do it with /lc reload (requires permission l-chat.reload)
And after, we see it! IMAGE - RELOAD COMMAND AND NEW GLOBAL MESSAGE

Now, we change blacklist for global chat.

yml
# ... other sections ...
blacklist:
  global: true #if set to false, plugin will read blacklist from this place. Else, it will read from config.yml
 # config:
 #   minimessage: false # Disables able for players for use minimessage. By default, set to false or Minimessage can be used.
 #   gradients: false # Disables able for players for use gradients. By default, disabled.
 #   tags: # Disables custom (and not only) tags.
 #     - newline
 #     - obf

As we can see, section config are commented and there we use global blacklist, that defined in config.yml.
We need to do this:

yml
# ... other sections ...
blacklist:
  global: false #if set to false, plugin will read blacklist from this place. Else, it will read from config.yml
  config:
    minimessage: false # Disables able for players for use minimessage. By default, set to false or Minimessage can be used.
    gradients: false # Disables able for players for use gradients. By default, disabled.
    tags: # Disables custom (and not only) tags.
      - newline
      - obf

Now, reload plugin and check for hover in global chat and in, for example, local.
When we try to type to local chat without permission "l-chat.full-format-use", we will see IMAGE - Not enough rights In the same time, if we try to type same text in global:
IMAGE - Hover text But, if we try to use <obf>... IMAGE - obf not work Now, we return to default values everything:

yml
# ... other sections ...
blacklist:
  global: true #if set to false, plugin will read blacklist from this place. Else, it will read from config.yml
 # config:
 #   minimessage: false # Disables able for players for use minimessage. By default, set to false or Minimessage can be used.
 #   gradients: false # Disables able for players for use gradients. By default, disabled.
 #   tags: # Disables custom (and not only) tags.
 #     - newline
 #     - obf

Create your own template for chat

In this section, we will...

  • Create our own chat in .yml/.json
  • Add it to config.

YML chat template

At first, we need to know structure of .yml chat template.

yml
#example-chat.yml
config:
  prompt: "[My chat] <prefix><nickname><suffix> -> <m><reset>"
  cooldown: 1
blacklist:
  global: true

This is minimal template for chat. Let's analyze the template structure.

  • config — Root of basic chat. Included prompt and cooldown.
    • prompt — Text, that will be used for this chat when player send message.
    • cooldown — Time, for what player cannot to send message in this chat. If not defined - using default from config.yml
  • blacklist — Root of blacklist for tags (and not only) in chat
    • global — Logical value, that says to plugin "Hey. I using global blacklist and not using my own". If set to true - chat will use blacklist from config.yml. If set to false - chat will use their own blacklist

Now, we need to register it inside config.yml

yml
#... other sections ...
chats:
  my-chat:
    template: "example-chat.yml"
    prefix: ["#", "_", "--"]
    radius: -1

Now. Let’s put everything in its place.

  • chats — Root for every registered chat. If you remove it - plugin will broked.
  • my-chat — Name for your chat inside plugin. Players will not able to see it when they type in this chat.
  • template — Path to your template of chat.
  • prefix — Prefix for message, that players will need to type in this chat. Supports aliases
  • radius — Radius in blocks, players in this radius will see message. If radius is set to -1 — everyone on server will see it.

Now, reload plugin. IMAGE - 6 chatsin my case here 6 chats, not 4, because I already use .json experiment and using internal chats

And now, we can try to type inside our chat. IMAGE - my chat 1 But what if we need more style? Let's change example-chat.yml

yml
config:
  prompt: "<gray>[<red>My chat</red>]</gray> <prefix><gold><nickname></gold><suffix> <blue>-></blue> <m><reset>"
  cooldown: 1
blacklist:
  global: true

Now, prompt is "<gray>[<red>My chat</red>]</gray> <prefix><gold><nickname></gold><suffix> <blue>-></blue> <m><reset>". That means, about [] in start are gray, My chat inside them are red, player-nickname will be gold and -> will be blue. Let's try it. Reload plugin and after type a message IMAGE - my chat 2

You can change blacklist how you want. Here example.

yml
blacklist:
  global: false #if set to false, plugin will read blacklist from this place. Else, it will read from config.yml
  config:
    minimessage: false # Disables able for players for use minimessage. By default, set to false or Minimessage can be used.
    gradients: false # Disables able for players for use gradients. By default, disabled.
    tags: # Disables custom (and not only) tags.
      - newline
      - obf

JSON chat template

As a first step, we NEED to enable support for JSON for chats inside config.yml

yml
options:
  #...
  experiments:
    jsonForChats: true # <--- HERE. If here in your config false, change it to true.
    databasesForMute: false

# ... Other sections ...

Now, we can make new .json template.
At first, we need to know structure of .json chat template.

json
{
  "config": {
    "prompt": "[My chat] <prefix><nickname><suffix> -> <m><reset>",
    "cooldown": 1
  },
  "blacklist": {
    "global": true
  }
}

This is minimal template for chat. Let's analyze the template structure.

  • "config" — Root of basic chat. Included prompt and cooldown.
    • "prompt" — Text, that will be used for this chat when player send message.
    • "cooldown" — Time, for what player cannot to send message in this chat. If not defined - using default from config.yml
  • "blacklist" — Root of blacklist for tags (and not only) in chat
    • "global" — Logical value, that says to plugin "Hey. I using global blacklist and not using my own". If set to true - chat will use blacklist from config.yml. If set to false - chat will use their own blacklist

Now, we need to register it inside config.yml

yml
#... other sections ...
chats:
  my-chat:
    template: "example-chat.json"
    prefix: ["#", "_", "--"]
    radius: -1

Now. Let’s put everything in its place.

  • chats — Root for every registered chat. If you remove it - plugin will broked.
  • my-chat — Name for your chat inside plugin. Players will not able to see it when they type in this chat.
  • template — Path to your template of chat.
  • prefix — Prefix for message, that players will need to type in this chat. Supports aliases
  • radius — Radius in blocks, players in this radius will see message. If radius is set to -1 — everyone on server will see it.

Now, reload plugin. IMAGE - 6 chatsin my case here 6 chats, not 4, because I using internal chats

And now, we can try to type inside our chat. IMAGE - my chat 1 But what if we need more style? Let's change example-chat.json

json
{
  "config": {
    "prompt": "<gray>[<red>My chat</red>]</gray> <prefix><gold><nickname></gold><suffix> <blue>-></blue> <m><reset>",
    "cooldown": 1
  },
  "blacklist": {
    "global": true
  }
}

Now, prompt is "<gray>[<red>My chat</red>]</gray> <prefix><gold><nickname></gold><suffix> <blue>-></blue> <m><reset>". That means, about [] in start are gray, My chat inside them are red, player-nickname will be gold and -> will be blue. Let's try it. Reload plugin and after type a message IMAGE - my chat 2

You can change blacklist how you want. Here example.

json
  "blacklist": {
    "global": false,
    "config": {
      "minimessage": true,
      "gradients": false,
      "tags": [
        "newline", "obf", "b", "i"
      ]
    }
  }

Released under the MIT License. Made by LazyCato0o. Created with VitePress.