Skip to content

Commit

Permalink
Update API.md (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
Laamy committed Sep 18, 2023
1 parent 4c7bb65 commit 8f3b6c5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,22 @@ relay.on('connect', player => {
console.log('New connection', player.connection.address)

// Server is sending a message to the client.
player.on('clientbound', ({ name, params }) => {
player.on('clientbound', ({ name, params }, des) => {
if (name === 'disconnect') { // Intercept kick
params.message = 'Intercepted' // Change kick message to "Intercepted"
}
})
// Client is sending a message to the server
player.on('serverbound', ({ name, params }) => {
player.on('serverbound', ({ name, params }, des) => {
if (name === 'text') { // Intercept chat message to server and append time.
params.message += `, on ${new Date().toLocaleString()}`
}

if (name === 'command_request') { // Intercept command request to server and cancel if its "/test"
if (params.command == "/test") {
des.canceled = true
}
}
})
})
```
Expand Down

0 comments on commit 8f3b6c5

Please sign in to comment.