diff --git a/src/plugin-host/plugin-events/event-arguments/pre-user-score-changed-event-arguments.ts b/src/plugin-host/plugin-events/event-arguments/pre-user-score-changed-event-arguments.ts index d2c50b1..00df710 100644 --- a/src/plugin-host/plugin-events/event-arguments/pre-user-score-changed-event-arguments.ts +++ b/src/plugin-host/plugin-events/event-arguments/pre-user-score-changed-event-arguments.ts @@ -26,11 +26,21 @@ export class PreUserScoreChangedEventArguments extends PluginEventArguments { public set changeInScore(newChangeInScore: number) { if (isNaN(newChangeInScore)) { console.error(`Failed to set new score change for source '${this.nameOfOriginPlugin}' for reason '${this.reason}': not a number`); - } else if (!this.immutable) { + } else if (this.isImmutable) { + console.warn(`Cannot change the value for an immutable event from source '${this.nameOfOriginPlugin}' with reason '${this.reason}'.`); + } else { this.myChangeInScore = newChangeInScore; } } + /** + * Indicates if the event is immutable. + */ + public get immutable(): boolean { + return this.isImmutable; + } + + private isImmutable = false; private myChangeInScore = 0; /** @@ -43,10 +53,11 @@ export class PreUserScoreChangedEventArguments extends PluginEventArguments { * not being caused by a plugin. * @param immutable Disallows the score delta to be changed. */ - constructor(chat: Chat, user: User, changeInScore: number, reason: string, nameOfOriginPlugin: string, private immutable: boolean) { + constructor(chat: Chat, user: User, changeInScore: number, reason: string, nameOfOriginPlugin: string, immutable: boolean) { super(nameOfOriginPlugin, reason); this.chat = chat; this.user = user; - this.changeInScore = changeInScore; + this.myChangeInScore = changeInScore; + this.isImmutable = immutable; } }