mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-02 08:39:49 +01:00
Merge pull request #473 from Glitchfinder/master
Alleviating hangtime on world save
This commit is contained in:
commit
91670d3945
@ -32,7 +32,9 @@ public class HashChunkManager implements ChunkManager {
|
||||
private List<Entity> spawnedMobs = new ArrayList<Entity>();
|
||||
private List<Entity> spawnedPets = new ArrayList<Entity>();
|
||||
private List<Entity> mobsToRemove = new ArrayList<Entity>();
|
||||
private List<String> savedChunks = new ArrayList<String>();
|
||||
private boolean safeToRemoveMobs = true;
|
||||
private boolean savingWorld = false;
|
||||
|
||||
@Override
|
||||
public synchronized void closeAll() {
|
||||
@ -219,6 +221,9 @@ public class HashChunkManager implements ChunkManager {
|
||||
if (world == null)
|
||||
return;
|
||||
|
||||
if(savingWorld && savedChunks.contains(world.getName() + "," + cx + "," + cz))
|
||||
return;
|
||||
|
||||
boolean unloaded = false;
|
||||
if (!store.containsKey(world.getName() + "," + cx + "," + cz)) {
|
||||
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
||||
@ -273,6 +278,9 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
writeChunkStore(world, cx, cz, out);
|
||||
}
|
||||
|
||||
if(savingWorld)
|
||||
savedChunks.add(world.getName() + "," + cx + "," + cz);
|
||||
}
|
||||
|
||||
private boolean isEntityInChunk(Entity entity, int cx, int cz, World world) {
|
||||
@ -317,6 +325,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
closeAll();
|
||||
String worldName = world.getName();
|
||||
savingWorld = true;
|
||||
|
||||
List<String> keys = new ArrayList<String>(store.keySet());
|
||||
for (String key : keys) {
|
||||
@ -361,6 +370,9 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
saveChunk(cx, cz, world);
|
||||
}
|
||||
|
||||
savingWorld = false;
|
||||
savedChunks.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -370,6 +382,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
closeAll();
|
||||
String worldName = world.getName();
|
||||
savingWorld = true;
|
||||
|
||||
List<String> keys = new ArrayList<String>(store.keySet());
|
||||
for (String key : keys) {
|
||||
@ -422,6 +435,8 @@ public class HashChunkManager implements ChunkManager {
|
||||
spawnedMobs.remove(mobsToRemove);
|
||||
spawnedPets.remove(mobsToRemove);
|
||||
mobsToRemove.clear();
|
||||
savingWorld = false;
|
||||
savedChunks.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user