diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java index 879410d75d..679d7257c5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java @@ -97,10 +97,15 @@ protected InputStream getInputStream(String name, String worldName) throws IOExc for (Enumeration e = zip.entries(); e.hasMoreElements(); ) { ZipEntry testEntry = e.nextElement(); // Check for world - if (worldPattern.matcher(testEntry.getName()).matches()) { + String entryName = testEntry.getName(); + if (worldPattern.matcher(entryName).matches()) { // Check for file - if (pattern.matcher(testEntry.getName()).matches()) { - folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/')); + if (pattern.matcher(entryName).matches()) { + int endIndex = entryName.lastIndexOf('/'); + if (endIndex < 0) { + endIndex = entryName.lastIndexOf('\\'); + } + folder = entryName.substring(0, endIndex); if (folder.endsWith("poi")) { continue; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java index 4b0272be0e..030004ee3a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java @@ -81,12 +81,18 @@ protected InputStream getInputStream(String name, String worldName) throws IOExc } } else { Pattern pattern = Pattern.compile(".*\\.mc[ra]$"); + Pattern worldPattern = Pattern.compile(worldName + "[\\\\/].*"); for (Enumeration e = zip.entries(); e.hasMoreElements(); ) { ZipEntry testEntry = e.nextElement(); // Check for world - if (testEntry.getName().startsWith(worldName + "/")) { - if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca - folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/')); + String entryName = testEntry.getName(); + if (worldPattern.matcher(entryName).matches()) { + if (pattern.matcher(entryName).matches()) { // does entry end in .mca + int endIndex = entryName.lastIndexOf('/'); + if (endIndex < 0) { + endIndex = entryName.lastIndexOf('\\'); + } + folder = entryName.substring(0, endIndex); if (folder.endsWith("poi")) { continue; }