From da7a12bc008e14cf7a7679ad66659dcac9f0fa66 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 29 Aug 2016 16:21:14 +1000 Subject: [PATCH] Fixes #1234 --- .../plot/commands/Template.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Template.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Template.java index e564cc961..91014ac33 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -51,13 +51,18 @@ public class Template extends SubCommand { ZipEntry ze = zis.getNextEntry(); byte[] buffer = new byte[2048]; while (ze != null) { - String name = ze.getName().replace('\\', File.separatorChar).replace('/', File.separatorChar); - File newFile = new File((output + File.separator + name).replaceAll("__TEMP_DIR__", world)); - new File(newFile.getParent()).mkdirs(); - try (FileOutputStream fos = new FileOutputStream(newFile)) { - int len; - while ((len = zis.read(buffer)) > 0) { - fos.write(buffer, 0, len); + if (!ze.isDirectory()) { + String name = ze.getName().replace('\\', File.separatorChar).replace('/', File.separatorChar); + File newFile = new File((output + File.separator + name).replaceAll("__TEMP_DIR__", world)); + File parent = newFile.getParentFile(); + if (parent != null) { + parent.mkdirs(); + } + try (FileOutputStream fos = new FileOutputStream(newFile)) { + int len; + while ((len = zis.read(buffer)) > 0) { + fos.write(buffer, 0, len); + } } } ze = zis.getNextEntry();