From 63be7fefc10222d00ea66fc23068d922abffed40 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Sun, 16 Jun 2013 10:54:03 -0400 Subject: [PATCH] Tweaked Dungeon Tutorial Copy Code Tweaked the code that copies the dungeon export tutorial. I'm not sure it worked all the time before. It didn't seem quite right. I've confirmed it's working better now. Also cleaned up copyfile a little. --- .../mod_pocketDim/helpers/DungeonHelper.java | 7 ++---- .../mod_pocketDim/helpers/copyfile.java | 24 +++++++------------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java index b05ed70f..af664695 100644 --- a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java +++ b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java @@ -107,13 +107,10 @@ public class DungeonHelper private void initializeDungeons() { File file = new File(properties.CustomSchematicDirectory); - String helpFile = "/mods/DimDoors/How_to_add_dungeons.txt"; - if (new File(helpFile).exists()) + if (file.exists() || file.mkdir()) { - copyfile.copyFile(helpFile, file + "/How_to_add_dungeons.txt"); + copyfile.copyFile("/mods/DimDoors/How_to_add_dungeons.txt", file.getAbsolutePath() + "/How_to_add_dungeons.txt"); } - file.mkdir(); - registerFlipBlocks(); importCustomDungeons(properties.CustomSchematicDirectory); registerBaseDungeons(); diff --git a/StevenDimDoors/mod_pocketDim/helpers/copyfile.java b/StevenDimDoors/mod_pocketDim/helpers/copyfile.java index e83e7bb8..32e05340 100644 --- a/StevenDimDoors/mod_pocketDim/helpers/copyfile.java +++ b/StevenDimDoors/mod_pocketDim/helpers/copyfile.java @@ -1,6 +1,5 @@ package StevenDimDoors.mod_pocketDim.helpers; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; @@ -9,29 +8,24 @@ import StevenDimDoors.mod_pocketDim.mod_pocketDim; public class copyfile { - - public static boolean copyFile(String ori, String dest) { try { - InputStream in = (mod_pocketDim.class.getClass().getResourceAsStream(ori)); - OutputStream out = new FileOutputStream(dest); - byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } - in.close(); - out.close(); + InputStream in = (mod_pocketDim.class.getClass().getResourceAsStream(ori)); + OutputStream out = new FileOutputStream(dest); + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + in.close(); + out.close(); } catch(Exception e) { - //e.printStackTrace(); return false; } return true; } - - } \ No newline at end of file