-
-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completed steps up to downloading forge universal jar for 1.8-1.12.
Next step is processing the version.json and transforming it into a deliverable module.
- Loading branch information
Showing
14 changed files
with
251 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Forge113Adapter } from './forge/adapter/forge113.resolver' | ||
import { Forge18Adapter } from './forge/adapter/forge18.resolver' | ||
import { ForgeResolver } from './forge/forge.resolver' | ||
|
||
export class ResolverRegistry { | ||
|
||
public static readonly FORGE_ADAPTER_IMPL = [ | ||
Forge18Adapter, | ||
Forge113Adapter | ||
] | ||
|
||
public static getForgeResolver( | ||
minecraftVersion: string, | ||
forgeVersion: string, | ||
absoluteRoot: string, relativeRoot: string): ForgeResolver | undefined { | ||
for (const impl of ResolverRegistry.FORGE_ADAPTER_IMPL) { | ||
if (impl.isForVersion(minecraftVersion)) { | ||
return new impl(absoluteRoot, relativeRoot, minecraftVersion, forgeVersion) | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
import { Module } from '../model/spec/module' | ||
import { VersionUtil } from '../util/versionutil' | ||
import { Resolver } from './resolver' | ||
|
||
export abstract class BaseResolver implements Resolver { | ||
|
||
protected static isVersionAcceptable(version: string, acceptable: number[]): boolean { | ||
const versionComponents = VersionUtil.getMinecraftVersionComponents(version) | ||
if (versionComponents != null && versionComponents.major === 1) { | ||
return acceptable.find((element) => versionComponents.minor === element) != null | ||
} | ||
return false | ||
} | ||
|
||
constructor( | ||
protected absoluteRoot: string, | ||
protected relativeRoot: string | ||
) {} | ||
|
||
public abstract getModule(): Promise<Module> | ||
|
||
public abstract isForVersion(version: string): boolean | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Module } from '../../../model/spec/module' | ||
import { ForgeResolver } from '../forge.resolver' | ||
|
||
export class Forge113Adapter extends ForgeResolver { | ||
|
||
public static isForVersion(version: string) { | ||
return Forge113Adapter.isVersionAcceptable(version, [13, 14, 15]) | ||
} | ||
|
||
constructor( | ||
absoluteRoot: string, | ||
relativeRoot: string, | ||
minecraftVersion: string, | ||
forgeVersion: string | ||
) { | ||
super(absoluteRoot, relativeRoot, minecraftVersion, forgeVersion) | ||
} | ||
|
||
public async getModule(): Promise<Module> { | ||
return null as unknown as Module | ||
} | ||
|
||
public isForVersion(version: string): boolean { | ||
return Forge113Adapter.isForVersion(version) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,52 @@ | ||
import { Module } from '../../../model/spec/module' | ||
import { ForgeRepoStructure } from '../../../model/struct/repo/forgerepo.struct' | ||
import { ForgeResolver } from '../forge.resolver' | ||
|
||
export class Forge18Adapter extends ForgeResolver { | ||
|
||
public static isForVersion(version: string) { | ||
return Forge18Adapter.isVersionAcceptable(version, [8, 9, 10, 11, 12]) | ||
} | ||
|
||
constructor( | ||
absoluteRoot: string, | ||
relativeRoot: string, | ||
minecraftVersion: string, | ||
forgeVersion: string | ||
) { | ||
super(absoluteRoot, relativeRoot, minecraftVersion, forgeVersion) | ||
} | ||
|
||
public async getModule(): Promise<Module> { | ||
await this.getForgeByVersion() | ||
return null as unknown as Module | ||
} | ||
|
||
public isForVersion(version: string) { | ||
return Forge18Adapter.isForVersion(version) | ||
} | ||
|
||
public async getForgeByVersion() { | ||
const forgeRepo = this.repoStructure.getForgeRepoStruct() | ||
const artifactVersion = `${this.minecraftVersion}-${this.forgeVersion}` | ||
const targetLocalPath = forgeRepo.getLocalForge(artifactVersion, 'universal') | ||
console.debug(`Checking for forge version at ${targetLocalPath}..`) | ||
if (!await forgeRepo.artifactExists(targetLocalPath)) { | ||
console.debug(`Forge not found locally, initializing download..`) | ||
await forgeRepo.downloadArtifact( | ||
this.REMOTE_REPOSITORY, | ||
ForgeRepoStructure.FORGE_GROUP, | ||
ForgeRepoStructure.FORGE_ARTIFACT, | ||
artifactVersion, 'universal', 'jar') | ||
} else { | ||
console.debug('Using locally discovered forge.') | ||
} | ||
console.debug(`Beginning processing of Forge v${this.forgeVersion} (Minecraft ${this.minecraftVersion})`) | ||
} | ||
|
||
// TODO | ||
// extract manifest | ||
// parse manifest | ||
// return module | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,20 @@ | ||
import { Module } from '../../model/spec/module' | ||
import { RepoStructure } from '../../model/struct/repo/repo.struct' | ||
import { BaseResolver } from '../baseresolver' | ||
import { Forge18Adapter } from './adapter/forge18.resolver' | ||
|
||
export abstract class ForgeResolver extends BaseResolver { | ||
|
||
public static getResolver(version: string) { | ||
return ForgeResolver.ADAPTER_LIST[version] | ||
} | ||
|
||
// tslint:disable: object-literal-key-quotes | ||
private static readonly ADAPTER_LIST: {[version: string]: any} = { | ||
'1.8': Forge18Adapter, | ||
'1.9': Forge18Adapter, | ||
'1.10': Forge18Adapter, | ||
'1.11': Forge18Adapter, | ||
'1.12': Forge18Adapter | ||
} | ||
protected readonly REMOTE_REPOSITORY = 'https://files.minecraftforge.net/maven/' | ||
|
||
protected repoStructure: RepoStructure | ||
|
||
constructor( | ||
absoluteRoot: string, | ||
relativeRoot: string | ||
relativeRoot: string, | ||
protected minecraftVersion: string, | ||
protected forgeVersion: string | ||
) { | ||
super(absoluteRoot, relativeRoot) | ||
this.repoStructure = new RepoStructure(absoluteRoot, relativeRoot) | ||
} | ||
|
||
public abstract getModule(): Promise<Module> | ||
|
||
} |
Oops, something went wrong.