[PCCompat] Add more funcs to SimpleStore, use wrapper for Plugin.settings

This commit is contained in:
Ducko 2021-04-07 16:34:14 +01:00 committed by フズキ
parent 638927b2ec
commit 2584ce03c5
No known key found for this signature in database
GPG Key ID: E06450E46F83376C
1 changed files with 25 additions and 1 deletions

View File

@ -101,8 +101,22 @@ class SimpleStore {
}
updateSetting = (key, value) => {
if (value === undefined) {
return this.toggleSetting(key);
}
this.store[key] = value;
}
toggleSetting = (key) => {
this.store[key] = !this.store[key];
}
deleteSetting = (key) => {
delete this.store[key];
}
getKeys = () => Object.keys(this.store)
}
export class Plugin {
@ -128,7 +142,17 @@ export class Plugin {
}
get settings() {
return settingStores[this.entityID];
const store = settingStores[this.entityID];
return { // Basic wrapper with renamed functions
get: store.getSetting,
set: store.setSetting,
delete: store.deleteSetting,
getKeys: store.getKeys,
connectStore: () => {} // Unneeded util func, but here incase it is attempted to be called
};
}
get goosemodHandlers() {