From d634c477634b26bc92fa7b16dca291fc120f7e8f Mon Sep 17 00:00:00 2001 From: fulcanelly Date: Thu, 14 Jan 2021 18:49:39 +0200 Subject: [PATCH] added test blueprints --- test/main.js | 20 ++++++++++++++++++++ test/package.json | 15 +++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 test/main.js create mode 100644 test/package.json diff --git a/test/main.js b/test/main.js new file mode 100644 index 00000000..f4e7e057 --- /dev/null +++ b/test/main.js @@ -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}); + } +}); diff --git a/test/package.json b/test/package.json new file mode 100644 index 00000000..a7bd9920 --- /dev/null +++ b/test/package.json @@ -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" + } +}