Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added libs/commons-codec-1.13.jar
Binary file not shown.
Binary file removed libs/paperspigot.jar
Binary file not shown.
Binary file added libs/paperspigot_1.14.4.jar
Binary file not shown.
12 changes: 10 additions & 2 deletions src/autosaveworld/features/save/AutoSaveThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,16 @@ private void dumpRegionCache(World world) {
if (world.isAutoSave()) {
try {
Object worldserver = getNMSWorld(world);
// invoke saveLevel method which waits for all chunks to save and than dumps RegionFileCache
ReflectionUtils.getMethod(worldserver.getClass(), NMSNames.getSaveLevelMethodName(), 0).invoke(worldserver);
// Navigate to the RegionFileCache class
Object chunkprovider = ReflectionUtils.getMethod(worldserver.getClass(), "getChunkProvider", 0).invoke(worldserver);
Object playerchunkmap = ReflectionUtils.getField(chunkprovider.getClass(), "playerChunkMap").get(chunkprovider);
Object cache = ReflectionUtils.getField(playerchunkmap.getClass(), "cache").get(playerchunkmap);

// Waits for all chunks to save and then dumps RegionFileCache
while ((int) ReflectionUtils.getMethod(cache.getClass(), "size", 0).invoke(cache) > 0) {
Object popped = ReflectionUtils.getMethod(cache.getClass(), "removeLast", 0).invoke(cache);
ReflectionUtils.getMethod(popped.getClass(), "close", 0).invoke(popped);
}
} catch (Exception e) {
MessageLogger.exception("Could not dump RegionFileCache", e);
}
Expand Down