You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/RoseChat/configuration-files.md
+88-83Lines changed: 88 additions & 83 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,60 +75,81 @@ The `shout` format is used with the `shout-commands` setting, and a message is s
75
75
The `broadcast` format is used when a message is sent the channel from `/broadcast`.<br/>
76
76
The `join-message` format is the message sent to a player when they join the channel.<br/>
77
77
78
-
## replacements.yml
79
-
The replacements file is used for replacing messages with other content. This can be used for fun, or to filter a message. For example, the default replacements file replaces `<3` with `❤️`. These are extremely configurable, and allow for things like emojis and tags.
78
+
## Filters
79
+
The filters folder allows organising multiple files with filters defined inside them.<br/>
80
+
Filters can edit or block messages, such as blocking swear words, censoring them, or adding emojis and colours.<br/>
81
+
The default file `colors.yml` defines tag-based colours like `<red>` to make text red, `fun.yml` defines some fun and useful features like emojis or `@Player` tags, and `swears.yml` shows how to block or censor a word.
80
82
81
-
A replacement must first start with an ID and has two sections, `input` which contains settings for inputting a replacement, and `output` which contains settings for the output of a replacement. These can be seen as what the player types and what the player sees.
83
+
A filter must first start with one or more `matches`, which tells the plugin what to search for in a message. They may optionally also contain a `replacement`, which tells the plugin what to replace the matched word with.
82
84
83
-
This basic replacement replaces the input of `:example:` to `\uE000`, which will be an emoji.<br>
85
+
This basic filter replaces the input of `:example:` to `\uE000`, which represents an emoji.<br/>
84
86
The `can-toggle` setting allows the /toggleemoji command to be used, this allows players to not format specific replacements, like not converting `<3` to `❤️`.<br>
85
87
These emojis can have icons when using a [Resource Pack](resource-packs.md).
86
88
```yaml
87
89
example:
88
-
input:
89
-
text: ':example:'
90
-
can-toggle: true
91
-
output:
92
-
text: "\uE000"
90
+
matches:
91
+
- ":example:"
92
+
can-toggle: true
93
+
replacement: "\uE000"
93
94
```
94
95
95
-
There are many configuration options for replacements.
96
+
There are many configuration options for filters.
96
97
```yaml
97
98
example:
98
-
input:
99
-
text: ':example:'
100
-
is-emoji: true
101
-
output:
102
-
text: "\uE000"
103
-
hover: '&b&o:rosewood:'
99
+
matches:
100
+
- ":example:"
101
+
can-toggle: true
102
+
hover: "&b&o:rosewood:"
103
+
replacement: "\uE000"
104
104
```
105
-
The `hover` option allows a replacement to be hovered over.<br>
105
+
The `hover` option allows a filter to be hovered over.<br>
106
106
You can also use a custom placeholder here.
107
107
```yaml
108
-
output:
109
-
text: "{your-placeholder}"
108
+
replacement: "{your-placeholder}"
109
+
```
110
+
111
+
There are two ways to use permissions in filters, a `use` permission and a `bypass` permission.
112
+
The player also needs `rosechat.filters.<location>` to send replacements in a specific location.<br>
113
+
These are formatted like so:
114
+
```yaml
115
+
replaceable-words:
116
+
matches:
117
+
- 'crap'
118
+
replacement: 'cr*p'
119
+
permission:
120
+
bypass: "rosechat.admin"
110
121
```
122
+
This `bypass` permission ensures the filter will **not** be applied for that player.
123
+
124
+
```yaml
125
+
star:
126
+
matches:
127
+
- ':star:'
128
+
replacement: "✸"
129
+
permission:
130
+
use: rosechat.filter.star
131
+
```
132
+
This `use` permission ensures that the player must have this permission to use the filter.<br/>
111
133
112
134
```yaml
113
135
rainbow:
114
-
input:
115
-
text: '&h'
116
-
output:
117
-
text: '<r:0.5>'
118
-
color-retention: true
136
+
matches:
137
+
- "&h"
138
+
replacement: "<r:0.5>"
139
+
color-retention: true
119
140
```
120
141
The `color-retention` option allows the color specified in the output text to continue along the message.
The `is-regex` option allows the `text` value to be seen as regex, and replacements will be matched against it.<br>
131
-
For replacements that use regex, there are placeholders for regex groups. These can be used in linked custom placeholders, or in the `text` option itself.<br>
151
+
The `use-regex` option allows the `text` value to be seen as regex, and replacements will be matched against it.<br>
152
+
For filters that use regex, there are placeholders for regex groups. These can be used in linked custom placeholders, or in the `text` option itself.<br>
132
153
```yaml
133
154
spoiler-tag:
134
155
text:
@@ -137,22 +158,20 @@ spoiler-tag:
137
158
default:
138
159
- "%input_1%"
139
160
```
140
-
This replacement uses `%input_1%` to get the text inside the spoiler tags. These can also be used in inline replacements.<br>
161
+
This filter uses `%input_1%` to get the text inside the spoiler tags. These can also be used in inline .<br>
141
162
The `input` placeholder allows grabbing a regex group while also checking a player's permission. Using `%group_1%` would return the first group and also parse the message without checking permissions, applying colours even if the player does not have permission to use colours in chat.
142
163
143
-
### Prefixed Replacements
164
+
### Prefixed Filters
144
165
145
166
```yaml
146
167
spoiler:
147
-
input:
148
-
prefix: '<spoiler>'
149
-
suffix: '</spoiler>'
150
-
output:
151
-
text: '{spoiler-tag}'
152
-
match-length: true
168
+
prefix: "<spoiler>"
169
+
suffix: "</spoiler>"
170
+
replacement: "{spoiler-tag}"
171
+
match-length: true
153
172
```
154
173
155
-
Replacements can also have `prefix` and `suffix`. This example will match this text: `<spoiler>Hello</spoiler>`and replace it with the custom placeholder `{spoiler-tag}`.<br>
174
+
Filters can also have a `prefix` and a `suffix`. This example will match this text: `<spoiler>Hello</spoiler>`and replace it with the custom placeholder `{spoiler-tag}`.<br>
156
175
The `match-length` option is useful as the `{spoiler-tag}` setting contains one character, `match-length` will repeat this character 5 times as `Hello` has 5 characters.<br>
157
176
`prefix`and `suffix` can also contain regex if `is-regex` is enabled.
158
177
@@ -166,25 +185,24 @@ player:
166
185
tag-online-players: true
167
186
sound: minecraft:block.note_block.pling
168
187
```
169
-
Replacements can also have only a `prefix` option. This example will look for words starting with `@` and replace them with the output text.<br>
188
+
Filters can also have only a `prefix` option. This example will look for words starting with `@` and replace them with the output text.<br>
170
189
The `stop` setting is a regex string, telling the plugin where to stop looking after it finds the prefix. This example searches for `@player` and stops when it finds punctuation or a space.<br>
171
190
The output option `tag-online-players` highlights the player's name, and sends them a sound, specified in the `sound` option.
This replacement converts `[Click Here](www.example.com)` to `Click Here`, with the link `www.example.com`. <br>
205
+
This filter converts `[Click Here](www.example.com)` to `Click Here`, with the link `www.example.com`. <br>
188
206
The `prefix` and `suffix` values define the prefix and suffix for the content, `Click Here`.<br>
189
207
The `inline-prefix` and `inline-suffix` values define the prefix and suffix for the inline, `www.example.com`<br>
190
208
These can be used without regex, and without the `text` value to allow players to create their own hoverable messages. For example, `[Hover Me!](Hello)`, when configured, will create a message saying "Hover Me", and the hover says "Hello".<br>
@@ -194,40 +212,27 @@ You can also use `is-content-regex` to match text between the `prefix` and `suff
194
212
195
213
The `discord-output` option, requiring DiscordSRV, allows the output to be different if sent to Discord.
196
214
```yaml
197
-
example:
198
-
input:
199
-
text: ':example:'
200
-
output:
201
-
text: "\uE000"
202
-
discord-output: ":smile:"
203
-
```
204
-
205
-
By default, the permission to use a replacement is `rosechat.replacement.<id>`. The player also needs `rosechat.replacements.<location>` to send replacements in a specific location.<br>
206
-
This can be changed using the `permission` option:
207
-
```yaml
208
-
example:
209
-
input:
210
-
text: ':example:'
211
-
permission: 'your.permission'
212
-
output:
213
-
text: "\uE000"
215
+
discord-output: ":smile:"
214
216
```
215
217
216
-
## colors.yml
217
-
The colors file serves as an extra space to add replacements that are specifically custom colors. These have `color-retention` enabled by default.
218
-
By default, this file allows players used to MiniMessage formats to use colors in RoseChat.
219
-
220
-
This is an example of a basic color.
218
+
### Swear Filters
219
+
You may want to stop players from sending messages with bad words in them.
220
+
The `block` option stops a message from being sent.
221
221
```yaml
222
-
red:
223
-
input:
224
-
text: "<red>"
225
-
has-closing-tag: true
226
-
output:
227
-
text: "&c"
222
+
bannable-words:
223
+
matches:
224
+
- damn
225
+
sensitivity: 20
226
+
block: true
227
+
commands:
228
+
server:
229
+
- warn %player% Swearing
228
230
```
229
-
230
-
The format is the same as a replacement, the player can type `<red>` and it is replaced by the `&c` color code. The `has-closing-tag` option allows the plugin to automatically create a closing tag version of the replacement. This means that the above color will also be available by typing `<red>your text</red>`, allowing for non-colored text the be placed outside of the tags.
231
+
The default `bannable-words` filter in `swears.yml` blocks the message being sent if it finds "damn", it then also runs a command on the server to warn the player.<br>
232
+
The `sensitivity` option provides an easy way to filter similar words without having to type them all. This filter will catch `damn`, `dámn` and other variations.
233
+
A filter with a sensitivity that is too high may catch incorrect words, like `dam`, in this instance, the sensitivity can be lowered or removed entirely.
234
+
There may be some instances where creating a second filter with a different sensitivity value may be more useful than editing the sensitivity of one.<br>
235
+
These options may also be used in other filters.
231
236
232
237
## custom-placeholders.yml
233
238
The placeholders file is used to define placeholders that RoseChat uses. This is probably the most useful file.
This method allows using a [MessageLocation](https://github.com/Rosewood-Development/RoseChat/blob/master/src/main/java/dev/rosewood/rosechat/message/MessageLocation.java) to check for permissions.
18
+
This method allows using a [PermissionArea](https://github.com/Rosewood-Development/RoseChat/blob/master/src/main/java/dev/rosewood/rosechat/message/PermissionArea.java) to check for permissions.
The [MessageContents](https://github.com/Rosewood-Development/RoseChat/blob/master/src/main/java/dev/rosewood/rosechat/message/contents/MessageContents.java) class provides an abstracted way to handle the output of a message, abstracted from whichever platform you are using.
24
+
22
25
23
26
#### RosePlayer
24
27
The [RosePlayer](https://github.com/Rosewood-Development/RoseChat/blob/master/src/main/java/dev/rosewood/rosechat/message/RosePlayer.java) object is used by RoseChat to give more information to a Player object. When you need to use a RosePlayer, you can just create a `new RosePlayer()`. This object has a few different constructors, but passing a Player object through is the most common.
@@ -31,8 +34,9 @@ public void onPlayerJoin(PlayerJoinEvent event) {
@@ -45,27 +49,26 @@ Creating a new `RoseMessage` object for each player allows each player to receiv
45
49
#### Rose Messages
46
50
The preferred way to send a message to multiple players is by using `RoseMessage.forChannel(RosePlayer, Channel)` or `RoseMessage.forLocation(RosePlayer, MessageLocation).<br>
47
51
48
-
An example of this is used in the RoseChatChannel class:
This creates a new `MessageRules` object, which defines the rules of the message, and if a message should be filtered based on the permissions of the sender. It also applies the sender's chat colour.<br>
@@ -80,34 +83,34 @@ A format is not needed, and `null` can be passed.<br>
80
83
There are several `parse` functions in the `RoseMessage` class.<br>
81
84
The first simply parses the message as it should be seen in-game.
The second treats the message as if it was sent from Discord, converting Discord formatting to Minecraft. A discord id can be passed to allow messages to be deleted in Discord.
87
90
```java
88
-
BaseComponent[] parseMessageFromDiscord(RosePlayer viewer, String format, String discordId)
91
+
MessageContents parseMessageFromDiscord(RosePlayer viewer, String format, String discordId)
89
92
```
90
93
91
94
The third treats the message as if it was sent to Discord, converting Minecraft formatting to Discord.
The final method allows a MessageParser to be specified, and a discord id too, if needed..
104
+
The final method allows a MessageParser to be specified, and a discord id too, if needed.
102
105
```java
103
-
BaseComponent[] parse(MessageParser parser, RosePlayer viewer, String format, String discordId)
106
+
MessageContents parse(MessageParser parser, RosePlayer viewer, String format, String discordId)
104
107
```
105
108
106
109
Now that the message is parsed, functions such as `getTaggedPlayers()` becomes available to use from the MessageOuputs class.
107
110
108
111
### Message Parsers
109
112
A message parser is a way of deciding what to do with a message when it is parsed.<br>
110
-
Typically, this consists of combining multiple [tokenizers]() to create a final message.<br>
113
+
Typically, this consists of combining multiple [tokenizers](tokens-%26-tokenizers.md) to create a final message.<br>
111
114
An example of a MessageParser can be seen [here](https://github.com/Rosewood-Development/RoseChat/blob/master/src/main/java/dev/rosewood/rosechat/message/parser/RoseChatParser.java).<br>
112
115
This MessageParser mainly decides what tokenizers to use for the message.<br>
113
116
A MessageParser is simply called when the message is parsed, so anything can be done to the message.
0 commit comments