# Chat system

# Config file

KingdomCraft has support for multiple chat channels. You can add, delete or change channels. Je kan deze in the **chat.yml** config file.

```yaml
enabled: true

default-channel: 'public'

channels:
  kingdom:
    format: '&6[K]&a{prefix}{rank_prefix}&a{username}&a: &f{message}'
    prefix: ''
    clone-per-kingdom: true

  public:
    format: '&8[P]&7{prefix}{kingdom_prefix}{rank_prefix} &7{username} &8\u00BB &7{message}'
    prefix: '!'
    toggleable: false
    range: 20
    cooldown: 5

  hkm:
    format: '&6[HKM]&a{prefix}{kingdom_prefix}{rank_prefix}&a{username}&a: &f{message}'
    prefix: '@'
    restrict: 'read'
    toggleable: true
```


# Root options

## Enabled

```yaml
enabled: true
```

You can disable the use of multiple chat channels with this option. It is recommend that you install another chat plugin so you can still configure the chat format.

## Default channel

```yaml
default-channel: 'public'
```

This changes the default channel for players without a kingdom. They don’t need to prefix their message with an activator symbol to talk in this channel.

# Channel options

## Format

```yaml
format: '&6[K]&a{prefix}{rank_prefix}&a{username}&a: &f{message}'
```

