Skip to content

Commit

Permalink
disable logging and --bail
Browse files Browse the repository at this point in the history
  • Loading branch information
extremeheat committed Jan 7, 2025
1 parent e5292d1 commit a93bb2c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ function inject (bot) {
console.log('Player Info', packet)
// player list item(s)

if (bot.registry.version['>=']('1.21.3')) {
if (typeof packet.action === 'string') {
// the features checks below this will be un-needed with https://github.com/PrismarineJS/minecraft-data/pull/948
for (const update of packet.data) {
let player = bot.uuidToUsername[update.uuid] ? bot.players[bot.uuidToUsername[update.uuid]] : null
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"mocha_test": "mocha --reporter spec --exit --bail",
"mocha_test": "mocha --reporter spec --exit",
"test": "npm run mocha_test",
"pretest": "npm run lint",
"lint": "standard && standard-markdown",
Expand Down
26 changes: 14 additions & 12 deletions test/externalTests/plugins/testCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,20 @@ function inject (bot) {
}

// DEBUG
bot._client.on('packet', function (data, meta) {
if (['chunk', 'time', 'light', 'alive'].some(e => meta.name.includes(e))) return
console.log('->', meta.name, JSON.stringify(data)?.slice(0, 250))
})
const oldWrite = bot._client.write
bot._client.write = function (name, data) {
if (['alive', 'pong', 'ping'].some(e => name.includes(e))) return
console.log('<-', name, JSON.stringify(data)?.slice(0, 250))
oldWrite.apply(bot._client, arguments)
}
BigInt.prototype.toJSON ??= function () {
return this.toString()
if (process.env.DEBUG) {
bot._client.on('packet', function (data, meta) {
if (['chunk', 'time', 'light', 'alive'].some(e => meta.name.includes(e))) return
console.log('->', meta.name, JSON.stringify(data)?.slice(0, 250))
})
const oldWrite = bot._client.write
bot._client.write = function (name, data) {
if (['alive', 'pong', 'ping'].some(e => name.includes(e))) return
console.log('<-', name, JSON.stringify(data)?.slice(0, 250))
oldWrite.apply(bot._client, arguments)
}
BigInt.prototype.toJSON ??= function () { // eslint-disable-line
return this.toString()
}
}

// you need to be in creative mode for this to work
Expand Down
15 changes: 10 additions & 5 deletions test/internalTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ for (const supportedVersion of mineflayer.testedVersions) {
const registry = require('prismarine-registry')(supportedVersion)
const version = registry.version
const Chunk = require('prismarine-chunk')(supportedVersion)
const hasSignedChat = registry.supportFeature('signedChat')
const isNewPlayerInfoFormat = registry.version['>=']('1.20.3')
function wrapPlayerInfo (n) {
if (isNewPlayerInfoFormat) return { _value: n }
return n
}

const hasSignedChat = registry.supportFeature('signedChat')
function chatText (text) {
// TODO: move this to prismarine-chat in a new ChatMessage(text).toNotch(asNbt) method
return registry.supportFeature('chatPacketsUseNbtComponents')
Expand Down Expand Up @@ -580,7 +585,7 @@ for (const supportedVersion of mineflayer.testedVersions) {
assert.strictEqual(entity.username, player.displayName.toString())
if (registry.supportFeature('playerInfoActionIsBitfield')) {
client.write('player_info', {
action: 53,
action: wrapPlayerInfo(53),
data: [{
uuid: '1-2-3-4',
player: {
Expand Down Expand Up @@ -616,7 +621,7 @@ for (const supportedVersion of mineflayer.testedVersions) {
assert.strictEqual('wvffle', player.displayName.toString())
if (registry.supportFeature('playerInfoActionIsBitfield')) {
client.write('player_info', {
action: 53,
action: wrapPlayerInfo(53),
data: [{
uuid: '1-2-3-4',
player: {
Expand Down Expand Up @@ -653,7 +658,7 @@ for (const supportedVersion of mineflayer.testedVersions) {

if (registry.supportFeature('playerInfoActionIsBitfield')) {
client.write('player_info', {
action: 53,
action: wrapPlayerInfo(53),
data: [{
uuid: '1-2-3-4',
player: {
Expand Down Expand Up @@ -736,7 +741,7 @@ for (const supportedVersion of mineflayer.testedVersions) {

if (registry.supportFeature('playerInfoActionIsBitfield')) {
client.write('player_info', {
action: 53,
action: wrapPlayerInfo(53),
data: [{
uuid: '1-2-3-4',
player: {
Expand Down

0 comments on commit a93bb2c

Please sign in to comment.