Merge branch 'master' into lluiscab/fix-client_echo

This commit is contained in:
Romain Beaumont 2018-09-24 22:09:46 +02:00 committed by GitHub
commit 26267ab043
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 232 additions and 92 deletions

View file

@ -27,6 +27,6 @@ client.on('chat', function (packet) {
const username = jsonMsg.with[0].text
const msg = jsonMsg.with[1]
if (username === client.username) return
client.write('chat', {message: msg})
client.write('chat', { message: msg })
}
})

View file

@ -111,7 +111,7 @@ client.on('error', function (err) {
client.on('state', function (newState) {
if (newState === states.PLAY) {
chats.forEach(function (chat) {
client.write('chat', {message: chat})
client.write('chat', { message: chat })
})
}
})
@ -127,7 +127,7 @@ rl.on('line', function (line) {
console.info('Forcibly ended client')
process.exit(0)
}
if (!client.write('chat', {message: line})) {
if (!client.write('chat', { message: line })) {
chats.push(line)
}
})

View file

@ -27,7 +27,7 @@ client.on('chat', function (packet) {
const username = jsonMsg.with[0].text
const msg = jsonMsg.with[1]
if (username === client.username) return
if (msg.text) client.write('chat', {message: msg.text})
else client.write('chat', {message: msg})
if (msg.text) client.write('chat', { message: msg.text})
else client.write('chat', { message: msg})
}
})

View file

@ -43,6 +43,6 @@ client.on('chat', function (packet) {
const username = jsonMsg.with[0].text
const msg = jsonMsg.with[1]
if (username === client.username) return
client.write('chat', {message: msg})
client.write('chat', { message: msg })
}
})

View file

@ -50,6 +50,6 @@ client.on('chat', function (packet) {
const username = jsonMsg.with[0].text
const msg = jsonMsg.with[1]
if (username === client.username) return
client.write('chat', {message: msg})
client.write('chat', { message: msg })
}
})

View file

