workaround offline world player saving data
This commit is contained in:
parent
ee1a2d0f68
commit
de978e0528
1 changed files with 13 additions and 5 deletions
|
|
@ -131,12 +131,20 @@ console.info = (...args) => {
|
|||
info.apply(console, args)
|
||||
}
|
||||
|
||||
window.addEventListener('unload', (e) => {
|
||||
if (window.singlePlayerServer) {
|
||||
for (const player of window.singlePlayerServer.players) {
|
||||
player.save()
|
||||
}
|
||||
const savePlayers = () => {
|
||||
if (!window.singlePlayerServer) return
|
||||
for (const player of window.singlePlayerServer.players) {
|
||||
player.save()
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
savePlayers()
|
||||
// todo investigate unload failures instead
|
||||
}, 1000)
|
||||
|
||||
window.addEventListener('unload', (e) => {
|
||||
savePlayers()
|
||||
})
|
||||
|
||||
// todo move from global state
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue