Skip to content

Commit

Permalink
Make sure we pass a string to a storagebuilder (#2645)
Browse files Browse the repository at this point in the history
* Make sure we pass a string to a storagebuilder

* Add test

* Fix lint

---------

Co-authored-by: Romain Beaumont <[email protected]>
  • Loading branch information
u9g and rom1504 committed Jul 29, 2023
1 parent b336d22 commit fc95843
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/plugins/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,11 @@ function inject (bot, { version, storageBuilder, hideErrors }) {
if (bot.supportFeature('dimensionIsAnInt')) {
return dimensionNames[dimension]
} else if (bot.supportFeature('dimensionIsAString') || bot.supportFeature('dimensionIsAWorld')) {
return dimension
return worldName
}
}
// only exposed for testing
bot._getDimensionName = () => worldName

async function switchWorld () {
if (bot.world) {
Expand Down Expand Up @@ -503,9 +505,10 @@ function inject (bot, { version, storageBuilder, hideErrors }) {
bot._client.on('login', (packet) => {
if (bot.supportFeature('dimensionIsAnInt')) {
dimension = packet.dimension
worldName = dimensionToFolderName(dimension)
} else {
dimension = packet.dimension
worldName = packet.worldName
worldName = /^minecraft:.+/.test(packet.worldName) ? packet.worldName : `minecraft:${packet.worldName}`
}
switchWorld()
})
Expand Down
5 changes: 5 additions & 0 deletions test/externalTests/dimensionName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const assert = require('assert')

module.exports = () => async (bot) => {
assert.strictEqual(bot._getDimensionName(), 'minecraft:overworld')
}

0 comments on commit fc95843

Please sign in to comment.