Compensate for lack of mod id in litemod claritas resolution.

More tweaks to Claritas.
This commit is contained in:
Daniel Scalzi
2020-07-15 09:04:09 -04:00
parent bda96eb24e
commit ea23912a85
3 changed files with 24 additions and 1 deletions

Binary file not shown.

View File

@@ -8,6 +8,7 @@ import { LiteMod } from '../../../liteloader/litemod'
import { ToggleableModuleStructure } from './toggleablemodule.struct'
import { MinecraftVersion } from '../../../../util/MinecraftVersion'
import { LibraryType } from '../../../claritas/ClaritasLibraryType'
import { MetadataUtil } from '../../../../util/MetadataUtil'
export class LiteModStructure extends ToggleableModuleStructure {
@@ -28,7 +29,8 @@ export class LiteModStructure extends ToggleableModuleStructure {
protected async getModuleId(name: string, path: string): Promise<string> {
const liteModData = await this.getLiteModMetadata(name, path)
return this.generateMavenIdentifier(this.getClaritasGroup(path), liteModData.name, `${liteModData.version}-${liteModData.mcversion}`)
return this.generateMavenIdentifier(
MetadataUtil.completeGroupInference(this.getClaritasGroup(path), liteModData.name), liteModData.name, `${liteModData.version}-${liteModData.mcversion}`)
}
protected async getModuleName(name: string, path: string): Promise<string> {
return capitalize((await this.getLiteModMetadata(name, path)).name)

21
src/util/MetadataUtil.ts Normal file
View File

@@ -0,0 +1,21 @@
export class MetadataUtil {
public static completeGroupInference(partial: string, id: string): string {
const bits = partial.split('.')
let isBadTerm = true
while(isBadTerm && bits.length > 2) {
const term = bits[bits.length-1]
if(term !== id) {
isBadTerm = false
} else {
bits.pop()
}
}
return bits.join('.')
}
}