complete rename and init builder options
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { world } from "@minecraft/server";
|
||||
import { BuilderOption } from "./BuilderOption";
|
||||
|
||||
export class BuilderOptions {
|
||||
playerId = void 0;
|
||||
options = {};
|
||||
|
||||
constructor(playerId) {
|
||||
this.playerId = playerId;
|
||||
this.loadOptions();
|
||||
}
|
||||
|
||||
loadOptions() {
|
||||
const optionDPs = world.getDynamicPropertyIds().filter((id) => id.startsWith(`builderOptions:${this.playerId}:`));
|
||||
for (const optionDP of optionDPs)
|
||||
new BuilderOption(JSON.parse(world.getDynamicProperty(optionDP)));
|
||||
}
|
||||
|
||||
add(builderOption) {
|
||||
this.options[builderOption.identifer] = builderOption;
|
||||
}
|
||||
|
||||
get(id) {
|
||||
return this.options[id];
|
||||
}
|
||||
|
||||
getValue(id) {
|
||||
return this.options[id].getValue();
|
||||
}
|
||||
|
||||
setValue(id, value) {
|
||||
return this.options[id].setValue(value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user