Simplified PocketManager
1. Rewrote or removed a few bits that were causing minor warnings. 2. Rewrote deleteDimensionFiles() and deleteDimensionData() to remove unnecessary casts and checks. We can confirm that those checks are unnecessary because those functions are only used inside PocketManager. If they were ever exposed externally, then we would need to add checks again.
This commit is contained in:
parent
80bb87dac6
commit
b4a58f5c88
1 changed files with 22 additions and 29 deletions
|
@ -315,44 +315,43 @@ public class PocketManager
|
|||
{
|
||||
if (deleteFolder)
|
||||
{
|
||||
deleteDimensionFiles(target);
|
||||
deleteDimensionFiles(dimension);
|
||||
}
|
||||
dimensionIDBlackList.add(dimension.id);
|
||||
deleteDimensionData(dimension.id);
|
||||
deleteDimensionData(dimension);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean deleteDimensionFiles(NewDimData target)
|
||||
private static void deleteDimensionFiles(InnerDimData dimension)
|
||||
{
|
||||
InnerDimData dimension = (InnerDimData) target;
|
||||
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
|
||||
{
|
||||
String saveRootPath = DimensionManager.getCurrentSaveRootDirectory().getAbsolutePath();
|
||||
File saveDirectory = new File(saveRootPath + "/DimensionalDoors/pocketDimID" + dimension.id());
|
||||
DeleteFolder.deleteFolder(saveDirectory);
|
||||
File dataFile = new File(saveRootPath + "/DimensionalDoors/data/dim_" + dimension.id() + ".txt");
|
||||
dataFile.delete();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// 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!
|
||||
String saveRootPath = DimensionManager.getCurrentSaveRootDirectory().getAbsolutePath();
|
||||
File saveDirectory = new File(saveRootPath + "/DimensionalDoors/pocketDimID" + dimension.id());
|
||||
DeleteFolder.deleteFolder(saveDirectory);
|
||||
File dataFile = new File(saveRootPath + "/DimensionalDoors/data/dim_" + dimension.id() + ".txt");
|
||||
dataFile.delete();
|
||||
}
|
||||
|
||||
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
|
||||
getDimwatcher().onDeleted(new ClientDimData(dimension));
|
||||
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)
|
||||
|
@ -647,10 +646,7 @@ public class PocketManager
|
|||
{
|
||||
return dimension.getLink(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isBlackListed(int dimensionID)
|
||||
|
@ -715,9 +711,6 @@ public class PocketManager
|
|||
// Load compacted client-side dimension data
|
||||
load();
|
||||
Compactor.readDimensions(input, new DimRegistrationCallback());
|
||||
|
||||
// Register pocket dimensions
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
isLoaded = true;
|
||||
isLoading = false;
|
||||
|
|
Loading…
Reference in a new issue