Finished maketree() method in Backup ?

This commit is contained in:
BuildTools 2018-09-13 13:09:00 +01:00
parent 55ea36c165
commit 7a5668b1d7

View file

@ -86,8 +86,6 @@ public class Backup
*/ */
private void maketree(List<Town> towns, List<World> worlds, Server server, File folder) throws IOException private void maketree(List<Town> towns, List<World> worlds, Server server, File folder) throws IOException
{ {
HashMap<String, HashMap<Coord, RegionChunkList>> townbranch; HashMap<String, HashMap<Coord, RegionChunkList>> townbranch;
HashMap<Coord, RegionChunkList> worldbranch; HashMap<Coord, RegionChunkList> worldbranch;
@ -97,13 +95,7 @@ public class Backup
String worldname; String worldname;
File townDir, /* TODO
worldDir,
chunksDir,
chlistDir;
/*
*
*/ */
for (Town town : towns) for (Town town : towns)
{ {
@ -120,22 +112,27 @@ public class Backup
worldname = block.getWorld().getName(); worldname = block.getWorld().getName();
worldbranch = townbranch.get(worldname); worldbranch = townbranch.get(worldname);
//convert block to chunk
x = block.getX() >> 4; x = block.getX() >> 4;
z = block.getZ() >> 4; z = block.getZ() >> 4;
coord = new Coord(x >> 5, z >> 5); coord = new Coord(x >> 5, z >> 5);
chunklist = worldbranch.get(coord); chunklist = worldbranch.get(coord);
//create if nonexistent
if (chunklist == null) if (chunklist == null)
{ {
townDir = new File(folder, town.getUID().toString()); File townDir = new File(folder, town.getUID().toString());
worldDir = new File(townDir, worldname); File worldDir = new File(townDir, worldname);
chunksDir = new File(worldDir, "region chunk lists"); File chunksDir = new File(worldDir, "region chunk lists");
chlistDir = new File(chunksDir, "r."+coord.x+"."+coord.z+".chunklist"); File chlistDir = new File(chunksDir, "r."+coord.x+"."+coord.z+".chunklist");
chunklist = new RegionChunkList(chlistDir); chunklist = new RegionChunkList(chlistDir);
worldbranch.put(coord, chunklist); worldbranch.put(coord, chunklist);
} }
//add chunk to chunk list
chunklist.storeChunk(x, z);
} }
tree.put(town.getUID(), townbranch); 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.<p> * Holds region coordinates. A region is 32x32 chunks. A chunk is 16x16 blocks.<p>
* *
* The chunk coordinates of a block are (block x >> 4, block z >> 4).<p> * The chunk coordinates of a block are (block x >> 4, block z >> 4).<p>
*
* The region coordinates of a chunk are (chunk x >> 5, chunk z >> 5).<p> * The region coordinates of a chunk are (chunk x >> 5, chunk z >> 5).<p>
*/ */
public static class Coord public static class Coord