complete rename and init builder options

This commit is contained in:
ForestOfLight
2025-04-19 17:55:28 -07:00
Unverified
parent 818f2d0183
commit d6c9acdaab
33 changed files with 297 additions and 183 deletions
@@ -0,0 +1,53 @@
import { BuilderOptions } from "./BuilderOptions";
import { Option } from "../Option";
export class BuilderOption extends Option {
playerId;
identifier;
displayName;
description;
value;
#onEnable;
#onDisable;
#DP_NAMESPACE = "builderOptions";
constructor({ player, identifier, displayName, description, howToUse, onEnableCallback = () => {}, onDisableCallback = () => {} }) {
this.playerId = player.id;
this.identifier = identifier;
this.displayName = displayName;
this.description = description;
this.howToUse = howToUse;
this.#onEnable = onEnableCallback;
this.#onDisable = onDisableCallback;
BuilderOptions.add(this);
}
save() {
this.saveToDP(this.#DP_NAMESPACE, `${this.playerId}:${this.identifier}`, this);
}
load() {
this.loadFromDP(this.#DP_NAMESPACE, `${this.playerId}:${this.identifier}`);
this.value = this.value ?? false;
}
clear() {
this.clearDP(this.#DP_NAMESPACE, `${this.playerId}:${this.identifier}`);
}
getValue() {
return this.value;
}
setValue(value) {
if (value)
this.#onEnable();
else
this.#onDisable();
if (this.value !== value) {
this.value = value;
return value;
}
return void 0;
}
}