Formatting change

Aformentioned merge wouldnt commit for some reason

PLEASE REVIEW THIS AND THE PREVIOUS COMMIT
This commit is contained in:
StevenRS11
2014-07-16 10:41:27 -05:00
parent 7c7129914a
commit 499c7d91d8

View File

@@ -29,21 +29,25 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* This class regulates all the operations involving the storage and manipulation of dimensions.
* It handles saving dim data, teleporting the player, and creating/registering new dimensions as
* well as loading old dimensions on startup
* This class regulates all the operations involving the storage and
* manipulation of dimensions. It handles saving dim data, teleporting the
* player, and creating/registering new dimensions as well as loading old
* dimensions on startup
*/
public class PocketManager
{
private static class InnerDimData extends NewDimData
{
// This class allows us to instantiate NewDimData indirectly without exposing
// a public constructor from NewDimData. It's meant to stop us from constructing
// instances of NewDimData going through PocketManager. In turn, that enforces
// that any link destinations must be real dimensions controlled by PocketManager.
// This class allows us to instantiate NewDimData indirectly without
// exposing
// a public constructor from NewDimData. It's meant to stop us from
// constructing
// instances of NewDimData going through PocketManager. In turn, that
// enforces
// that any link destinations must be real dimensions controlled by
// PocketManager.
public InnerDimData(int id, InnerDimData parent, DimensionType type,
IUpdateWatcher<ClientLinkData> linkWatcher)
public InnerDimData(int id, InnerDimData parent, DimensionType type, IUpdateWatcher<ClientLinkData> linkWatcher)
{
super(id, parent, type, linkWatcher);
}
@@ -108,9 +112,12 @@ public class PocketManager
private static class DimRegistrationCallback implements IDimRegistrationCallback
{
// We use this class to provide Compactor with the ability to send us dim data without
// having to instantiate a bunch of data containers and without exposing an "unsafe"
// creation method for anyone to call. Integrity protection for the win! It's like
// We use this class to provide Compactor with the ability to send us
// dim data without
// having to instantiate a bunch of data containers and without exposing
// an "unsafe"
// creation method for anyone to call. Integrity protection for the win!
// It's like
// exposing a private constructor ONLY to a very specific trusted class.
@Override
@@ -133,9 +140,11 @@ public class PocketManager
private static final UpdateWatcherProxy<ClientDimData> dimWatcher = new UpdateWatcherProxy<ClientDimData>();
private static ArrayList<NewDimData> rootDimensions = null;
//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;
//ArrayList that stores the dimension IDs of any dimension that has been deleted.
// ArrayList that stores the dimension IDs of any dimension that has been
// deleted.
private static ArrayList<Integer> dimensionIDBlackList = null;
// Stores all the personal pocket mappings
@@ -147,7 +156,9 @@ public class PocketManager
}
/**
* simple method called on startup to register all dims saved in the dim list. Only tries to register pocket dims, though. Also calls load()
* simple method called on startup to register all dims saved in the dim
* list. Only tries to register pocket dims, though. Also calls load()
*
* @return
*/
public static void load()
@@ -167,7 +178,6 @@ public class PocketManager
dimensionIDBlackList = new ArrayList<Integer>();
personalPocketsMapping = new HashMap<String, NewDimData>();
if (FMLCommonHandler.instance().getEffectiveSide().isClient())
{
// Shouldnt try to load everything if we are a client
@@ -180,7 +190,6 @@ public class PocketManager
DDProperties properties = DDProperties.instance();
registerDimension(properties.LimboDimensionID, null, DimensionType.ROOT);
loadInternal();
// Register pocket dimensions
@@ -210,7 +219,8 @@ public class PocketManager
PocketManager.rootDimensions.add(dimData);
}
else //register children
else
// register children
{
InnerDimData test = PocketManager.dimensionData.get(packedData.ParentID);
dimData = new InnerDimData(packedData.ID, test, type, linkWatcher);
@@ -232,8 +242,10 @@ public class PocketManager
public static boolean deletePocket(NewDimData target, boolean deleteFolder)
{
// We can't delete the dimension if it's currently loaded or if it's not actually a pocket.
// We cast to InnerDimData so that if anyone tries to be a smartass and create their
// We can't delete the dimension if it's currently loaded or if it's not
// actually a pocket.
// We cast to InnerDimData so that if anyone tries to be a smartass and
// create their
// own version of NewDimData, this will throw an exception.
InnerDimData dimension = (InnerDimData) target;
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
@@ -303,7 +315,8 @@ public class PocketManager
}
catch (Exception e)
{
System.err.println("Could not register pocket dimension #" + dimension.id() + ". Probably caused by a version update/save data corruption/other mods.");
System.err.println("Could not register pocket dimension #" + dimension.id()
+ ". Probably caused by a version update/save data corruption/other mods.");
e.printStackTrace();
}
}
@@ -342,7 +355,8 @@ public class PocketManager
}
/**
* loads the dim data from the saved hashMap. Also handles compatibility with old saves, see OldSaveHandler
* loads the dim data from the saved hashMap. Also handles compatibility
* with old saves, see OldSaveHandler
*/
private static void loadInternal()
{
@@ -439,6 +453,7 @@ public class PocketManager
/**
* method to register a new pocket with DD and with forge.
*
* @param parent
* @param type
* @param playername
@@ -467,7 +482,8 @@ public class PocketManager
return data;
}
else
{ //register a pocket as personal if its parents are personal, but without a mapping.
{ // register a pocket as personal if its parents are personal, but
// without a mapping.
if (parent.type == DimensionType.PERSONAL)
{
DimensionManager.registerDimension(dimensionID, properties.PersonalPocketProviderID);
@@ -489,6 +505,7 @@ public class PocketManager
/**
* Registers a dimension with DD but NOT with forge.
*
* @param dimensionID
* @param parent
* @param isPocket
@@ -524,7 +541,8 @@ public class PocketManager
// client side. createDimensionData() always handles root dimensions
// properly, even if they weren't defined before.
// SenseiKiwi: I'm a little worried about how createDimensionData will raise
// SenseiKiwi: I'm a little worried about how createDimensionData will
// raise
// an event when it creates any root dimensions... Needs checking later.
InnerDimData root = (InnerDimData) createDimensionData(rootID);
@@ -545,10 +563,13 @@ public class PocketManager
}
if (dimension.isPocketDimension() && !DimensionManager.isDimensionRegistered(dimension.id()))
{
//Im registering pocket dims here. I *think* we can assume that if its a pocket and we are
// Im registering pocket dims here. I *think* we can assume that if
// its a pocket and we are
// registering its dim data, we also need to register it with forge.
//New packet stuff prevents this from always being true, unfortuantly. I send the dimdata to the client when they teleport.
// New packet stuff prevents this from always being true,
// unfortuantly. I send the dimdata to the client when they
// teleport.
// Steven
DimensionManager.registerDimension(dimensionID, mod_pocketDim.properties.PocketProviderID);
}
@@ -572,15 +593,19 @@ public class PocketManager
public static NewDimData createDimensionDataDangerously(int dimensionID)
{
// Same as createDimensionData(int), but public. Meant to discourage anyone from
// using it unless absolutely needed! We'll probably phase this out eventually.
// Same as createDimensionData(int), but public. Meant to discourage
// anyone from
// using it unless absolutely needed! We'll probably phase this out
// eventually.
return createDimensionData(dimensionID);
}
protected static NewDimData createDimensionData(int dimensionID)
{
// Retrieve the data for a dimension. If we don't have a record for that dimension,
// assume it's a non-pocket dimension that hasn't been initialized with us before
// Retrieve the data for a dimension. If we don't have a record for that
// dimension,
// assume it's a non-pocket dimension that hasn't been initialized with
// us before
// and create a NewDimData instance for it.
NewDimData dimension = PocketManager.dimensionData.get(dimensionID);
@@ -643,10 +668,12 @@ public class PocketManager
{
return PocketManager.dimensionIDBlackList.contains(dimensionID);
}
public static void registerDimWatcher(IUpdateWatcher<ClientDimData> watcher)
{
getDimwatcher().registerReceiver(watcher);
}
public static boolean unregisterDimWatcher(IUpdateWatcher<ClientDimData> watcher)
{
return getDimwatcher().unregisterReceiver(watcher);
@@ -669,7 +696,8 @@ public class PocketManager
public static void writePacket(DataOutputStream output) throws IOException
{
// Write a very compact description of our dimensions and links to be sent to a client
// Write a very compact description of our dimensions and links to be
// sent to a client
Compactor.write(dimensionData.values(), output);
}
@@ -687,6 +715,7 @@ public class PocketManager
DimensionManager.registerDimension(dimID, DDProperties.instance().PocketProviderID);
}
}
public static void readPacket(DataInputStream input) throws IOException
{
// TODO- figure out why this is getting called so frequently