In the above example `{prefix}` and `{message}` are examples of **placeholders**. A placeholder will be replaced with other text in the game depending on the player. [Here](https://wiki.guflimc.com/doc/chat-system-BI5h4CO5nK#h-placeholders) is a list of all placeholders provided by KingdomCraft.

You can also use legacy color codes like **&7** (gray) or **&b** (bold). You can find a list of these [here](https://www.reddit.com/r/Minecraft/comments/8rxug9/colour_codes_for_minecraft/). Alternatively you can also use full RGB colors in the format of `<#rrggbb>`.

## Prefix

```yaml
prefix: '@'
```

This is the activator **symbol** that you have to put in front of your message to talk in this channel. You can also put multiple characters here.

E.g. to send the message `hello there` in the public channel you have to send `!hello there` otherwise it will be sent to the kingdom channel.


## Clone-per-kingdom

```yaml
clone-per-kingdom: true
```

This will create a different chat channel for each kingdom which only their members can access. All these channels will have the same configuration. 

## Kingdoms

```yaml
kingdoms:
- Eltria
- Altiri
- Empirion
```

With this option you can restrict which kingdoms have access to this channel. This can be useful if you have fixed alliances which require their own chat channel. You can also enter just a single kingdom.

## Toggleable

```yaml
toggleable: false
```

You can enable or disable if this channel can be toggled through the command `/k chatchannel <channel>`.

## Restrict

```yaml
restrict: 'read'
```

With this option you can restrict a channel so only players with the permission `kingdom.chat.channel.CHANNELNAME` can access this channel. You can set this option to:

* `read`: You need the permission to read and talk in this channel.
* `talk`: You need the permission to talk in this channel. Everyone can read. (e.g. an announcement channel)

## Range

```yaml
range: 20
```

With this option you can only see the messages of players that are within this distance of blocks.

## Cooldown

```yaml
cooldown: 5
```

You can set a cooldown on this channel in seconds. You only sent another message if this time has passed since your last message.

You can bypess this restriction with the following permission: `kingdom.chat.bypass.cooldown`

# Commands

## Join a channel

Join a channel

| /k chatchannel join <channel> | kingdom.chatchannel.join |
|-------------------------------|--------------------------|

## Leave a channel

Leave a channel

| /k chatchannel leave <channel> | kingdom.chatchannel.leave |
|--------------------------------|---------------------------|

## Chat

With this command you can directly specify a channel to send the given message in. For example, moderators can use this command to sent a message to channels of another kingdom.

| /k chat <channel> <message> | kingdom.chat |
|-----------------------------|--------------|
| /k chat <channel> <message> | kingdom.chat.other |

## Default channel

By default you will always talk in the channel with an empty **activator prefix**. If you want to talk by default in a channel that requires an activator prefix you can use this command.

For example, by default you don’t need a prefix for the channel *public* and you need the prefix `!` to talk in the channel *kingdom*. If you use this command like `/k dc kingdom` then no longer need a prefix to talk in the channel *kingdom* and you can talk in the channel *public* with the prefix `!`.

| /k dc <channel><br>/k defaultchannel <channel> |
|---------------------------------------------|

## Disable channel

You can disable a channel for the whole server. Nobody will be able to talk in this channel anymore.

| /k chatchannel disable <channel> | kingdom.chatchannel.disable |
|----------------------------------|-----------------------------|

## Enable channel

You can enable a channel after it was disabled.

| /k chatchannel enable <channel> | kingdom.chatchannel.enable |
|---------------------------------|----------------------------|

# Placeholders

The following placeholders can be used in the chat format. If you have premium you can use even more placeholders and also use these placeholders in other plugins ([More info](https://wiki.guflimc.com/doc/placeholders-9gQgGoKMAB)).

These placeholders are always in relation to the player that sends the message and their kingdom or rank.

| Placeholder | Description |
|-------------|-------------|
| username    | Name of the player. |
| kingdom     | The **display** (displayname) of the player’s kingdom. |
| kingdom_name | The **name** of the player’s kingdom. |
| kingdom_prefix | The **prefix** of the player’s kingdom. |
| kingdom_suffix | The **suffix** of the player’s kingdom. |
| rank        | The **display** (displayname) of the player’s rank. |
| rank_name   | The **naam** of the player’s rank. |
| rank_prefix | The **prefix** of the player’s rank. |
| rank_suffix | The **suffix** fo the player’s rank. |

# DiscordSRV

The chat system of KingdomCraft supports [DiscordSRV](https://www.spigotmc.org/resources/discordsrv.18494/). However, you still need to setup a few things.

Config snippet of DiscordSRV:

```javascript
Channels:
  public: 0123456789
  roleplay: 9876543210
  kingdom-eltria: 6969696969
```


On the left is the KingomCraft channel name, on the right is the Discord channel id. e.g. `public: 0123456789`. 

All messages sent in minecraft to this channel will be sent to the corresponding discord channel, and all messages sent to the discord channel will also be sent to the kingdomcraft channel in-game.


NB. The setting `clone-per-kingdom: true` on channels means that each kingdom gets their own channel. Internally this channel will have the following name: `<channelnaam>-<kingdomnaam>`. If you want to link this channel to a Discord channel you need to use this name. (e.g. `roleplay-eltria` is the `roleplay` channel specifically for the kingdom `eltria`).

---

**Documents**

- [Getting started](https://wiki.guflimc.com/s/kingdomcraft/doc/getting-started-D6nO7R93ys)
- [Configuration](https://wiki.guflimc.com/s/kingdomcraft/doc/configuration-DMcGaWt85O)
- [Kingdom setup](https://wiki.guflimc.com/s/kingdomcraft/doc/kingdom-setup-ZDcgXrOKXu)
- [Ranks setup](https://wiki.guflimc.com/s/kingdomcraft/doc/ranks-setup-8ZxHwOcwuN)
- [Players guide](https://wiki.guflimc.com/s/kingdomcraft/doc/players-guide-52cG3r3F9w)
- [Chat system](https://wiki.guflimc.com/s/kingdomcraft/doc/chat-system-BI5h4CO5nK)
- [Relations](https://wiki.guflimc.com/s/kingdomcraft/doc/relations-DWqWWHEum8)
- [Admin mode](https://wiki.guflimc.com/s/kingdomcraft/doc/admin-mode-XiPDZwgCU9)
- [Translations](https://wiki.guflimc.com/s/kingdomcraft/doc/translations-P1RH2hwYjp)
- [Rank permissions](https://wiki.guflimc.com/s/kingdomcraft/doc/rank-permissions-pJn6oSjLYI)
- [All permissions](https://wiki.guflimc.com/s/kingdomcraft/doc/all-permissions-abZLW9OAkb)
- [Database](https://wiki.guflimc.com/s/kingdomcraft/doc/database-XlNdVs86Jz)