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
+25
View File
@@ -0,0 +1,25 @@
import { world } from "@minecraft/server";
export class Option {
saveToDP(namespace, id, data) {
world.setDynamicProperty(`${namespace}:${id}`, JSON.stringify(data));
}
loadFromDP(namespace, id) {
try {
const options = JSON.parse(world.getDynamicProperty(`${namespace}:${id}`));
if (options)
Object.assign(this, options);
else
throw new Error("Options not found");
} catch {
this.saveToDP(namespace, id, {});
const options = JSON.parse(world.getDynamicProperty(`${namespace}:${id}`) || "{}");
Object.assign(this, options);
}
}
clearDP(namespace, id) {
world.setDynamicProperty(`${namespace}:${id}`, void 0);
}
}