Update protodef version
This commit is contained in:
parent
b546cda899
commit
1cdb0e4c55
7 changed files with 17 additions and 14 deletions
|
|
@ -1,7 +1,7 @@
|
|||
const { ClientStatus, Connection } = require('./connection')
|
||||
const { createDeserializer, createSerializer } = require('./transforms/serializer')
|
||||
const { RakClient } = require('./rak')
|
||||
const { serialize } = require('./datatypes/util')
|
||||
const { serialize, isDebug } = require('./datatypes/util')
|
||||
const debug = require('debug')('minecraft-protocol')
|
||||
const Options = require('./options')
|
||||
const auth = require('./client/auth')
|
||||
|
|
@ -35,7 +35,7 @@ class Client extends Connection {
|
|||
this.startGameData = {}
|
||||
this.clientRuntimeId = null
|
||||
|
||||
if (process.env.DEBUG.includes('minecraft-protocol')) {
|
||||
if (isDebug) {
|
||||
this.inLog = (...args) => debug('C ->', ...args)
|
||||
this.outLog = (...args) => debug('C <-', ...args)
|
||||
}
|
||||
|
|
@ -156,7 +156,7 @@ class Client extends Connection {
|
|||
readPacket (packet) {
|
||||
const des = this.deserializer.parsePacketBuffer(packet)
|
||||
const pakData = { name: des.data.name, params: des.data.params }
|
||||
this.inLog('-> C', pakData.name, this.options.loggging ? serialize(pakData.params) : '')
|
||||
this.inLog?.('-> C', pakData.name, this.options.loggging ? serialize(pakData.params) : '')
|
||||
this.emit('packet', des)
|
||||
|
||||
if (debugging) {
|
||||
|
|
@ -186,7 +186,7 @@ class Client extends Connection {
|
|||
break
|
||||
case 'play_status':
|
||||
if (this.status === ClientStatus.Authenticating) {
|
||||
this.inLog('Server wants to skip encryption')
|
||||
this.inLog?.('Server wants to skip encryption')
|
||||
this.emit('join')
|
||||
this.status = ClientStatus.Initializing
|
||||
}
|
||||
|
|
@ -194,7 +194,8 @@ class Client extends Connection {
|
|||
break
|
||||
default:
|
||||
if (this.status !== ClientStatus.Initializing && this.status !== ClientStatus.Initialized) {
|
||||
this.inLog(`Can't accept ${des.data.name}, client not yet authenticated : ${this.status}`)
|
||||
// TODO: standardjs bug happens here with ?.(`something ${des.data.name}`)
|
||||
if (this.inLog) this.inLog(`Can't accept ${des.data.name}, client not yet authenticated : ${this.status}`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,4 +43,6 @@ function nextUUID () {
|
|||
return uuidFrom(Date.now().toString())
|
||||
}
|
||||
|
||||
module.exports = { getFiles, sleep, waitFor, serialize, uuidFrom, nextUUID }
|
||||
const isDebug = process.env.DEBUG?.includes('minecraft-protocol')
|
||||
|
||||
module.exports = { getFiles, sleep, waitFor, serialize, uuidFrom, nextUUID, isDebug }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const { ClientStatus, Connection } = require('./connection')
|
||||
const Options = require('./options')
|
||||
const { serialize } = require('./datatypes/util')
|
||||
const { serialize, isDebug } = require('./datatypes/util')
|
||||
const { KeyExchange } = require('./handshake/keyExchange')
|
||||
const Login = require('./handshake/login')
|
||||
const LoginVerify = require('./handshake/loginVerify')
|
||||
|
|
@ -23,7 +23,7 @@ class Player extends Connection {
|
|||
this.startQueue()
|
||||
this.status = ClientStatus.Authenticating
|
||||
|
||||
if (process.env.DEBUG.includes('minecraft-protocol')) {
|
||||
if (isDebug) {
|
||||
this.inLog = (...args) => debug('S ->', ...args)
|
||||
this.outLog = (...args) => debug('S <-', ...args)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const [readVarInt, writeVarInt, sizeOfVarInt] = require('protodef-compiler-fix').types.varint
|
||||
const [readVarInt, writeVarInt, sizeOfVarInt] = require('protodef').types.varint
|
||||
const zlib = require('zlib')
|
||||
|
||||
// Concatenates packets into one batch packet, and adds length prefixs.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const { ProtoDefCompiler, CompiledProtodef } = require('protodef-compiler-fix').Compiler
|
||||
const { FullPacketParser, Serializer } = require('protodef-compiler-fix')
|
||||
const { ProtoDefCompiler, CompiledProtodef } = require('protodef').Compiler
|
||||
const { FullPacketParser, Serializer } = require('protodef')
|
||||
const { join } = require('path')
|
||||
|
||||
class Parser extends FullPacketParser {
|
||||
|
|
@ -43,7 +43,7 @@ function getProtocol (version) {
|
|||
compiler.addTypes(require(join(__dirname, '../datatypes/compiler-minecraft')))
|
||||
compiler.addTypes(require('prismarine-nbt/compiler-zigzag'))
|
||||
|
||||
global.PartialReadError = require('protodef-compiler-fix/src/utils').PartialReadError
|
||||
global.PartialReadError = require('protodef/src/utils').PartialReadError
|
||||
const compile = (compiler, file) => require(file)(compiler.native)
|
||||
|
||||
return new CompiledProtodef(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue