From a174ad4b29087171561bf4b6c329e95de8c87886 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Thu, 1 Aug 2013 00:05:08 -0400 Subject: [PATCH] Fixed CommandCreateDungeonRift Forgot to fix a reference to DungeonHelper in CommandCreateDungeonRift during the last commit. Made some further improvements to DungeonHelper to avoid exposing internal variables. --- .../commands/CommandCreateDungeonRift.java | 4 +- .../mod_pocketDim/helpers/DungeonHelper.java | 37 ++++++++++++------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandCreateDungeonRift.java b/StevenDimDoors/mod_pocketDim/commands/CommandCreateDungeonRift.java index ac89ef29..3259ca4a 100644 --- a/StevenDimDoors/mod_pocketDim/commands/CommandCreateDungeonRift.java +++ b/StevenDimDoors/mod_pocketDim/commands/CommandCreateDungeonRift.java @@ -69,10 +69,10 @@ public class CommandCreateDungeonRift extends DDCommandBase } else { - result = findDungeonByPartialName(command[0], dungeonHelper.registeredDungeons); + result = findDungeonByPartialName(command[0], dungeonHelper.getRegisteredDungeons()); if (result == null) { - result = findDungeonByPartialName(command[0], dungeonHelper.customDungeons); + result = findDungeonByPartialName(command[0], dungeonHelper.getUntaggedDungeons()); } //Check if we found any matches if (result != null) diff --git a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java index a91b6ebd..5d57357a 100644 --- a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java +++ b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java @@ -6,6 +6,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Random; import java.util.regex.Pattern; @@ -60,8 +61,8 @@ public class DungeonHelper private Random rand = new Random(); - public ArrayList untaggedDungeons = new ArrayList(); - public ArrayList registeredDungeons = new ArrayList(); + private ArrayList untaggedDungeons = new ArrayList(); + private ArrayList registeredDungeons = new ArrayList(); private ArrayList simpleHalls = new ArrayList(); private ArrayList complexHalls = new ArrayList(); @@ -105,17 +106,6 @@ public class DungeonHelper registerCustomDungeons(); } - private void registerCustomDungeons() - { - File file = new File(properties.CustomSchematicDirectory); - if (file.exists() || file.mkdir()) - { - copyfile.copyFile("/mods/DimDoors/text/How_to_add_dungeons.txt", file.getAbsolutePath() + "/How_to_add_dungeons.txt"); - } - importCustomDungeons(properties.CustomSchematicDirectory); - registerBaseDungeons(); - } - public static DungeonHelper initialize() { if (instance == null) @@ -141,6 +131,27 @@ public class DungeonHelper return instance; } + private void registerCustomDungeons() + { + File file = new File(properties.CustomSchematicDirectory); + if (file.exists() || file.mkdir()) + { + copyfile.copyFile("/mods/DimDoors/text/How_to_add_dungeons.txt", file.getAbsolutePath() + "/How_to_add_dungeons.txt"); + } + importCustomDungeons(properties.CustomSchematicDirectory); + registerBaseDungeons(); + } + + public List getRegisteredDungeons() + { + return Collections.unmodifiableList(this.registeredDungeons); + } + + public List getUntaggedDungeons() + { + return Collections.unmodifiableList(this.untaggedDungeons); + } + public LinkData createCustomDungeonDoor(World world, int x, int y, int z) { //Create a link above the specified position. Link to a new pocket dimension.