Improved Rift Gateway Generation and Fixed Several Bugs #26

Merged
SenseiKiwi merged 7 commits from master into master 2013-06-17 21:16:09 +00:00
Showing only changes of commit 30960acffa - Show all commits

View File

@@ -4,6 +4,7 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Random; import java.util.Random;
@@ -217,16 +218,19 @@ public class DungeonHelper
} }
} }
public void importCustomDungeons(String dir) public void importCustomDungeons(String path)
{ {
File file = new File(dir); File directory = new File(path);
File[] schematicNames = file.listFiles(); File[] schematicNames = directory.listFiles();
if (schematicNames != null) if (schematicNames != null)
{ {
for (File schematicFile: schematicNames) for (File schematicFile: schematicNames)
{ {
this.registerCustomDungeon(schematicFile); if (schematicFile.getName().endsWith(SCHEMATIC_FILE_EXTENSION))
{
registerCustomDungeon(schematicFile);
}
} }
} }
} }
@@ -660,13 +664,18 @@ public class DungeonHelper
} }
public Collection<String> getDungeonNames() { public Collection<String> getDungeonNames() {
//Use a HashSet to guarantee that all dungeon names will be distinct. //Use a HashSet to guarantee that all dungeon names will be distinct.
//This shouldn't be necessary if we keep proper lists without repetitions, //This shouldn't be necessary if we keep proper lists without repetitions,
//but it's a fool-proof workaround. //but it's a fool-proof workaround.
HashSet<String> dungeonNames = new HashSet<String>(); HashSet<String> dungeonNames = new HashSet<String>();
dungeonNames.addAll( parseDungeonNames(registeredDungeons) ); dungeonNames.addAll( parseDungeonNames(registeredDungeons) );
dungeonNames.addAll( parseDungeonNames(customDungeons) ); dungeonNames.addAll( parseDungeonNames(customDungeons) );
return dungeonNames;
//Sort dungeon names alphabetically
ArrayList<String> sortedNames = new ArrayList<String>(dungeonNames);
Collections.sort(sortedNames);
return sortedNames;
} }
private static ArrayList<String> parseDungeonNames(ArrayList<DungeonGenerator> dungeons) private static ArrayList<String> parseDungeonNames(ArrayList<DungeonGenerator> dungeons)