@ -127,7 +127,7 @@ srv.on('login', function (client) {
targetClient.on('raw', function (buffer, meta) {
if (client.state !== states.PLAY || meta.state !== states.PLAY) { return }
const packetData = targetClient.deserializer.parsePacketBuffer(buffer).data.params
const packetBuff = client.serializer.createPacketBuffer({name: meta.name, params: packetData})
const packetBuff = client.serializer.createPacketBuffer({ name: meta.name, params: packetData })
if (!bufferEqual(buffer, packetBuff)) {
console.log('client<-server: Error in packet ' + meta.state + '.' + meta.name)
console.log('received buffer', buffer.toString('hex'))
@ -146,7 +146,7 @@ srv.on('login', function (client) {
client.on('raw', function (buffer, meta) {
if (meta.state !== states.PLAY || targetClient.state !== states.PLAY) { return }
const packetData = client.deserializer.parsePacketBuffer(buffer).data.params
const packetBuff = targetClient.serializer.createPacketBuffer({name: meta.name, params: packetData})
const packetBuff = targetClient.serializer.createPacketBuffer({ name: meta.name, params: packetData })
if (!bufferEqual(buffer, packetBuff)) {
console.log('client->server: Error in packet ' + meta.state + '.' + meta.name)
console.log('received buffer', buffer.toString('hex'))

View file

@ -45,7 +45,7 @@ server.on('login', function (client) {
'Hello, world!'
]
}
client.write('chat', {message: JSON.stringify(msg), position: 0})
client.write('chat', { message: JSON.stringify(msg), position: 0 })
})
server.on('error', function (error) {

View file

@ -3,6 +3,7 @@
"version": "1.8.0",
"description": "Parse and serialize minecraft packets, plus authentication and encryption.",
"main": "src/index.js",
"types": "src/index.d.ts",
"repository": {
"type": "git",
"url": "git://github.com/PrismarineJS/node-minecraft-protocol.git"
@ -30,17 +31,18 @@
},
"browser": "src/browser.js",
"devDependencies": {
"@types/node": "^10.5.8",
"espower-loader": "^1.0.0",
"intelli-espower-loader": "^1.0.0",
"minecraft-wrap": "^1.2.0",
"mocha": "^5.0.5",
"power-assert": "^1.0.0",
"require-self": "^0.2.1",
"standard": "^11.0.1"
"standard": "^12.0.0"
},
"dependencies": {
"buffer-equal": "^1.0.0",
"debug": "^3.0.0",
"debug": "^4.0.0",
"endian-toggle": "^0.0.0",
"lodash.get": "^4.1.2",
"lodash.merge": "^4.3.0",

View file

@ -35,13 +35,13 @@ class Client extends EventEmitter {
}
setSerializer (state) {
this.serializer = createSerializer({isServer: this.isServer, version: this.version, state: state, customPackets: this.customPackets})
this.deserializer = createDeserializer({isServer: this.isServer,
this.serializer = createSerializer({ isServer: this.isServer, version: this.version, state: state, customPackets: this.customPackets })
this.deserializer = createDeserializer({ isServer: this.isServer,
version: this.version,
state: state,
packetsToParse:
this.packetsToParse,
customPackets: this.customPackets})
customPackets: this.customPackets })
this.splitter.recognizeLegacyPing = state === states.HANDSHAKING
@ -208,7 +208,7 @@ class Client extends EventEmitter {
// TCP/IP-specific (not generic Stream) method for backwards-compatibility
connect (port, host) {
const options = {port, host}
const options = { port, host }
if (!this.options) this.options = options
require('./client/tcp_dns')(this, options)
options.connect(this)

View file

@ -42,8 +42,8 @@ module.exports = function (client, options) {
function sendEncryptionKeyResponse () {
const pubKey = mcPubKeyToPem(packet.publicKey)
const encryptedSharedSecretBuffer = crypto.publicEncrypt({key: pubKey, padding: crypto.constants.RSA_PKCS1_PADDING}, sharedSecret)
const encryptedVerifyTokenBuffer = crypto.publicEncrypt({key: pubKey, padding: crypto.constants.RSA_PKCS1_PADDING}, packet.verifyToken)
const encryptedSharedSecretBuffer = crypto.publicEncrypt({ key: pubKey, padding: crypto.constants.RSA_PKCS1_PADDING }, sharedSecret)
const encryptedVerifyTokenBuffer = crypto.publicEncrypt({ key: pubKey, padding: crypto.constants.RSA_PKCS1_PADDING }, packet.verifyToken)
client.write('encryption_begin', {
sharedSecret: encryptedSharedSecretBuffer,
verifyToken: encryptedVerifyTokenBuffer

View file

@ -36,7 +36,7 @@ function createServer (options = {}) {
server.playerCount = 0
server.onlineModeExceptions = {}
server.favicon = favicon
server.serverKey = new NodeRSA({b: 1024})
server.serverKey = new NodeRSA({ b: 1024 })
server.on('connection', function (client) {
plugins.forEach(plugin => plugin(client, server, options))

View file

@ -42,7 +42,7 @@ function sizeOfNbt (value) {
function readOptionalNbt (buffer, offset) {
if (offset + 1 > buffer.length) { throw new PartialReadError() }
if (buffer.readInt8(offset) === 0) return {size: 1}
if (buffer.readInt8(offset) === 0) return { size: 1 }
return nbt.proto.read(buffer, offset, 'nbt')
}
@ -63,7 +63,7 @@ function sizeOfOptionalNbt (value) {
function readCompressedNbt (buffer, offset) {
if (offset + 2 > buffer.length) { throw new PartialReadError() }
const length = buffer.readInt16BE(offset)
if (length === -1) return {size: 2}
if (length === -1) return { size: 2 }
if (offset + 2 + length > buffer.length) { throw new PartialReadError() }
const compressedNbt = buffer.slice(offset + 2, offset + 2 + length)
@ -120,7 +120,7 @@ function sizeOfRestBuffer (value) {
return value.length
}
function readEntityMetadata (buffer, offset, {type, endVal}) {
function readEntityMetadata (buffer, offset, { type, endVal }) {
let cursor = offset
const metadata = []
let item
@ -139,7 +139,7 @@ function readEntityMetadata (buffer, offset, {type, endVal}) {
}
}
function writeEntityMetadata (value, buffer, offset, {type, endVal}) {
function writeEntityMetadata (value, buffer, offset, { type, endVal }) {
const self = this
value.forEach(function (item) {
offset = self.write(item, buffer, offset, type, {})
@ -148,7 +148,7 @@ function writeEntityMetadata (value, buffer, offset, {type, endVal}) {
return offset + 1
}
function sizeOfEntityMetadata (value, {type}) {
function sizeOfEntityMetadata (value, { type }) {
let size = 1
for (let i = 0; i < value.length; ++i) {
size += this.sizeOf(value[i], type, {})

138
src/index.d.ts vendored Normal file
View file

@ -0,0 +1,138 @@
import {Socket} from 'net'
import * as Stream from 'stream'
import EventEmitter = NodeJS.EventEmitter
declare enum EnumStates {
HANDSHAKING = 'handshaking',
STATUS = 'status',
LOGIN = 'login',
PLAY = 'play',
}
export interface IPacketMeta {
name: string
state: EnumStates
}
export declare class Client extends EventEmitter {
constructor(isServer: boolean, version: string, customPackets?: any)
write(name: string, params: any)
end(reason: string)
state: EnumStates
isServer: boolean
socket: Socket
uuid: string
username: string
session: any
profile: any
latency: number
on(event: 'packet', handler: (data: any, packetMeta: IPacketMeta) => any)
on(event: 'raw', handler: (data: any, packetMeta: IPacketMeta) => any)
on(event: 'state', handler: (newState: EnumStates, oldState: EnumStates) => any)
on(event: 'session', handler: (session: any) => any)
writeChannel(channel: any, params: any)
registerChannel(name: string, typeDefinition: any, custom?: boolean)
unregisterChannel(name: string)
}
interface IClientsMap {
[key: string]: Client
}
export declare class Server extends EventEmitter {
constructor(version: string, customPackets?: any)
onlineModeExceptions: object
clients: IClientsMap
playerCount: number
maxPlayers: number
motd: string
favicon: string
on(event: 'connection', handler: (client: Client) => any)
on(event: 'login', handler: (client: Client) => any)
}
export interface ICreateServerOptions {
host?: string
port?: number
kickTimeout?: number
checkTimeoutInterval?: number
'online-mode'?: boolean
motd?: string
maxPlayers?: number
keepAlive?: boolean
version?: string
customPackets?: any
stream?: Stream
beforePing?: (response: any, client: Client, callback?: (result: any) => any) => any
errorHandler?: (client: Client, error: Error) => any
connect?: (client: Client) => any
hideErrors?: boolean
}
export interface ICreateClientOptions {
username: string
port?: number
password?: string
host?: string
clientToken?: string
accessToken?: string
keepAlive?: boolean
checkTimeoutInterval?: number
version?: string
customPackets?: any
hideErrors?: boolean
}
export interface ICreateSerializerOptions {
state?: EnumStates
isServer?: boolean
version: string
customPackets: any
}
export interface IPingOptions {
host?: string
port?: number
version?: string
majorVersion?: string
protocolVersion?: string
}
export interface IPingOldResult {
prefix: string
protocol: string
version: string
motd: string
playerCount: number
maxPlayers: number,
}
export interface IPingNewResult {
description: string
players: {
max: number
online: number
sample: {
id: string
name: string
}[]
}
version: {
name: string
protocol: string
}
favicon: string
latency: number
}
export declare function createServer(options: ICreateServerOptions): Server
export declare function createClient(options: ICreateClientOptions): Client
export const state: EnumStates
export declare function createSerializer({state, isServer, version, customPackets}: ICreateSerializerOptions)
export declare function createDeserializer({state, isServer, version, customPackets}: ICreateSerializerOptions)
export declare function ping(options: IPingOptions, callback: (err: Error, result: IPingOldResult | IPingNewResult) => any);
export const supportedVersions: string[]

View file

@ -28,7 +28,7 @@ function ping (options, cb) {
cb(null, data)
client.end()
})
client.write('ping', {time: [0, 0]})
client.write('ping', { time: [0, 0] })
})
client.on('state', function (newState) {

View file

@ -27,9 +27,9 @@ class Server extends EventEmitter {
client.end = function end (endReason) {
endReason = '{"text":"' + endReason + '"}'
if (client.state === states.PLAY) {
client.write('kick_disconnect', {reason: endReason})
client.write('kick_disconnect', { reason: endReason })
} else if (client.state === states.LOGIN) {
client.write('disconnect', {reason: endReason})
client.write('disconnect', { reason: endReason })
}
client._end(endReason)
}

View file

@ -1,6 +1,6 @@
const states = require('../states')
module.exports = function (client, server, {version}) {
module.exports = function (client, server, { version }) {
client.once('set_protocol', onHandshake)
function onHandshake (packet) {

View file

@ -56,12 +56,12 @@ module.exports = function (client, server, options) {
function onEncryptionKeyResponse (packet) {
let sharedSecret
try {
const verifyToken = crypto.privateDecrypt({key: server.serverKey.exportKey(), padding: crypto.constants.RSA_PKCS1_PADDING}, packet.verifyToken)
const verifyToken = crypto.privateDecrypt({ key: server.serverKey.exportKey(), padding: crypto.constants.RSA_PKCS1_PADDING }, packet.verifyToken)
if (!bufferEqual(client.verifyToken, verifyToken)) {
client.end('DidNotEncryptVerifyTokenProperly')
return
}
sharedSecret = crypto.privateDecrypt({key: server.serverKey.exportKey(), padding: crypto.constants.RSA_PKCS1_PADDING}, packet.sharedSecret)
sharedSecret = crypto.privateDecrypt({ key: server.serverKey.exportKey(), padding: crypto.constants.RSA_PKCS1_PADDING }, packet.sharedSecret)
} catch (e) {
client.end('DidNotEncryptVerifyTokenProperly')
return
@ -111,7 +111,7 @@ module.exports = function (client, server, options) {
client.write('compress', { threshold: 256 }) // Default threshold is 256
client.compressionThreshold = 256
}
client.write('success', {uuid: client.uuid, username: client.username})
client.write('success', { uuid: client.uuid, username: client.username })
client.state = states.PLAY
clearTimeout(loginKickTimer)

View file

@ -1,6 +1,6 @@
const endianToggle = require('endian-toggle')
module.exports = function (client, server, {beforePing = null}) {
module.exports = function (client, server, { beforePing = null }) {
client.once('ping_start', onPing)
client.once('legacy_server_list_ping', onLegacyPing)
@ -15,13 +15,13 @@ module.exports = function (client, server, {beforePing = null}) {
'online': server.playerCount,
'sample': []
},
'description': {'text': server.motd},
'description': { 'text': server.motd },
'favicon': server.favicon
}
function answerToPing (err, response) {
if (err) return
client.write('server_info', {response: JSON.stringify(response)})
client.write('server_info', { response: JSON.stringify(response) })
}
if (beforePing) {
@ -35,7 +35,7 @@ module.exports = function (client, server, {beforePing = null}) {
}
client.once('ping', function (packet) {
client.write('ping', {time: packet.time})
client.write('ping', { time: packet.time })
client.end()
})
}

View file

@ -48,7 +48,7 @@ class Splitter extends Transform {
let value, size
let stop = false
try {
({value, size} = readVarInt(this.buffer, offset))
({ value, size } = readVarInt(this.buffer, offset))
} catch (e) {
if (!(e.partialReadError)) {
throw e
@ -59,7 +59,7 @@ class Splitter extends Transform {
try {
this.push(this.buffer.slice(offset + size, offset + size + value))
offset += size + value;
({value, size} = readVarInt(this.buffer, offset))
({ value, size } = readVarInt(this.buffer, offset))
} catch (e) {
if (e.partialReadError) {
break

View file

@ -22,11 +22,11 @@ function createProtocol (state, direction, version, customPackets) {
return proto
}
function createSerializer ({state = states.HANDSHAKING, isServer = false, version, customPackets} = {}) {
function createSerializer ({ state = states.HANDSHAKING, isServer = false, version, customPackets } = {}) {
return new Serializer(createProtocol(state, !isServer ? 'toServer' : 'toClient', version, customPackets), 'packet')
}
function createDeserializer ({state = states.HANDSHAKING, isServer = false, version, customPackets} = {}) {
function createDeserializer ({ state = states.HANDSHAKING, isServer = false, version, customPackets } = {}) {
return new Parser(createProtocol(state, isServer ? 'toServer' : 'toClient', version, customPackets), 'packet')
}

View file

@ -6,14 +6,14 @@ const mc = require('../')
const states = mc.states
const testDataWrite = [
{name: 'keep_alive', params: {keepAliveId: 957759560}},
{name: 'chat', params: {message: '<Bob> Hello World!'}},
{name: 'position_look', params: {x: 6.5, y: 65.62, stance: 67.24, z: 7.5, yaw: 0, pitch: 0, onGround: true}}
{ name: 'keep_alive', params: { keepAliveId: 957759560 } },
{ name: 'chat', params: { message: '<Bob> Hello World!' } },
{ name: 'position_look', params: { x: 6.5, y: 65.62, stance: 67.24, z: 7.5, yaw: 0, pitch: 0, onGround: true } }
// TODO: add more packets for better quality data
]
const {firstVersion, lastVersion} = require('./common/parallel')
console.log({firstVersion, lastVersion})
const { firstVersion, lastVersion } = require('./common/parallel')
console.log({ firstVersion, lastVersion })
mc.supportedVersions.forEach(function (supportedVersion, i) {
if (!(i >= firstVersion && i <= lastVersion)) { return }
@ -24,7 +24,7 @@ mc.supportedVersions.forEach(function (supportedVersion, i) {
this.timeout(60 * 1000)
const inputData = []
it('bench serializing', function (done) {
const serializer = mc.createSerializer({state: states.PLAY, isServer: false, version: version.minecraftVersion})
const serializer = mc.createSerializer({ state: states.PLAY, isServer: false, version: version.minecraftVersion })
let start, i, j
console.log('Beginning write test')
start = Date.now()
@ -39,7 +39,7 @@ mc.supportedVersions.forEach(function (supportedVersion, i) {
})
it('bench parsing', function (done) {
const deserializer = mc.createDeserializer({state: states.PLAY, isServer: true, version: version.minecraftVersion})
const deserializer = mc.createDeserializer({ state: states.PLAY, isServer: true, version: version.minecraftVersion })
console.log('Beginning read test')
const start = Date.now()
for (let j = 0; j < inputData.length; j++) {

View file

@ -9,7 +9,7 @@ const MC_SERVER_PATH = path.join(__dirname, 'server')
const Wrap = require('minecraft-wrap').Wrap
const {firstVersion, lastVersion} = require('./common/parallel')
const { firstVersion, lastVersion } = require('./common/parallel')
const download = require('minecraft-wrap').download

View file

@ -10,11 +10,11 @@ const mc = require('../../')
// (3,4,10) -> (9,9)
function testedRange (nodeIndex, nodeTotal, numberOfVersions) {
const nbFirsts = Math.ceil(numberOfVersions / nodeTotal)
if (nodeIndex === (nodeTotal - 1)) { return {firstVersion: nbFirsts * nodeIndex, lastVersion: numberOfVersions - 1} }
if (nodeIndex === (nodeTotal - 1)) { return { firstVersion: nbFirsts * nodeIndex, lastVersion: numberOfVersions - 1 } }
return {firstVersion: nodeIndex * nbFirsts, lastVersion: (nodeIndex + 1) * nbFirsts - 1}
return { firstVersion: nodeIndex * nbFirsts, lastVersion: (nodeIndex + 1) * nbFirsts - 1 }
}
console.log({nodeIndex, nodeTotal, versions: mc.supportedVersions.length})
const {firstVersion, lastVersion} = parallel ? testedRange(nodeIndex, nodeTotal, mc.supportedVersions.length) : {firstVersion: 0, lastVersion: mc.supportedVersions.length - 1}
console.log({ nodeIndex, nodeTotal, versions: mc.supportedVersions.length })
const { firstVersion, lastVersion } = parallel ? testedRange(nodeIndex, nodeTotal, mc.supportedVersions.length) : { firstVersion: 0, lastVersion: mc.supportedVersions.length - 1 }
module.exports = {firstVersion, lastVersion}
module.exports = { firstVersion, lastVersion }

View file

@ -21,13 +21,13 @@ const slotValue = {
type: 'compound',
name: 'test',
value: {
test1: {type: 'int', value: 4},
test2: {type: 'long', value: [12, 42]},
test3: {type: 'byteArray', value: [32]},
test4: {type: 'string', value: 'ohi'},
test5: {type: 'list', value: {type: 'int', value: [4]}},
test6: {type: 'compound', value: {test: {type: 'int', value: 4}}},
test7: {type: 'intArray', value: [12, 42]}
test1: { type: 'int', value: 4 },
test2: { type: 'long', value: [12, 42] },
test3: { type: 'byteArray', value: [32] },
test4: { type: 'string', value: 'ohi' },
test5: { type: 'list', value: { type: 'int', value: [4] } },
test6: { type: 'compound', value: { test: { type: 'int', value: 4 } } },
test7: { type: 'intArray', value: [12, 42] }
}
}
}
@ -85,45 +85,45 @@ const values = {
type: 'compound',
name: 'test',
value: {
test1: {type: 'int', value: 4},
test2: {type: 'long', value: [12, 42]},
test3: {type: 'byteArray', value: [32]},
test4: {type: 'string', value: 'ohi'},
test5: {type: 'list', value: {type: 'int', value: [4]}},
test6: {type: 'compound', value: {test: {type: 'int', value: 4}}},
test7: {type: 'intArray', value: [12, 42]}
test1: { type: 'int', value: 4 },
test2: { type: 'long', value: [12, 42] },
test3: { type: 'byteArray', value: [32] },
test4: { type: 'string', value: 'ohi' },
test5: { type: 'list', value: { type: 'int', value: [4] } },
test6: { type: 'compound', value: { test: { type: 'int', value: 4 } } },
test7: { type: 'intArray', value: [12, 42] }
}
},
'optionalNbt': {
type: 'compound',
name: 'test',
value: {
test1: {type: 'int', value: 4},
test2: {type: 'long', value: [12, 42]},
test3: {type: 'byteArray', value: [32]},
test4: {type: 'string', value: 'ohi'},
test5: {type: 'list', value: {type: 'int', value: [4]}},
test6: {type: 'compound', value: {test: {type: 'int', value: 4}}},
test7: {type: 'intArray', value: [12, 42]}
test1: { type: 'int', value: 4 },
test2: { type: 'long', value: [12, 42] },
test3: { type: 'byteArray', value: [32] },
test4: { type: 'string', value: 'ohi' },
test5: { type: 'list', value: { type: 'int', value: [4] } },
test6: { type: 'compound', value: { test: { type: 'int', value: 4 } } },
test7: { type: 'intArray', value: [12, 42] }
}
},
'compressedNbt': {
type: 'compound',
name: 'test',
value: {
test1: {type: 'int', value: 4},
test2: {type: 'long', value: [12, 42]},
test3: {type: 'byteArray', value: [32]},
test4: {type: 'string', value: 'ohi'},
test5: {type: 'list', value: {type: 'int', value: [4]}},
test6: {type: 'compound', value: {test: {type: 'int', value: 4}}},
test7: {type: 'intArray', value: [12, 42]}
test1: { type: 'int', value: 4 },
test2: { type: 'long', value: [12, 42] },
test3: { type: 'byteArray', value: [32] },
test4: { type: 'string', value: 'ohi' },
test5: { type: 'list', value: { type: 'int', value: [4] } },
test6: { type: 'compound', value: { test: { type: 'int', value: 4 } } },
test7: { type: 'intArray', value: [12, 42] }
}
},
'i64': [0, 1],
'u64': [0, 1],
'entityMetadata': [
{key: 17, value: 0, type: 0}
{ key: 17, value: 0, type: 0 }
],
'objectData': {
intField: 9,
@ -132,10 +132,10 @@ const values = {
velocityZ: 3
},
'UUID': '00112233-4455-6677-8899-aabbccddeeff',
'position': {x: 12, y: 100, z: 4382821},
'position_ibi': {x: 12, y: 100, z: 4382821},
'position_isi': {x: 12, y: 100, z: 4382821},
'position_iii': {x: 12, y: 100, z: 4382821},
'position': { x: 12, y: 100, z: 4382821 },
'position_ibi': { x: 12, y: 100, z: 4382821 },
'position_isi': { x: 12, y: 100, z: 4382821 },
'position_iii': { x: 12, y: 100, z: 4382821 },
'restBuffer': Buffer.alloc(0),
'switch': function (typeArgs, context) {
const i = typeArgs.fields[getField(typeArgs.compareTo, context)]
@ -158,7 +158,7 @@ const values = {
})
return results
},
'tags': [{'tagName': 'hi', 'entries': [1, 2, 3, 4, 5]}],
'tags': [{ 'tagName': 'hi', 'entries': [1, 2, 3, 4, 5] }],
'ingredient': [slotValue],
'particleData': null
}
@ -174,7 +174,7 @@ function getValue (_type, packet) {
}
}
const {firstVersion, lastVersion} = require('./common/parallel')
const { firstVersion, lastVersion } = require('./common/parallel')
mc.supportedVersions.forEach(function (supportedVersion, i) {
if (!(i >= firstVersion && i <= lastVersion)) { return }

View file

@ -3,7 +3,7 @@
const mc = require('../')
const assert = require('power-assert')
const {firstVersion, lastVersion} = require('./common/parallel')
const { firstVersion, lastVersion } = require('./common/parallel')
mc.supportedVersions.forEach(function (supportedVersion, i) {
if (!(i >= firstVersion && i <= lastVersion)) { return }
@ -124,7 +124,7 @@ mc.supportedVersions.forEach(function (supportedVersion, i) {
online: 0,
sample: []
},
description: {text: 'test1234'}
description: { text: 'test1234' }
})
server.close()
})
@ -192,9 +192,9 @@ mc.supportedVersions.forEach(function (supportedVersion, i) {
player2.end()
}
player1.write('chat', {message: 'hello'})
player1.write('chat', { message: 'hello' })
})
player2.write('chat', {message: 'hi'})
player2.write('chat', { message: 'hi' })
})
const player2 = mc.createClient({
username: 'player2',
@ -211,7 +211,7 @@ mc.supportedVersions.forEach(function (supportedVersion, i) {
if (!server.clients.hasOwnProperty(clientId)) continue
client = server.clients[clientId]
if (client !== exclude) client.write('chat', {message: JSON.stringify({text: message}), position: 0})
if (client !== exclude) client.write('chat', { message: JSON.stringify({ text: message }), position: 0 })
}
}
})