Skip to content

Commit 8929be7

Browse files
authored
Merge pull request #161 from pylonmc/maybe-fix-autosaving
Maybe fix autosaving
2 parents 322f81f + 1165440 commit 8929be7

2 files changed

Lines changed: 10 additions & 14 deletions

File tree

pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/BlockStorage.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,13 @@ object BlockStorage : Listener {
342342
// Wait a random delay before starting, this is to help smooth out lag from saving
343343
delay(Random.nextLong(PylonConfig.entityDataAutosaveIntervalSeconds * 1000))
344344

345-
chunkAutosaveTasks[event.chunk.position] = PylonCore.launch(PylonCore.minecraftDispatcher) {
346-
while (true) {
347-
lockBlockRead {
348-
val blocksInChunk = blocksByChunk[event.chunk.position]
349-
check(blocksInChunk != null) { "Block autosave task was not cancelled properly" }
350-
save(event.chunk, blocksInChunk)
351-
}
352-
delay(PylonConfig.entityDataAutosaveIntervalSeconds * 1000)
345+
while (true) {
346+
lockBlockRead {
347+
val blocksInChunk = blocksByChunk[event.chunk.position]
348+
check(blocksInChunk != null) { "Block autosave task was not cancelled properly" }
349+
save(event.chunk, blocksInChunk)
353350
}
351+
delay(PylonConfig.entityDataAutosaveIntervalSeconds * 1000)
354352
}
355353
}
356354
}

pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/entity/EntityStorage.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,11 @@ object EntityStorage : Listener {
136136
// Wait a random delay before starting, this is to help smooth out lag from saving
137137
delay(Random.nextLong(PylonConfig.entityDataAutosaveIntervalSeconds * 1000))
138138

139-
entityAutosaveTasks[entity.uuid] = PylonCore.launch(PylonCore.minecraftDispatcher) {
140-
while (true) {
141-
lockEntityRead {
142-
entity.write(entity.entity.persistentDataContainer)
143-
}
144-
delay(PylonConfig.entityDataAutosaveIntervalSeconds * 1000)
139+
while (true) {
140+
lockEntityRead {
141+
entity.write(entity.entity.persistentDataContainer)
145142
}
143+
delay(PylonConfig.entityDataAutosaveIntervalSeconds * 1000)
146144
}
147145
}
148146
entity

0 commit comments

Comments
 (0)