diff --git a/src/client/caseCorrect.js b/src/client/caseCorrect.js index 2eb634a..e8a42d8 100644 --- a/src/client/caseCorrect.js +++ b/src/client/caseCorrect.js @@ -1,7 +1,8 @@ var yggdrasil = require('yggdrasil')({}); var UUID = require('uuid-1345'); -module.exports = function(client, options) { +module.exports = function(client) { + var options = client.options; var clientToken = options.clientToken || UUID.v4().toString(); options.accessToken = null; options.haveCredentials = options.password != null || (clientToken != null && options.session != null); diff --git a/src/client/compress.js b/src/client/compress.js index cebe34f..40d092f 100644 --- a/src/client/compress.js +++ b/src/client/compress.js @@ -1,4 +1,4 @@ -module.exports = function(client, options) { +module.exports = function(client) { client.once("compress", onCompressionRequest); client.on("set_compression", onCompressionRequest); diff --git a/src/client/encrypt.js b/src/client/encrypt.js index 696ddfc..10b391c 100644 --- a/src/client/encrypt.js +++ b/src/client/encrypt.js @@ -3,7 +3,8 @@ var yggserver = require('yggdrasil').server({}); var ursa=require("../ursa"); var debug = require("../debug"); -module.exports = function(client, options) { +module.exports = function(client) { + var options = client.options; client.once('encryption_begin', onEncryptionKeyRequest); function onEncryptionKeyRequest(packet) { diff --git a/src/client/keepalive.js b/src/client/keepalive.js index 3fc817b..5b206cf 100644 --- a/src/client/keepalive.js +++ b/src/client/keepalive.js @@ -1,4 +1,5 @@ -module.exports = function(client, options) { +module.exports = function(client) { + var options = client.options; var keepAlive = options.keepAlive == null ? true : options.keepAlive; if (!keepAlive) return; diff --git a/src/client/play.js b/src/client/play.js index ebc491e..efcf84b 100644 --- a/src/client/play.js +++ b/src/client/play.js @@ -1,6 +1,6 @@ var states = require("../states"); -module.exports = function(client, options) { +module.exports = function(client) { client.once('success', onLogin); function onLogin(packet) { diff --git a/src/client/setProtocol.js b/src/client/setProtocol.js index 4948b1c..0c5b7db 100644 --- a/src/client/setProtocol.js +++ b/src/client/setProtocol.js @@ -1,7 +1,8 @@ var states = require("../states"); -module.exports = function(client, options) { +module.exports = function(client) { + var options = client.options; client.on('connect', onConnect); function onConnect() { diff --git a/src/client/tcp_dns.js b/src/client/tcp_dns.js index a8e3060..2863962 100644 --- a/src/client/tcp_dns.js +++ b/src/client/tcp_dns.js @@ -1,7 +1,8 @@ var net = require('net'); var dns = require('dns'); -module.exports = function(client, options) { +module.exports = function(client) { + var options = client.options; options.port = options.port || 25565; options.host = options.host || 'localhost'; diff --git a/src/createClient.js b/src/createClient.js index 40a3d13..5d7c342 100644 --- a/src/createClient.js +++ b/src/createClient.js @@ -22,14 +22,15 @@ function createClient(options) { options.protocolVersion = version.version; var client = new Client(false, options.majorVersion); + client.options = options; - tcp_dns(client, options); - setProtocol(client, options); - keepalive(client, options); - encrypt(client, options); - play(client, options); - compress(client, options); - caseCorrect(client, options); + tcp_dns(client); + setProtocol(client); + keepalive(client); + encrypt(client); + play(client); + compress(client); + caseCorrect(client); return client; } diff --git a/src/createClientAuto.js b/src/createClientAuto.js index 509d72c..b307157 100644 --- a/src/createClientAuto.js +++ b/src/createClientAuto.js @@ -47,13 +47,11 @@ function createClientAuto(options) { // Note that versionName is a descriptive version stirng like '1.8.9' on vailla, but other // servers add their own name (Spigot 1.8.8, Glowstone++ 1.8.9) so we cannot use it directly, // even though it is in a format accepted by minecraft-data. Instead, translate the protocol. - //XXX TODO: modify client object - options.version = protocolVersion2MinecraftVersion(protocolVersion); + client.options.version = protocolVersion2MinecraftVersion(protocolVersion); // Use the exact same protocol version // Requires https://github.com/PrismarineJS/node-minecraft-protocol/pull/330 - //XXX TODO: modify client objecti - options.protocolVersion = protocolVersion; + client.options.protocolVersion = protocolVersion; if (response.modinfo && response.modinfo.type === 'FML') { // Use the list of Forge mods from the server ping, so client will match server diff --git a/src/ping.js b/src/ping.js index 4a58353..1e6adcb 100644 --- a/src/ping.js +++ b/src/ping.js @@ -15,6 +15,7 @@ function ping(options, cb) { options.protocolVersion = version.version; var client = new Client(false,options.majorVersion); + client.options = options; client.on('error', function(err) { cb(err); }); @@ -46,6 +47,6 @@ function ping(options, cb) { client.state = states.STATUS; }); - tcp_dns(client, options); + tcp_dns(client); options.connect(client); }