Finished ResetCommand, first pass on blackList

This commit is contained in:
StevenRS11
2013-10-03 23:44:50 -04:00
parent 69864ea9ad
commit e421987338
3 changed files with 29 additions and 29 deletions

View File

@@ -36,20 +36,15 @@ public class CommandResetDungeons extends DDCommandBase
int dungeonCount = 0; int dungeonCount = 0;
int resetCount = 0; int resetCount = 0;
ArrayList<Integer> dimIdsToDelete= new ArrayList<Integer>(); ArrayList<Integer> dimsToDelete = new ArrayList<Integer>();
for (NewDimData data : PocketManager.getDimensions()) for (NewDimData data : PocketManager.getDimensions())
{ {
dungeonCount++; dungeonCount++;
if(DimensionManager.getWorld(data.id())==null) if(DimensionManager.getWorld(data.id())==null&&data.isDungeon())
{ {
if (data.isDungeon()) dimsToDelete.add(data.id());
{
PocketManager.deleteDimensionFolder(data);
dimIdsToDelete.add(data.id());
} }
} else if(data.isDungeon())
else
{ {
for(DimLink link : data.links()) for(DimLink link : data.links())
{ {
@@ -64,7 +59,11 @@ public class CommandResetDungeons extends DDCommandBase
} }
} }
} }
resetCount = PocketManager.deleteDimensionData(dimIdsToDelete); for(Integer dimID:dimsToDelete)
{
PocketManager.deletePocket(PocketManager.getDimensionData(dimID), true);
}
//TODO implement blackList //TODO implement blackList
//Notify the user of the results //Notify the user of the results

View File

@@ -470,12 +470,17 @@ public class DDTeleporter
private static boolean initializeDestination(DimLink link, DDProperties properties, Block door) private static boolean initializeDestination(DimLink link, DDProperties properties, Block door)
{ {
//TODO implement blackList
if (link.hasDestination()) if (link.hasDestination())
{
if(PocketManager.isBlackListed(link.destination().getDimension()))
{
link=PocketManager.getDimensionData(link.source().getDimension()).createLink(link.source,LinkTypes.SAFE_EXIT,link.orientation);
}
else
{ {
return true; return true;
} }
}
// Check the destination type and respond accordingly // Check the destination type and respond accordingly
switch (link.linkType()) switch (link.linkType())

View File

@@ -148,6 +148,8 @@ public class PocketManager
//HashMap that maps all the dimension IDs registered with DimDoors to their DD data. //HashMap that maps all the dimension IDs registered with DimDoors to their DD data.
private static HashMap<Integer, InnerDimData> dimensionData = null; private static HashMap<Integer, InnerDimData> dimensionData = null;
//ArrayList that stores the dimension IDs of any dimension that has been deleted.
private static ArrayList<Integer> dimensionIDBlackList = null;
public static boolean isLoaded() public static boolean isLoaded()
{ {
@@ -172,6 +174,7 @@ public class PocketManager
isLoading = true; isLoading = true;
dimensionData = new HashMap<Integer, InnerDimData>(); dimensionData = new HashMap<Integer, InnerDimData>();
rootDimensions = new ArrayList<NewDimData>(); rootDimensions = new ArrayList<NewDimData>();
dimensionIDBlackList = new ArrayList<Integer>();
//Register Limbo //Register Limbo
DDProperties properties = DDProperties.instance(); DDProperties properties = DDProperties.instance();
@@ -197,12 +200,13 @@ public class PocketManager
{ {
deleteDimensionFolder(target); deleteDimensionFolder(target);
} }
dimensionIDBlackList.add(dimension.id);
deleteDimensionData(dimension.id); deleteDimensionData(dimension.id);
return true; return true;
} }
return false; return false;
} }
public static boolean deleteDimensionFolder(NewDimData target) private static boolean deleteDimensionFolder(NewDimData target)
{ {
InnerDimData dimension = (InnerDimData) target; InnerDimData dimension = (InnerDimData) target;
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null) if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
@@ -213,7 +217,7 @@ public class PocketManager
} }
return false; return false;
} }
public static boolean deleteDimensionData(int dimensionID) private static boolean deleteDimensionData(int dimensionID)
{ {
if(dimensionData.containsKey(dimensionID)&& DimensionManager.getWorld(dimensionID) == null) if(dimensionData.containsKey(dimensionID)&& DimensionManager.getWorld(dimensionID) == null)
{ {
@@ -229,18 +233,6 @@ public class PocketManager
return false; return false;
} }
public static int deleteDimensionData(ArrayList<Integer> dimensions)
{
int deletedCount=0;
for(int dimID : dimensions)
{
if(deleteDimensionData(dimID))
{
deletedCount++;
}
}
return deletedCount;
}
private static void registerPockets(DDProperties properties) private static void registerPockets(DDProperties properties)
{ {
for (NewDimData dimension : dimensionData.values()) for (NewDimData dimension : dimensionData.values())
@@ -377,7 +369,7 @@ public class PocketManager
{ {
throw new IllegalArgumentException("Cannot register a dimension with ID = " + dimensionID + " because it has already been registered."); throw new IllegalArgumentException("Cannot register a dimension with ID = " + dimensionID + " because it has already been registered.");
} }
//TODO blacklist stuff probably should happen here
InnerDimData dimension = new InnerDimData(dimensionID, parent, isPocket, isDungeon, linkWatcher); InnerDimData dimension = new InnerDimData(dimensionID, parent, isPocket, isDungeon, linkWatcher);
dimensionData.put(dimensionID, dimension); dimensionData.put(dimensionID, dimension);
if (!dimension.isPocketDimension()) if (!dimension.isPocketDimension())
@@ -485,6 +477,10 @@ public class PocketManager
} }
} }
public static boolean isBlackListed(int dimensionID)
{
return PocketManager.dimensionIDBlackList.contains(dimensionID);
}
public static void registerDimWatcher(IUpdateWatcher<ClientDimData> watcher) public static void registerDimWatcher(IUpdateWatcher<ClientDimData> watcher)
{ {
dimWatcher.registerReceiver(watcher); dimWatcher.registerReceiver(watcher);