Skip to content

Commit 8f3b6c5

Browse files
authored
Update API.md (#448)
1 parent 4c7bb65 commit 8f3b6c5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/API.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,22 @@ relay.on('connect', player => {
206206
console.log('New connection', player.connection.address)
207207

208208
// Server is sending a message to the client.
209-
player.on('clientbound', ({ name, params }) => {
209+
player.on('clientbound', ({ name, params }, des) => {
210210
if (name === 'disconnect') { // Intercept kick
211211
params.message = 'Intercepted' // Change kick message to "Intercepted"
212212
}
213213
})
214214
// Client is sending a message to the server
215-
player.on('serverbound', ({ name, params }) => {
215+
player.on('serverbound', ({ name, params }, des) => {
216216
if (name === 'text') { // Intercept chat message to server and append time.
217217
params.message += `, on ${new Date().toLocaleString()}`
218218
}
219+
220+
if (name === 'command_request') { // Intercept command request to server and cancel if its "/test"
221+
if (params.command == "/test") {
222+
des.canceled = true
223+
}
224+
}
219225
})
220226
})
221227
```

0 commit comments

Comments
 (0)