-
-
Notifications
You must be signed in to change notification settings - Fork 923
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* titles event * only 1 event * remove chatmsg * add docs and example * LINT
- Loading branch information
Showing
8 changed files
with
58 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* An example of how to handle title events from the server. | ||
*/ | ||
const mineflayer = require('mineflayer') | ||
|
||
if (process.argv.length < 4 || process.argv.length > 6) { | ||
console.log('Usage : node titles.js <host> <port> [<name>] [<password>]') | ||
process.exit(1) | ||
} | ||
|
||
const bot = mineflayer.createBot({ | ||
host: process.argv[2], | ||
port: parseInt(process.argv[3]), | ||
username: process.argv[4] ? process.argv[4] : 'titles', | ||
password: process.argv[5] | ||
}) | ||
|
||
// This event is triggered when the server sends a title to the client. | ||
bot.on('title', (text, type) => { | ||
// type is either "title" or "subtitle" | ||
console.log(`Received ${type}: ${text}`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
module.exports = inject | ||
|
||
function inject (bot) { | ||
bot._client.on('title', (packet) => { | ||
if (packet.action === 0 || packet.action === 1) { | ||
bot.emit('title', packet.text) | ||
bot.emit('title', packet.text, 'title') | ||
} | ||
}) | ||
bot._client.on('set_title_text', packet => { | ||
bot.emit('title', packet.text, 'title') | ||
}) | ||
bot._client.on('set_title_subtitle', packet => { | ||
bot.emit('title', packet.text, 'subtitle') | ||
}) | ||
} |