Skip to content

Commit fc95843

Browse files
u9grom1504
andauthored
Make sure we pass a string to a storagebuilder (#2645)
* Make sure we pass a string to a storagebuilder * Add test * Fix lint --------- Co-authored-by: Romain Beaumont <romain.rom1@gmail.com>
1 parent b336d22 commit fc95843

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

lib/plugins/blocks.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,11 @@ function inject (bot, { version, storageBuilder, hideErrors }) {
470470
if (bot.supportFeature('dimensionIsAnInt')) {
471471
return dimensionNames[dimension]
472472
} else if (bot.supportFeature('dimensionIsAString') || bot.supportFeature('dimensionIsAWorld')) {
473-
return dimension
473+
return worldName
474474
}
475475
}
476+
// only exposed for testing
477+
bot._getDimensionName = () => worldName
476478

477479
async function switchWorld () {
478480
if (bot.world) {
@@ -503,9 +505,10 @@ function inject (bot, { version, storageBuilder, hideErrors }) {
503505
bot._client.on('login', (packet) => {
504506
if (bot.supportFeature('dimensionIsAnInt')) {
505507
dimension = packet.dimension
508+
worldName = dimensionToFolderName(dimension)
506509
} else {
507510
dimension = packet.dimension
508-
worldName = packet.worldName
511+
worldName = /^minecraft:.+/.test(packet.worldName) ? packet.worldName : `minecraft:${packet.worldName}`
509512
}
510513
switchWorld()
511514
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const assert = require('assert')
2+
3+
module.exports = () => async (bot) => {
4+
assert.strictEqual(bot._getDimensionName(), 'minecraft:overworld')
5+
}

0 commit comments

Comments
 (0)