From 248f14971e6ad1888756ba87d5a2ef5bf5f80d99 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Thu, 20 Jun 2013 04:47:16 -0400 Subject: [PATCH] Fixed Empty Dungeon Guide Bug Fixed the bug that caused "How_to_add_dungeons.txt" to be copied as an empty file. The reason was very subtle. Also moved the file to a different directory. --- .../mod_pocketDim/helpers/DungeonHelper.java | 2 +- StevenDimDoors/mod_pocketDim/helpers/copyfile.java | 12 ++++++------ .../mods/DimDoors/{ => text}/How_to_add_dungeons.txt | 0 3 files changed, 7 insertions(+), 7 deletions(-) rename resources/mods/DimDoors/{ => text}/How_to_add_dungeons.txt (100%) diff --git a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java index b4e411c0..f833e11c 100644 --- a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java +++ b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java @@ -112,7 +112,7 @@ public class DungeonHelper File file = new File(properties.CustomSchematicDirectory); if (file.exists() || file.mkdir()) { - copyfile.copyFile("/mods/DimDoors/How_to_add_dungeons.txt", file.getAbsolutePath() + "/How_to_add_dungeons.txt"); + copyfile.copyFile("/mods/DimDoors/text/How_to_add_dungeons.txt", file.getAbsolutePath() + "/How_to_add_dungeons.txt"); } registerFlipBlocks(); importCustomDungeons(properties.CustomSchematicDirectory); diff --git a/StevenDimDoors/mod_pocketDim/helpers/copyfile.java b/StevenDimDoors/mod_pocketDim/helpers/copyfile.java index 8af1ad39..ddcfc0aa 100644 --- a/StevenDimDoors/mod_pocketDim/helpers/copyfile.java +++ b/StevenDimDoors/mod_pocketDim/helpers/copyfile.java @@ -12,10 +12,10 @@ public class copyfile { try { - System.out.println("DIMDOORS COPYING FILE TIME"); - System.out.println("src: " + ori); - System.out.println("dest: " + dest); - InputStream in = (mod_pocketDim.class.getClass().getResourceAsStream(ori)); + //Note: For this to work properly, you must use getClass() on an instance of the class, + //not on the value obtained from .class. That was what caused this code to fail before. + //SchematicLoader didn't have this problem because we used instances of it. + InputStream in = mod_pocketDim.instance.getClass().getResourceAsStream(ori); OutputStream out = new FileOutputStream(dest); byte[] buf = new byte[1024]; int len; @@ -25,9 +25,9 @@ public class copyfile in.close(); out.close(); } - catch(Exception e) + catch (Exception e) { - e.printStackTrace(); + System.out.println("Unable to get resource: " + ori); return false; } return true; diff --git a/resources/mods/DimDoors/How_to_add_dungeons.txt b/resources/mods/DimDoors/text/How_to_add_dungeons.txt similarity index 100% rename from resources/mods/DimDoors/How_to_add_dungeons.txt rename to resources/mods/DimDoors/text/How_to_add_dungeons.txt