Skip to content

Commit

Permalink
added test blueprints
Browse files Browse the repository at this point in the history
  • Loading branch information
fulcanelly committed Jan 14, 2021
1 parent 93978e7 commit d634c47
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var mc = require('minecraft-protocol');
var client = mc.createClient({
host: "localhost", // optional
// port: 25565, // optional
username: "frr",
// password: "12345678",
// auth: 'mojang' // optional; by default uses mojang, if using a microsoft account, set to 'microsoft'
});


client.on('chat', function(packet) {
// Listen for chat messages and echo them back.
var jsonMsg = JSON.parse(packet.message);
if(jsonMsg.translate == 'chat.type.announcement' || jsonMsg.translate == 'chat.type.text') {
var username = jsonMsg.with[0].text;
var msg = jsonMsg.with[1];
if(username === client.username) return;
client.write('chat', {message: msg.text});
}
});
15 changes: 15 additions & 0 deletions test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"minecraft-protocol": "^1.21.0"
}
}

0 comments on commit d634c47

Please sign in to comment.