|
@@ -8,6 +8,7 @@ import java.io.ObjectOutputStream;
|
|
|
import java.lang.Boolean;
|
|
|
import java.lang.Integer;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
@@ -161,12 +162,13 @@ public class HashChunkManager implements ChunkManager {
|
|
|
|
|
|
UUID key = world.getUID();
|
|
|
boolean oldDataHasKey = oldData.containsKey(key);
|
|
|
+ boolean converted = false;
|
|
|
|
|
|
if (!oldDataHasKey) {
|
|
|
oldData.put(key, (new File(world.getWorldFolder(), "mcmmo_data")).exists());
|
|
|
}
|
|
|
else if (oldData.get(key)) {
|
|
|
- convertChunk(new File(world.getWorldFolder(), "mcmmo_data"), cx, cz, world, true);
|
|
|
+ converted = convertChunk(new File(world.getWorldFolder(), "mcmmo_data"), cx, cz, world, true);
|
|
|
}
|
|
|
|
|
|
try {
|
|
@@ -174,31 +176,32 @@ public class HashChunkManager implements ChunkManager {
|
|
|
}
|
|
|
catch(Exception e) {}
|
|
|
|
|
|
- if (in != null) {
|
|
|
- store.put(world.getName() + "," + cx + "," + cz, in);
|
|
|
+ if (in == null || converted)
|
|
|
+ return;
|
|
|
|
|
|
- List<UUID> mobs = in.getSpawnedMobs();
|
|
|
+ store.put(world.getName() + "," + cx + "," + cz, in);
|
|
|
|
|
|
- if (mobs.isEmpty())
|
|
|
- return;
|
|
|
+ List<UUID> mobs = in.getSpawnedMobs();
|
|
|
|
|
|
- iteratingMobs = true;
|
|
|
+ if (mobs.isEmpty())
|
|
|
+ return;
|
|
|
|
|
|
- for (LivingEntity entity : world.getLivingEntities()) {
|
|
|
- if (mobs.contains(entity.getUniqueId()))
|
|
|
- addSpawnedMob(entity);
|
|
|
- }
|
|
|
+ iteratingMobs = true;
|
|
|
|
|
|
- for(FallingBlock entity: world.getEntitiesByClass(FallingBlock.class)) {
|
|
|
- if (mobs.contains(entity.getUniqueId()))
|
|
|
- addSpawnedMob(entity);
|
|
|
- }
|
|
|
+ List<Entity> chunkMobs = new ArrayList(Arrays.asList(world.getChunkAt(cx, cz).getEntities()));
|
|
|
|
|
|
- if(safeToRemoveMobs)
|
|
|
- iteratingMobs = false;
|
|
|
+ for (Entity entity : chunkMobs) {
|
|
|
+ if(!(entity instanceof LivingEntity) && !(entity instanceof FallingBlock))
|
|
|
+ continue;
|
|
|
|
|
|
- in.clearSpawnedMobs();
|
|
|
+ if (mobs.contains(entity.getUniqueId()))
|
|
|
+ addSpawnedMob(entity);
|
|
|
}
|
|
|
+
|
|
|
+ if(safeToRemoveMobs)
|
|
|
+ iteratingMobs = false;
|
|
|
+
|
|
|
+ in.clearSpawnedMobs();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -546,14 +549,14 @@ public class HashChunkManager implements ChunkManager {
|
|
|
convertChunk(dataDir, cx, cz, world, false);
|
|
|
}
|
|
|
|
|
|
- public synchronized void convertChunk(File dataDir, int cx, int cz, World world, boolean actually) {
|
|
|
+ public synchronized boolean convertChunk(File dataDir, int cx, int cz, World world, boolean actually) {
|
|
|
if (!actually)
|
|
|
- return;
|
|
|
- if (!dataDir.exists()) return;
|
|
|
+ return false;
|
|
|
+ if (!dataDir.exists()) return false;
|
|
|
File cxDir = new File(dataDir, "" + cx);
|
|
|
- if (!cxDir.exists()) return;
|
|
|
+ if (!cxDir.exists()) return false;
|
|
|
File czDir = new File(cxDir, "" + cz);
|
|
|
- if (!czDir.exists()) return;
|
|
|
+ if (!czDir.exists()) return false;
|
|
|
|
|
|
boolean conversionSet = false;
|
|
|
|
|
@@ -574,6 +577,8 @@ public class HashChunkManager implements ChunkManager {
|
|
|
converter.start(world, cxDir, czDir);
|
|
|
converters.add(converter);
|
|
|
}
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
public boolean isSpawnedMob(Entity entity) {
|