From 7a5668b1d75ca5ace526f61bc00ace4ace309648 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 13 Sep 2018 13:09:00 +0100 Subject: [PATCH] Finished maketree() method in Backup ? --- src/simpleWarBackup/Backup.java | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/simpleWarBackup/Backup.java b/src/simpleWarBackup/Backup.java index 3029160..c7f94ff 100644 --- a/src/simpleWarBackup/Backup.java +++ b/src/simpleWarBackup/Backup.java @@ -86,8 +86,6 @@ public class Backup */ private void maketree(List towns, List worlds, Server server, File folder) throws IOException { - - HashMap> townbranch; HashMap worldbranch; @@ -97,13 +95,7 @@ public class Backup String worldname; - File townDir, - worldDir, - chunksDir, - chlistDir; - - /* - * + /* TODO */ for (Town town : towns) { @@ -120,22 +112,27 @@ public class Backup worldname = block.getWorld().getName(); worldbranch = townbranch.get(worldname); + //convert block to chunk x = block.getX() >> 4; z = block.getZ() >> 4; coord = new Coord(x >> 5, z >> 5); chunklist = worldbranch.get(coord); + //create if nonexistent if (chunklist == null) { - townDir = new File(folder, town.getUID().toString()); - worldDir = new File(townDir, worldname); - chunksDir = new File(worldDir, "region chunk lists"); - chlistDir = new File(chunksDir, "r."+coord.x+"."+coord.z+".chunklist"); + File townDir = new File(folder, town.getUID().toString()); + File worldDir = new File(townDir, worldname); + File chunksDir = new File(worldDir, "region chunk lists"); + File chlistDir = new File(chunksDir, "r."+coord.x+"."+coord.z+".chunklist"); chunklist = new RegionChunkList(chlistDir); worldbranch.put(coord, chunklist); } + + //add chunk to chunk list + chunklist.storeChunk(x, z); } tree.put(town.getUID(), townbranch); @@ -148,6 +145,7 @@ public class Backup * Holds region coordinates. A region is 32x32 chunks. A chunk is 16x16 blocks.

* * The chunk coordinates of a block are (block x >> 4, block z >> 4).

+ * * The region coordinates of a chunk are (chunk x >> 5, chunk z >> 5).

*/ public static class Coord