(key: K, value?: PlayerPreferences[K] | null)
| 1224 | */ |
| 1225 | static preference<K extends keyof PlayerPreferences>(key: K, value: PlayerPreferences[K]): PlayerPreferences[K]; |
| 1226 | static preference<K extends keyof PlayerPreferences>(key: K, value?: PlayerPreferences[K] | null): PlayerPreferences[K] { |
| 1227 | if (value !== undefined && value !== null) { |
| 1228 | this._preferences[key] = value; |
| 1229 | this.Storage.update('Settings', this._preferences); |
| 1230 | |
| 1231 | return this._preferences[key]; |
| 1232 | } |
| 1233 | |
| 1234 | if (typeof this._preferences[key] !== 'undefined') { |
| 1235 | return this._preferences[key]; |
| 1236 | } |
| 1237 | |
| 1238 | throw new Error(`Tried to access non existent preference with name '${key}'.`); |
| 1239 | } |
| 1240 | |
| 1241 | static preferences (object: Partial<PlayerPreferences> | null = null, save = false): PlayerPreferences { |
| 1242 | if (object !== null) { |
no test coverage detected