Changed DungeonHelper into a singleton
Changed DungeonHelper into a singleton. Changed code in other classes to interface with it properly.
This commit is contained in:
@@ -25,6 +25,7 @@ import StevenDimDoors.mod_pocketDim.helpers.jnbt.Tag;
|
||||
|
||||
public class DungeonHelper
|
||||
{
|
||||
private static DungeonHelper instance = null;
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public static final Pattern NamePattern = Pattern.compile("[A-Za-z0-9_]+");
|
||||
@@ -76,7 +77,7 @@ public class DungeonHelper
|
||||
private HashSet<String> dungeonTypeChecker;
|
||||
private Hashtable<String, ArrayList<DungeonGenerator>> dungeonTypeMapping;
|
||||
|
||||
public DungeonHelper()
|
||||
private DungeonHelper()
|
||||
{
|
||||
//Load the dungeon type checker with the list of all types in lowercase.
|
||||
//Capitalization matters for matching in a hash set.
|
||||
@@ -100,6 +101,27 @@ public class DungeonHelper
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
public static DungeonHelper create()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = new DungeonHelper();
|
||||
else
|
||||
throw new IllegalStateException("Cannot create DungeonHelper twice");
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static DungeonHelper instance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
//This is to prevent some frustrating bugs that could arise when classes
|
||||
//are loaded in the wrong order. Trust me, I had to squash a few...
|
||||
throw new IllegalStateException("Instance of DungeonHelper requested before creation");
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean validateSchematicName(String name)
|
||||
{
|
||||
String[] dungeonData = name.split("_");
|
||||
|
||||
@@ -978,7 +978,7 @@ public class dimHelper extends DimensionManager
|
||||
|
||||
if(isRandomRift)
|
||||
{
|
||||
mod_pocketDim.dungeonHelper.generateDungeonlink(link);
|
||||
DungeonHelper.instance().generateDungeonlink(link);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user