cleanup PopulationManager

This commit is contained in:
dfsek
2021-05-01 20:27:59 -07:00
parent e2a52afb67
commit fddf0c51b7
2 changed files with 8 additions and 23 deletions
@@ -1,21 +0,0 @@
package com.dfsek.terra.bukkit.population;
import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.bukkit.world.BukkitWorld;
import java.io.File;
public class Gaea {
private static boolean debug;
public static File getGaeaFolder(World w) {
File f = new File(((BukkitWorld) w).getWorldFolder(), "gaea");
f.mkdirs();
return f;
}
public static boolean isDebug() {
return debug;
}
}
@@ -33,17 +33,23 @@ public class PopulationManager extends BlockPopulator {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public synchronized void saveBlocks(World w) throws IOException { public synchronized void saveBlocks(World w) throws IOException {
File f = new File(Gaea.getGaeaFolder(w), "chunks.bin"); File f = new File(getDataFolder(w), "chunks.bin");
f.createNewFile(); f.createNewFile();
SerializationUtil.toFile((HashSet<ChunkCoordinate>) needsPop.clone(), f); SerializationUtil.toFile((HashSet<ChunkCoordinate>) needsPop.clone(), f);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public synchronized void loadBlocks(World w) throws IOException, ClassNotFoundException { public synchronized void loadBlocks(World w) throws IOException, ClassNotFoundException {
File f = new File(Gaea.getGaeaFolder(w), "chunks.bin"); File f = new File(getDataFolder(w), "chunks.bin");
needsPop.addAll((HashSet<ChunkCoordinate>) SerializationUtil.fromFile(f)); needsPop.addAll((HashSet<ChunkCoordinate>) SerializationUtil.fromFile(f));
} }
public static File getDataFolder(World w) {
File f = new File(((BukkitWorld) w).getWorldFolder(), "gaea");
f.mkdirs();
return f;
}
// Synchronize to prevent chunks from being queued for population multiple times. // Synchronize to prevent chunks from being queued for population multiple times.
public synchronized void checkNeighbors(int x, int z, World world) { public synchronized void checkNeighbors(int x, int z, World world) {