Fixed Rotation in Schematic Loader and Partially Overhauled Commands #32

Merged
SenseiKiwi merged 9 commits from master into master 2013-06-26 04:51:57 +00:00
3 changed files with 52 additions and 24 deletions
Showing only changes of commit ad0e2cbe61 - Show all commits

View File

@@ -2,6 +2,8 @@ package StevenDimDoors.mod_pocketDim.commands;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import StevenDimDoors.mod_pocketDim.DimData;
@@ -14,7 +16,7 @@ public class CommandPruneDimensions extends DDCommandBase
private CommandPruneDimensions()
{
super("dd-prune");
super("dd-prune", "['delete']");
}
public static CommandPruneDimensions instance()
@@ -28,36 +30,44 @@ public class CommandPruneDimensions extends DDCommandBase
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
int numRemoved=0;
ArrayList<Integer> dimsWithLinks = new ArrayList<Integer>();
if (command.length > 1)
{
return DDCommandResult.TOO_MANY_ARGUMENTS;
}
if (command.length == 1 && !command[0].equalsIgnoreCase("delete"))
{
return DDCommandResult.INVALID_ARGUMENTS;
}
int removedCount = 0;
boolean deleteFolders = (command.length == 1);
Set<Integer> linkedDimensions = new HashSet<Integer>();
Collection<DimData> allDims = new ArrayList<DimData>();
allDims.addAll(dimHelper.dimList.values());
for(DimData data: allDims)
for (DimData data : allDims)
{
for(LinkData link:data.printAllLinkData())
for (LinkData link : data.printAllLinkData())
{
if(!dimsWithLinks.contains(link.destDimID))
linkedDimensions.add(link.destDimID);
}
}
for (LinkData link : dimHelper.instance.interDimLinkList.values())
{
linkedDimensions.add(link.destDimID);
}
for (DimData data : allDims)
{
if (!linkedDimensions.contains(data.dimID))
{
if (dimHelper.instance.pruneDimension(data, deleteFolders))
{
dimsWithLinks.add(link.destDimID);
removedCount++;
}
}
}
for(LinkData link : dimHelper.instance.interDimLinkList.values())
{
if(!dimsWithLinks.contains(link.destDimID))
{
dimsWithLinks.add(link.destDimID);
}
}
for(DimData data : allDims)
{
if(!dimsWithLinks.contains(data.dimID))
{
dimHelper.dimList.remove(data.dimID);
numRemoved++;
}
}
dimHelper.instance.save();
sender.sendChatToPlayer("Removed " + numRemoved + " unreachable pocket dims.");
sender.sendChatToPlayer("Removed " + removedCount + " unreachable pocket dims.");
return DDCommandResult.SUCCESS;
}
}

View File

@@ -8,6 +8,7 @@ public class DDCommandResult {
public static final DDCommandResult TOO_MANY_ARGUMENTS = new DDCommandResult(2, "Error: Too many arguments passed to the command", true);
public static final DDCommandResult INVALID_DIMENSION_ID = new DDCommandResult(3, "Error: Invalid dimension ID", true);
public static final DDCommandResult UNREGISTERED_DIMENSION = new DDCommandResult(4, "Error: Dimension is not registered", false);
public static final DDCommandResult INVALID_ARGUMENTS = new DDCommandResult(5, "Error: Invalid arguments passed to the command.", true);
public static final int CUSTOM_ERROR_CODE = -1;

View File

@@ -816,7 +816,7 @@ public class dimHelper extends DimensionManager
public boolean resetPocket(DimData dimData)
{
//TODO: Should we add a check to see if the dimension is currently loaded? How could we check that? ~SenseiKiwi
if (getWorld(dimData.dimID) != null || !dimData.isPocket)
if (!dimData.isPocket || getWorld(dimData.dimID) != null)
{
return false;
}
@@ -836,6 +836,23 @@ public class dimHelper extends DimensionManager
return true;
}
public boolean pruneDimension(DimData dimData, boolean deleteFolder)
{
//TODO: Should we add a check to see if the dimension is currently loaded? How could we check that? ~SenseiKiwi
//TODO: All the logic for checking that this is an isolated pocket should be moved in here.
if (!dimData.isPocket || getWorld(dimData.dimID) != null)
{
return false;
}
dimList.remove(dimData.dimID);
if (deleteFolder)
{
File save = new File(getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimData.dimID);
DeleteFolder.deleteFolder(save);
}
return true;
}
/**
* method called when the client disconnects/server stops to unregister dims.
* @Return