mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-14 19:04:59 -05:00
simplified autoversion fallback
This commit is contained in:
parent
6a3acff5de
commit
2a6973ab42
1 changed files with 7 additions and 9 deletions
|
@ -22,18 +22,16 @@ module.exports = function(client, options) {
|
|||
// The version string is interpreted by https://github.com/PrismarineJS/node-minecraft-data
|
||||
const brandedMinecraftVersion = response.version.name; // 1.8.9, 1.7.10
|
||||
const protocolVersion = response.version.protocol;// 47, 5
|
||||
let versions = brandedMinecraftVersion.match(/((\d+\.)+\d+)/g).map(function (version) {
|
||||
let versions = [brandedMinecraftVersion]
|
||||
.concat(brandedMinecraftVersion.match(/((\d+\.)+\d+)/g)||[])
|
||||
.map(function (version) {
|
||||
return minecraft_data.versionsByMinecraftVersion["pc"][version]
|
||||
}).filter(function (info) {
|
||||
return info
|
||||
}).sort(function (a, b) {
|
||||
return b.version - a.version
|
||||
})
|
||||
.filter(function (info) { return info })
|
||||
.sort(function (a, b) { return b.version - a.version })
|
||||
.concat(minecraft_data.postNettyVersionsByProtocolVersion["pc"][protocolVersion]||[])
|
||||
if (versions.length === 0) {
|
||||
versions = minecraft_data.postNettyVersionsByProtocolVersion["pc"][protocolVersion];
|
||||
if (!versions) {
|
||||
throw new Error(`unsupported/unknown protocol version: ${protocolVersion}, update minecraft-data`);
|
||||
}
|
||||
throw new Error(`unsupported/unknown protocol version: ${protocolVersion}, update minecraft-data`);
|
||||
}
|
||||
const minecraftVersion = versions[0].minecraftVersion;
|
||||
|
||||
|
|
Loading…
Reference in a new issue