1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-09 16:21:51 +00:00

Basic ignore of duplicate mods

Only load the mod with highest priority for now. Proper behavior would
be to keep metadata for all duplicates and load the first that isn't
disabled. This allows easy mod source switching (for example, user mods
and development mods)
This commit is contained in:
Даниїл Григор'єв 2025-04-08 03:28:01 +03:00
parent c4e9d417b3
commit 499dbd269a
No known key found for this signature in database
GPG Key ID: B890DF16341D8C1D

View File

@ -45,6 +45,12 @@ export class ModLoader {
continue;
}
// TODO: Only check this after applying disabled state
if (this.isModPresent(metadata.id)) {
console.warn(`Ignoring duplicate mod ${location.source}::${location.file}`);
continue;
}
mods.push({
...location,
disabled: false,
@ -69,6 +75,10 @@ export class ModLoader {
return [...this.mods];
}
isModPresent(id: string): boolean {
return this.mods.some(mod => mod.metadata.id === id);
}
getModById(id: string): Mod | undefined {
return this.mods.find(mod => mod.metadata.id === id);
}