mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-14 19:04:59 -05:00
run standard
This commit is contained in:
parent
85264bcb95
commit
061176d377
12 changed files with 23 additions and 23 deletions
|
@ -11,8 +11,8 @@ if (!username || !password) {
|
||||||
const client = mc.createClient({
|
const client = mc.createClient({
|
||||||
host,
|
host,
|
||||||
port: parseInt(port),
|
port: parseInt(port),
|
||||||
username: username,
|
username,
|
||||||
password: password,
|
password,
|
||||||
sessionServer: '', // URL to your session server proxy that changes the expected result of mojang's seession server to mcleaks expected.
|
sessionServer: '', // URL to your session server proxy that changes the expected result of mojang's seession server to mcleaks expected.
|
||||||
// For more information: https://github.com/PrismarineJS/node-yggdrasil/blob/master/src/Server.js#L19
|
// For more information: https://github.com/PrismarineJS/node-yggdrasil/blob/master/src/Server.js#L19
|
||||||
auth: async (client, options) => {
|
auth: async (client, options) => {
|
||||||
|
|
|
@ -62,7 +62,7 @@ const client = mc.createClient({
|
||||||
port: parseInt(process.argv[3]),
|
port: parseInt(process.argv[3]),
|
||||||
username: process.argv[4] ? process.argv[4] : 'echo',
|
username: process.argv[4] ? process.argv[4] : 'echo',
|
||||||
password: process.argv[5],
|
password: process.argv[5],
|
||||||
customPackets: customPackets
|
customPackets
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on('connect', function () {
|
client.on('connect', function () {
|
||||||
|
|
|
@ -12,7 +12,7 @@ const client = mc.createClient({
|
||||||
host,
|
host,
|
||||||
port: parseInt(port),
|
port: parseInt(port),
|
||||||
username: userOrEmail, // your microsoft account email
|
username: userOrEmail, // your microsoft account email
|
||||||
password: password, // your microsoft account password
|
password, // your microsoft account password
|
||||||
auth: 'microsoft' // This option must be present and set to 'microsoft' to use Microsoft Account Authentication. Failure to do so will result in yggdrasil throwing invalid account information.
|
auth: 'microsoft' // This option must be present and set to 'microsoft' to use Microsoft Account Authentication. Failure to do so will result in yggdrasil throwing invalid account information.
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ const srv = mc.createServer({
|
||||||
'online-mode': false,
|
'online-mode': false,
|
||||||
port: 25566,
|
port: 25566,
|
||||||
keepAlive: false,
|
keepAlive: false,
|
||||||
version: version
|
version
|
||||||
})
|
})
|
||||||
srv.on('login', function (client) {
|
srv.on('login', function (client) {
|
||||||
const addr = client.socket.remoteAddress
|
const addr = client.socket.remoteAddress
|
||||||
|
@ -92,11 +92,11 @@ srv.on('login', function (client) {
|
||||||
if (!endedTargetClient) { targetClient.end('Error') }
|
if (!endedTargetClient) { targetClient.end('Error') }
|
||||||
})
|
})
|
||||||
const targetClient = mc.createClient({
|
const targetClient = mc.createClient({
|
||||||
host: host,
|
host,
|
||||||
port: port,
|
port,
|
||||||
username: client.username,
|
username: client.username,
|
||||||
keepAlive: false,
|
keepAlive: false,
|
||||||
version: version
|
version
|
||||||
})
|
})
|
||||||
client.on('packet', function (data, meta) {
|
client.on('packet', function (data, meta) {
|
||||||
if (targetClient.state === states.PLAY && meta.state === states.PLAY) {
|
if (targetClient.state === states.PLAY && meta.state === states.PLAY) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ function broadcast (message, exclude, username) {
|
||||||
client = server.clients[clientId]
|
client = server.clients[clientId]
|
||||||
if (client !== exclude) {
|
if (client !== exclude) {
|
||||||
const msg = {
|
const msg = {
|
||||||
translate: translate,
|
translate,
|
||||||
with: [
|
with: [
|
||||||
username,
|
username,
|
||||||
message
|
message
|
||||||
|
|
|
@ -20,7 +20,7 @@ if (!process.argv[2].includes(':')) { // Spliting ip and port if available.
|
||||||
port = parseInt(port)
|
port = parseInt(port)
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol.ping({ host: host, port: port }, (err, pingResults) => { // Pinging server and getting result
|
protocol.ping({ host, port }, (err, pingResults) => { // Pinging server and getting result
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`${removeColorsFromString(JSON.stringify(pingResults.description.text))}`) // Printing motd to console
|
console.log(`${removeColorsFromString(JSON.stringify(pingResults.description.text))}`) // Printing motd to console
|
||||||
// Printing some infos to console
|
// Printing some infos to console
|
||||||
|
|
|
@ -5,8 +5,8 @@ const Server = require('./server')
|
||||||
const serializer = require('./transforms/serializer')
|
const serializer = require('./transforms/serializer')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Client: Client,
|
Client,
|
||||||
Server: Server,
|
Server,
|
||||||
states: require('./states'),
|
states: require('./states'),
|
||||||
createSerializer: serializer.createSerializer,
|
createSerializer: serializer.createSerializer,
|
||||||
createDeserializer: serializer.createDeserializer,
|
createDeserializer: serializer.createDeserializer,
|
||||||
|
|
|
@ -39,11 +39,11 @@ class Client extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
setSerializer (state) {
|
setSerializer (state) {
|
||||||
this.serializer = createSerializer({ isServer: this.isServer, version: this.version, state: state, customPackets: this.customPackets })
|
this.serializer = createSerializer({ isServer: this.isServer, version: this.version, state, customPackets: this.customPackets })
|
||||||
this.deserializer = createDeserializer({
|
this.deserializer = createDeserializer({
|
||||||
isServer: this.isServer,
|
isServer: this.isServer,
|
||||||
version: this.version,
|
version: this.version,
|
||||||
state: state,
|
state,
|
||||||
packetsToParse:
|
packetsToParse:
|
||||||
this.packetsToParse,
|
this.packetsToParse,
|
||||||
customPackets: this.customPackets,
|
customPackets: this.customPackets,
|
||||||
|
|
|
@ -66,7 +66,7 @@ module.exports = function (client, options) {
|
||||||
function writeChannel (channel, params) {
|
function writeChannel (channel, params) {
|
||||||
debug('write custom payload ' + channel + ' ' + params)
|
debug('write custom payload ' + channel + ' ' + params)
|
||||||
client.write('custom_payload', {
|
client.write('custom_payload', {
|
||||||
channel: channel,
|
channel,
|
||||||
data: proto.createPacketBuffer(channel, params)
|
data: proto.createPacketBuffer(channel, params)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,10 @@ const createClient = require('./createClient')
|
||||||
const createServer = require('./createServer')
|
const createServer = require('./createServer')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
createClient: createClient,
|
createClient,
|
||||||
createServer: createServer,
|
createServer,
|
||||||
Client: Client,
|
Client,
|
||||||
Server: Server,
|
Server,
|
||||||
states: require('./states'),
|
states: require('./states'),
|
||||||
createSerializer: serializer.createSerializer,
|
createSerializer: serializer.createSerializer,
|
||||||
createDeserializer: serializer.createDeserializer,
|
createDeserializer: serializer.createDeserializer,
|
||||||
|
|
|
@ -49,6 +49,6 @@ class Decipher extends Transform {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
createCipher: createCipher,
|
createCipher,
|
||||||
createDecipher: createDecipher
|
createDecipher
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,6 @@ function createDeserializer ({ state = states.HANDSHAKING, isServer = false, ver
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
createSerializer: createSerializer,
|
createSerializer,
|
||||||
createDeserializer: createDeserializer
|
createDeserializer
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue