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:
parent
c4e9d417b3
commit
499dbd269a
@ -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);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user