From f6388102f95d88f46d139aac64a766b7a32a87e0 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Fri, 29 Mar 2013 19:18:58 -0500 Subject: [PATCH] Changed method for finding region folder (used by Fill and Trim) to hopefully support custom world types such as Twilight Forest and Mystcraft... untested, but hopefully working --- src/com/wimbli/WorldBorder/WorldFileData.java | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/com/wimbli/WorldBorder/WorldFileData.java b/src/com/wimbli/WorldBorder/WorldFileData.java index b397ccd..b667f3e 100644 --- a/src/com/wimbli/WorldBorder/WorldFileData.java +++ b/src/com/wimbli/WorldBorder/WorldFileData.java @@ -34,17 +34,21 @@ public class WorldFileData newData.regionFolder = new File(newData.world.getWorldFolder(), "region"); if (!newData.regionFolder.exists() || !newData.regionFolder.isDirectory()) { - String mainRegionFolder = newData.regionFolder.getPath(); - newData.regionFolder = new File(newData.world.getWorldFolder(), "DIM-1"+File.separator+"region"); // nether worlds + // check for region folder inside a DIM* folder (DIM-1 for nether, DIM1 for end, DIMwhatever for custom world types) + File[] possibleDimFolders = newData.world.getWorldFolder().listFiles(new DimFolderFileFilter()); + for (int i = 0; i < possibleDimFolders.length; i++) + { + File possible = new File(newData.world.getWorldFolder(), possibleDimFolders[i].getName()+File.separator+"region"); + if (possible.exists() && possible.isDirectory()) + { + newData.regionFolder = possible; + continue; + } + } if (!newData.regionFolder.exists() || !newData.regionFolder.isDirectory()) { - String subRegionFolder = newData.regionFolder.getPath(); - newData.regionFolder = new File(newData.world.getWorldFolder(), "DIM1"+File.separator+"region"); // "the end" worlds; not sure why "DIM1" vs "DIM-1", but that's how it is - if (!newData.regionFolder.exists() || !newData.regionFolder.isDirectory()) - { - newData.sendMessage("Could not validate folder for world's region files. Looked in: "+mainRegionFolder+" -and- "+subRegionFolder+" -and- "+newData.regionFolder.getPath()); - return null; - } + newData.sendMessage("Could not validate folder for world's region files. Looked in "+newData.world.getWorldFolder().getPath()+" for valid DIM* folder with a region folder in it."); + return null; } } @@ -240,6 +244,19 @@ public class WorldFileData } } + // file filter used for DIM* folders (for nether, End, and custom world types) + private static class DimFolderFileFilter implements FileFilter + { + @Override + public boolean accept(File file) + { + return ( + file.exists() + && file.isDirectory() + && file.getName().toLowerCase().startsWith("dim") + ); + } + } // crude chunk map PNG image output, for debugging