Skip to content

Commit

Permalink
feat: 1.20 support and allow versions without patch number
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekCornerGH authored and dscalzi committed Jun 25, 2023
1 parent 340df4f commit 3ec535d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
9 changes: 4 additions & 5 deletions src/resolver/forge/adapter/ForgeGradle3.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ForgeGradle3Adapter extends ForgeResolver {
if(version.getMinor() === 12 && VersionUtil.isOneDotTwelveFG2(libraryVersion)) {
return false
}
return VersionUtil.isVersionAcceptable(version, [12, 13, 14, 15, 16, 17, 18, 19])
return VersionUtil.isVersionAcceptable(version, [12, 13, 14, 15, 16, 17, 18, 19, 20])
}

private generatedFiles: GeneratedFile[] | undefined
Expand All @@ -57,7 +57,7 @@ export class ForgeGradle3Adapter extends ForgeResolver {
const is117OrGreater = this.minecraftVersion.getMinor() >= 17

// Configure for 13, 14, 15, 16, 17, 18, 19
if(VersionUtil.isVersionAcceptable(this.minecraftVersion, [13, 14, 15, 16, 17, 18, 19])) {
if(VersionUtil.isVersionAcceptable(this.minecraftVersion, [13, 14, 15, 16, 17, 18, 19, 20])) {

// https://github.com/MinecraftForge/MinecraftForge/commit/97d4652f5fe15931b980117efabdff332f9f6428
const mcpUnifiedVersion = `${this.minecraftVersion}-${ForgeGradle3Adapter.WILDCARD_MCP_VERSION}`
Expand Down Expand Up @@ -116,7 +116,7 @@ export class ForgeGradle3Adapter extends ForgeResolver {
)
}

if(VersionUtil.isVersionAcceptable(this.minecraftVersion, [17, 18, 19])) {
if(VersionUtil.isVersionAcceptable(this.minecraftVersion, [17, 18, 19, 20])) {

// Added in 1.17+

Expand Down Expand Up @@ -145,7 +145,7 @@ export class ForgeGradle3Adapter extends ForgeResolver {
)
}

if (VersionUtil.isVersionAcceptable(this.minecraftVersion, [18, 19])) {
if (VersionUtil.isVersionAcceptable(this.minecraftVersion, [18, 19, 20])) {

// Added in 1.18+

Expand Down Expand Up @@ -508,7 +508,6 @@ export class ForgeGradle3Adapter extends ForgeResolver {
)
)
})

const destination = libRepo.getArtifactByComponents(
components.group,
components.artifact,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ForgeModStructure113 extends BaseForgeModStructure {

// eslint-disable-next-line @typescript-eslint/no-unused-vars
public static isForVersion(version: MinecraftVersion, libraryVersion: string): boolean {
return VersionUtil.isVersionAcceptable(version, [13, 14, 15, 16, 17, 18, 19])
return VersionUtil.isVersionAcceptable(version, [13, 14, 15, 16, 17, 18, 19, 20])
}

private forgeModMetadata: {[property: string]: ModsToml | undefined} = {}
Expand Down
2 changes: 1 addition & 1 deletion src/util/MavenUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class MavenUtil {
public static mavenComponentsToString(
group: string, artifact: string, version: string, classifier?: string, extension = 'jar'
): string {
return `${group.replace(/\./g, '/')}/${artifact}/${version}/${artifact}-${version}${classifier != null ? `-${classifier}` : ''}.${extension}`
return `${group.replace(/\./g, '/').replace(/:/g, '/')}/${artifact}/${version}/${artifact}-${version}${classifier != null ? `-${classifier}` : ''}.${extension}`
}

public static mavenIdentifierToUrl(id: string, extension = 'jar'): URL {
Expand Down
8 changes: 4 additions & 4 deletions src/util/MinecraftVersion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class MinecraftVersion {

private static readonly MINECRAFT_VERSION_REGEX = /(\d+).(\d+).(\d+)/
private static readonly MINECRAFT_VERSION_REGEX = /(\d+).(\d+).?(\d+)?/

private readonly major: number
private readonly minor: number
Expand All @@ -11,7 +11,7 @@ export class MinecraftVersion {
if(res != null) {
this.major = Number(res[1])
this.minor = Number(res[2])
this.revision = Number(res[3])
this.revision = Number(res[3]) ?? undefined
} else {
throw new Error(`${version} is not a valid minecraft version!`)
}
Expand All @@ -23,8 +23,8 @@ export class MinecraftVersion {

public getMajor(): number { return this.major }
public getMinor(): number { return this.minor }
public getRevision(): number { return this.revision }
public getRevision(): number|undefined { return this.revision }

public toString(): string { return `${this.major}.${this.minor}.${this.revision}`}
public toString(): string { return `${this.major}.${this.minor}${this.revision? '.'+this.revision:''}`}

}
2 changes: 1 addition & 1 deletion src/util/VersionUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class VersionUtil {
'latest'
]

public static readonly MINECRAFT_VERSION_REGEX = /(\d+).(\d+).(\d+)/
public static readonly MINECRAFT_VERSION_REGEX = /(\d+).(\d+).?(\d+)?/

public static isVersionAcceptable(version: MinecraftVersion, acceptable: number[]): boolean {
if (version.getMajor() === 1) {
Expand Down

0 comments on commit 3ec535d

Please sign in to comment.