Skip to content

Commit

Permalink
Add boolean to check if changes to the mod configuration have been made
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchangelWTF committed Oct 19, 2024
1 parent bce945c commit cc8b3f0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/controllers/FikaClientController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { FikaConfig } from "../utils/FikaConfig";
export class FikaClientController {
protected requiredMods: Set<string>;
protected allowedMods: Set<string>;
protected hasRequiredorOptionalMods: boolean = true;

constructor(
@inject("FikaClientModHashesHelper") protected fikaClientModHashesHelper: FikaClientModHashesHelper,
Expand All @@ -27,6 +28,10 @@ export class FikaClientController {
const sanitizedRequiredMods = this.filterEmptyMods(config.client.mods.required);
const sanitizedOptionalMods = this.filterEmptyMods(config.client.mods.optional);

if (sanitizedRequiredMods.length === 0 && sanitizedRequiredMods.length === 0) {
this.hasRequiredorOptionalMods = false;
}

this.requiredMods = new Set([...sanitizedRequiredMods, "com.fika.core", "com.SPT.custom", "com.SPT.singleplayer", "com.SPT.core", "com.SPT.debugging"]);
this.allowedMods = new Set([...this.requiredMods, ...sanitizedOptionalMods, "com.bepis.bepinex.configurationmanager"]);
}
Expand All @@ -53,16 +58,14 @@ export class FikaClientController {
* Handle /fika/client/check/mods
*/
public handleCheckMods(request: IFikaCheckModRequestData): IFikaCheckModResponse {
const config = this.fikaConfig.getConfig();

const mismatchedMods: IFikaCheckModResponse = {
forbidden: [],
missingRequired: [],
hashMismatch: [],
};

// if no configuration was made, allow all mods
if (config.client.mods.required.length === 0 && config.client.mods.optional.length === 0) {
if (!this.hasRequiredorOptionalMods) {
return mismatchedMods;
}

Expand Down

0 comments on commit cc8b3f0

Please sign in to comment.