Reviewed and Rewrote Commands #169

Merged
SenseiKiwi merged 17 commits from master into master 2014-07-06 01:59:42 +00:00
Showing only changes of commit b4a58f5c88 - Show all commits

View File

@@ -315,44 +315,43 @@ public class PocketManager
{ {
if (deleteFolder) if (deleteFolder)
{ {
deleteDimensionFiles(target); deleteDimensionFiles(dimension);
} }
dimensionIDBlackList.add(dimension.id); dimensionIDBlackList.add(dimension.id);
deleteDimensionData(dimension.id); deleteDimensionData(dimension);
return true; return true;
} }
return false; return false;
} }
private static boolean deleteDimensionFiles(NewDimData target) private static void deleteDimensionFiles(InnerDimData dimension)
{ {
InnerDimData dimension = (InnerDimData) target; // We assume that the caller checks if the dimension is loaded, for the
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null) // sake of efficiency. Don't call this on a loaded dimension or bad
{ // things will happen!
String saveRootPath = DimensionManager.getCurrentSaveRootDirectory().getAbsolutePath(); String saveRootPath = DimensionManager.getCurrentSaveRootDirectory().getAbsolutePath();
File saveDirectory = new File(saveRootPath + "/DimensionalDoors/pocketDimID" + dimension.id()); File saveDirectory = new File(saveRootPath + "/DimensionalDoors/pocketDimID" + dimension.id());
DeleteFolder.deleteFolder(saveDirectory); DeleteFolder.deleteFolder(saveDirectory);
File dataFile = new File(saveRootPath + "/DimensionalDoors/data/dim_" + dimension.id() + ".txt"); File dataFile = new File(saveRootPath + "/DimensionalDoors/data/dim_" + dimension.id() + ".txt");
dataFile.delete(); dataFile.delete();
return true;
}
return false;
} }
private static boolean deleteDimensionData(int dimensionID) private static void deleteDimensionData(InnerDimData dimension)
{ {
if (dimensionData.containsKey(dimensionID) && DimensionManager.getWorld(dimensionID) == null) // We assume that the caller checks if the dimension is loaded, for the
// sake of efficiency. Don't call this on a loaded dimension or bad
// things will happen!
if (dimensionData.remove(dimension.id()) != null)
{ {
NewDimData target = PocketManager.getDimensionData(dimensionID);
InnerDimData dimension = (InnerDimData) target;
dimensionData.remove(dimensionID);
// Raise the dim deleted event // Raise the dim deleted event
getDimwatcher().onDeleted(new ClientDimData(dimension)); getDimwatcher().onDeleted(new ClientDimData(dimension));
dimension.clear(); dimension.clear();
return true;
} }
return false; else
{
// This should never happen. A simple sanity check.
throw new IllegalArgumentException("The specified dimension is not listed with PocketManager.");
}
} }
private static void registerPockets(DDProperties properties) private static void registerPockets(DDProperties properties)
@@ -647,10 +646,7 @@ public class PocketManager
{ {
return dimension.getLink(x, y, z); return dimension.getLink(x, y, z);
} }
else return null;
{
return null;
}
} }
public static boolean isBlackListed(int dimensionID) public static boolean isBlackListed(int dimensionID)
@@ -715,9 +711,6 @@ public class PocketManager
// Load compacted client-side dimension data // Load compacted client-side dimension data
load(); load();
Compactor.readDimensions(input, new DimRegistrationCallback()); Compactor.readDimensions(input, new DimRegistrationCallback());
// Register pocket dimensions
DDProperties properties = DDProperties.instance();
isLoaded = true; isLoaded = true;
isLoading = false; isLoading = false;