Partial Overhaul of Commands

Made progress on overhauling and prettifying our commands. There are
still more changes to be done for this to be functional. I need to do an
intermediate commit because I want to merge in recent changes by Steven.
This commit is contained in:
SenseiKiwi
2013-06-25 13:55:13 -04:00
parent 06a8abbf74
commit bc2745a596
14 changed files with 425 additions and 226 deletions

View File

@@ -16,37 +16,37 @@ public class DimData implements Serializable
public int dimID;
public int depth;
public int dimOrientation;
public World world;
public LinkData exitDimLink;
public boolean isPocket;
public boolean hasBeenFilled=false;
public boolean hasDoor=false;
public boolean isDimRandomRift=false;
public DungeonGenerator dungeonGenerator = null;
//public boolean isPrivatePocket = false;
public HashMap<Integer, HashMap<Integer, HashMap<Integer, LinkData>>> linksInThisDim=new HashMap();
public HashMap<Integer, HashMap<Integer, HashMap<Integer, LinkData>>> linksInThisDim = new HashMap();
HashMap<Integer, LinkData> dimX;
HashMap<Integer, HashMap<Integer, LinkData>> dimY ;
static final long serialVersionUID = 454342L;
public DimData(int dimID, boolean isPocket, int depth, LinkData exitLinkData)
{
this.dimID=dimID;
this.depth=depth;
this.isPocket=isPocket;
this.exitDimLink= exitLinkData;
}
public DimData(int dimID, boolean isPocket, int depth, int exitLinkDimID, int exitX, int exitY, int exitZ)
{
this(dimID, isPocket, depth, new LinkData(exitLinkDimID, exitX, exitY, exitZ));
}
public LinkData findNearestRift(World world, int range, int x, int y, int z)
{
LinkData nearest=null;
@@ -55,7 +55,7 @@ public class DimData implements Serializable
int j=-range;
int k=-range;
DDProperties properties = DDProperties.instance();
while (i<range)
{
while (j<range)
@@ -69,24 +69,24 @@ public class DimData implements Serializable
nearest=this.findLinkAtCoords(x+i, y+j, z+k);
distance=MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k);
}
}
k++;
}
k=-range;
j++;
}
j=-range;
i++;
}
return nearest;
}
public ArrayList findRiftsInRange(World world, int range, int x, int y, int z)
{
LinkData nearest=null;
@@ -95,7 +95,7 @@ public class DimData implements Serializable
int j=-range;
int k=-range;
DDProperties properties = DDProperties.instance();
while (i<range)
{
while (j<range)
@@ -112,32 +112,32 @@ public class DimData implements Serializable
rifts.add(nearest);
}
}
}
k++;
}
k=-range;
j++;
}
j=-range;
i++;
}
return rifts;
}
public LinkData addLinkToDim(LinkData link)
{
if(this.linksInThisDim.containsKey(link.locZCoord))
{
this.dimY=this.linksInThisDim.get(link.locZCoord);
if(this.dimY.containsKey(link.locYCoord))
{
this.dimX=this.dimY.get(link.locYCoord);
@@ -152,39 +152,39 @@ public class DimData implements Serializable
this.dimX=new HashMap<Integer, LinkData>();
this.dimY=new HashMap<Integer, HashMap<Integer, LinkData>>();
}
this.dimX.put(link.locXCoord, link);
this.dimY.put(link.locYCoord, dimX);
this.linksInThisDim.put(link.locZCoord, dimY);
//System.out.println("added link to dim "+this.dimID);
return link;
}
public LinkData addLinkToDim( int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord, int destinationXCoord, int destinationYCoord, int destinationZCoord, int linkOrientation)
{
LinkData linkData= new LinkData(this.dimID, destinationDimID, locationXCoord, locationYCoord, locationZCoord, destinationXCoord, destinationYCoord,destinationZCoord,this.isPocket,linkOrientation);
return this.addLinkToDim(linkData);
}
public boolean isLimbo()
{
return (this.dimID == DDProperties.instance().LimboDimensionID);
}
public void removeLinkAtCoords(LinkData link)
{
this.removeLinkAtCoords(link.locDimID, link.locXCoord, link.locYCoord, link.locZCoord);
}
public void removeLinkAtCoords(int locationID, int locationXCoord, int locationYCoord, int locationZCoord)
{
if (this.linksInThisDim.containsKey(locationZCoord))
{
this.dimY=this.linksInThisDim.get(locationZCoord);
if(this.dimY.containsKey(locationYCoord))
{
this.dimX=this.dimY.get(locationYCoord);
@@ -199,80 +199,59 @@ public class DimData implements Serializable
this.dimX=new HashMap<Integer, LinkData>();
this.dimY=new HashMap<Integer, HashMap<Integer, LinkData>>();
}
this.dimX.remove(locationXCoord);
this.dimY.put(locationYCoord, dimX);
this.linksInThisDim.put(locationZCoord, dimY);
}
public LinkData findLinkAtCoords(int locationXCoord, int locationYCoord, int locationZCoord)
{
try
{
if(this.linksInThisDim.containsKey(locationZCoord))
{
this.dimY=this.linksInThisDim.get(locationZCoord);
if(this.dimY.containsKey(locationYCoord))
if(this.linksInThisDim.containsKey(locationZCoord))
{
this.dimX=this.dimY.get(locationYCoord);
if(this.dimX.containsKey(locationXCoord))
this.dimY=this.linksInThisDim.get(locationZCoord);
if(this.dimY.containsKey(locationYCoord))
{
return this.dimX.get(locationXCoord);
this.dimX=this.dimY.get(locationYCoord);
if(this.dimX.containsKey(locationXCoord))
{
return this.dimX.get(locationXCoord);
}
}
}
}
}
catch(Exception E)
{
return null;
}
return null;
return null;
}
public ArrayList<LinkData> printAllLinkData()
{
ArrayList links = new ArrayList();
if(this.linksInThisDim==null)
//TODO: We might want to modify this function, but I'm afraid of breaking something right now.
//To begin with, the name is wrong. This doesn't print anything! >_o ~SenseiKiwi
ArrayList<LinkData> links = new ArrayList<LinkData>();
if (this.linksInThisDim == null)
{
return links;
}
for(HashMap<Integer, HashMap<Integer, LinkData>> first : this.linksInThisDim.values())
for (HashMap<Integer, HashMap<Integer, LinkData>> first : this.linksInThisDim.values())
{
for(HashMap<Integer, LinkData> second : first.values())
for (HashMap<Integer, LinkData> second : first.values())
{
for(LinkData linkData :second.values())
for (LinkData linkData : second.values())
{
links.add(linkData);
}
}
}
}
return links;
}
}