configure for regolith

This commit is contained in:
ForestOfLight
2025-07-02 20:02:17 -07:00
Unverified
parent b92cdd269c
commit 657467f49d
69 changed files with 29 additions and 1 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);
}
}