Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Formats

Matej Pacan edited this page Aug 5, 2020 · 21 revisions

ChatControl enables you to take full control on how the message looks like. The file formatting.yml enables you to make as many formats as you like, so you can use them anywhere in our plugin anyhow you desire.

Placeholder tips

We support PlaceholderAPI with the {player_name} syntax (not the %player_name%), a predefined set of our placeholders and custom JavaScript placeholders, please see a separate article.

TIP: Our predefined placeholders support the plus symbol: {pl_prefix+}, that will only add an extra space before the nick in case there is an actual prefix set. If there is no prefix, you will not end up with a doubled space.

Bear in mind, that using too many placeholders could affect performance as it would be more data that has to be loaded every time the user writes to chat.

Formats can be applied to all chat types (normal, ranged, bungee, ...), chat channels or even private messages and more. a

Introduction to Formats

The Formats section consists of two important elements.

1) Format names

The format name is totally up to you and you will call it from other places in ChatControl to use your format.

2) Format parts

Each format is built of parts. Which part represents a portion of the message that is formatted. Parts exist because you can assign different interactive elements for each one.

In each part, you can use all variables listed here.

Creating Our First Format

Let's take a look at the following example. It consists of two parts that are joined together when a chat message is sent. Read the image comments for a better understanding of how things work.

a

Now we need to make this format work. To do so, we set "Formatting.Default" to "Chat" in our file so ChatControl starts to use that format for our default chat. When you use Chat Channels, you need to give the format name in channels.yml file instead.

When we jump into the game, this is what happens when we type a message:

b

Since we also installed hover and click events on the first part of our format (the one showing player prefix and their name), they start functioning immediately when our mouse is moved onto that part. Also, upon clicking the part, a new suggested message is put into our chat console. That's how powerful ChatControl is.

c

Conditional Format

Some people prefer to use ChatControl instead of any prefix-management or permission plugin to print different chat messages for different ranks. Here's an example. Please also see the Parts Option section below for an explanation on the different keys.

To use this, place this in the Formats section in your formatting.yml and then refer to it from elsewhere by calling Ranked_Format name, such as in Formatting.Default key above in the same file.

  # This format is called "Ranked_Format" and will show different
  # parts before the player's prefix and name depending on what
  # permission the player (the sender) has.
  Ranked_Format:
    Rank_1:
      Message: "&c[Admin] "
      Sender_Permission: "my.rank.admin"
    Rank_2: 
      Message: "&9[Mod] "
      Sender_Permission: "my.rank.mod"
    Rank_3: 
      Message: "&6[Helper] "
      Sender_Permission: "my.rank.helper"
    The_Rest: 
      Message: "&7{pl_prefix+}{player}&7: &f{message}"

Part Options

You can write multiple options to each part enhance its functionality up to your requirements. Simply write the setting key and a value from the list below and effect will take place upon when you reload the plugin (/chc reload).

Message

Info: What message shall be printed out to the chat?

Accepts: String

Message: '{pl_prefix}{player}{pl_suffix}&7: {message}'

Sender_Permission

Info: Makes the entire part only show if the sender of the message has the specified permission.

Accepts: String

Sender_Permission: 'my.custom.permission'

Condition

Info: Makes the entire part only show if a specific Javascript condition is met. Variables, including those from PlaceholderAPI are supported. See here for more information.

Condition: '"{player}" == "kangarko"'

Hover_Event

Info: What happens when a mouse cursor goes over to this part?

Accepts: see below

Action

The action represents what can happen. Possible values: SHOW_TEXT, SHOW_ACHIEVEMENT, SHOW_ENTITY and SHOW_ITEM.

Values

Messages, per line, to display.

Hover_Event: 
  Action: SHOW_TEXT
  Values: 
    - "&6This player is VIP"
    - "&6Check out &e/web &6to obtain VIP"

Click_Event

Info: What happens when a mouse cursor clicks on this part?

Accepts: see below

Action

The action represents what can happen. Possible values: OPEN_URL, OPEN_FILE, RUN_COMMAND and SUGGEST_COMMAND.

Values

Messages, per line, to display.

Click_Event: 
  Action: SUGGEST_COMMAND
  Value: "/tell {player} "
Clone this wiki locally