2013-03-23 06:25:50 +01:00
|
|
|
package StevenDimDoors.mod_pocketDim.commands;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
|
2013-06-18 16:23:31 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-03-23 06:25:50 +01:00
|
|
|
import StevenDimDoors.mod_pocketDim.DimData;
|
|
|
|
import StevenDimDoors.mod_pocketDim.LinkData;
|
2013-06-10 23:03:52 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
2013-03-23 06:25:50 +01:00
|
|
|
|
2013-06-18 16:23:31 +02:00
|
|
|
public class CommandPruneDimensions extends DDCommandBase
|
2013-03-23 06:25:50 +01:00
|
|
|
{
|
2013-06-18 16:23:31 +02:00
|
|
|
private static CommandPruneDimensions instance = null;
|
|
|
|
|
|
|
|
private CommandPruneDimensions()
|
2013-03-23 06:25:50 +01:00
|
|
|
{
|
2013-06-18 16:23:31 +02:00
|
|
|
super("dd-prune");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static CommandPruneDimensions instance()
|
|
|
|
{
|
|
|
|
if (instance == null)
|
|
|
|
instance = new CommandPruneDimensions();
|
|
|
|
|
|
|
|
return instance;
|
2013-03-23 06:25:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-06-18 16:23:31 +02:00
|
|
|
protected void processCommand(EntityPlayer sender, String[] command)
|
2013-03-23 06:25:50 +01:00
|
|
|
{
|
|
|
|
int numRemoved=0;
|
2013-06-18 16:23:31 +02:00
|
|
|
ArrayList<Integer> dimsWithLinks = new ArrayList<Integer>();
|
|
|
|
Collection<DimData> allDims = new ArrayList<DimData>();
|
2013-03-23 06:25:50 +01:00
|
|
|
allDims.addAll(dimHelper.dimList.values());
|
|
|
|
for(DimData data: allDims)
|
|
|
|
{
|
|
|
|
for(LinkData link:data.printAllLinkData())
|
|
|
|
{
|
|
|
|
if(!dimsWithLinks.contains(link.destDimID))
|
|
|
|
{
|
|
|
|
dimsWithLinks.add(link.destDimID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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();
|
2013-06-18 16:23:31 +02:00
|
|
|
sender.sendChatToPlayer("Removed " + numRemoved + " unreachable pocket dims.");
|
2013-03-23 06:25:50 +01:00
|
|
|
}
|
|
|
|
}
|