Skip to content

Commit

Permalink
feat: Minecraft for 1.20.5 requires Java 21 (and not 1.21) (#7)
Browse files Browse the repository at this point in the history
- Also rewrites the mcVersionAtLeast using semver.satisfies() to make patch version works
  • Loading branch information
GeekCornerGH committed Apr 24, 2024
1 parent 17a44be commit 2e37936
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/common/distribution/DistributionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class HeliosServer {
}

private defaultJavaVersion(): [string, number] {
if(mcVersionAtLeast('1.21', this.rawServer.minecraftVersion)) {
if(mcVersionAtLeast('1.20.5', this.rawServer.minecraftVersion)) {
return ['>=21.x', 21]
} else if(mcVersionAtLeast('1.17', this.rawServer.minecraftVersion)) {
return ['>=17.x', 17]
Expand Down
11 changes: 2 additions & 9 deletions lib/common/util/MojangUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Rule, Natives } from '../../dl/mojang/MojangTypes'
import semver from 'semver'

export function getMojangOS(): string {
const opSys = process.platform
Expand Down Expand Up @@ -48,13 +49,5 @@ export function isLibraryCompatible(rules?: Rule[], natives?: Natives): boolean
* @param {string} actual The actual version.
*/
export function mcVersionAtLeast(desired: string, actual: string): boolean {
const des = desired.split('.')
const act = actual.split('.')

for(let i=0; i<des.length; i++){
if(!(parseInt(act[i]) >= parseInt(des[i]))){
return false
}
}
return true
return semver.satisfies(actual, `>=${desired}`)
}

0 comments on commit 2e37936

Please sign in to comment.