2013-03-23 07:29:20 +01:00
|
|
|
package StevenDimDoors.mod_pocketDim.commands;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2013-06-18 16:23:31 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.world.World;
|
2013-10-02 04:50:43 +02:00
|
|
|
import net.minecraftforge.common.DimensionManager;
|
|
|
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
2013-08-29 08:14:24 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
|
|
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
2013-03-23 07:29:20 +01:00
|
|
|
|
2013-06-18 16:23:31 +02:00
|
|
|
public class CommandDeleteAllLinks extends DDCommandBase
|
2013-03-23 07:29:20 +01:00
|
|
|
{
|
2013-06-18 16:23:31 +02:00
|
|
|
private static CommandDeleteAllLinks instance = null;
|
|
|
|
|
|
|
|
private CommandDeleteAllLinks()
|
2013-03-23 07:29:20 +01:00
|
|
|
{
|
2013-07-16 23:00:25 +02:00
|
|
|
super("dd-deletelinks", "???");
|
2013-03-23 07:29:20 +01:00
|
|
|
}
|
|
|
|
|
2013-06-18 16:23:31 +02:00
|
|
|
public static CommandDeleteAllLinks instance()
|
|
|
|
{
|
|
|
|
if (instance == null)
|
|
|
|
instance = new CommandDeleteAllLinks();
|
2013-03-23 07:29:20 +01:00
|
|
|
|
2013-06-18 16:23:31 +02:00
|
|
|
return instance;
|
|
|
|
}
|
2013-03-23 07:29:20 +01:00
|
|
|
|
|
|
|
@Override
|
2013-06-25 19:55:13 +02:00
|
|
|
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
2013-03-23 07:29:20 +01:00
|
|
|
{
|
|
|
|
int linksRemoved=0;
|
|
|
|
int targetDim;
|
|
|
|
boolean shouldGo= true;
|
2013-06-18 16:23:31 +02:00
|
|
|
|
2013-10-02 04:50:43 +02:00
|
|
|
if(command.length==1)
|
2013-03-23 07:29:20 +01:00
|
|
|
{
|
2013-06-18 16:23:31 +02:00
|
|
|
targetDim = parseInt(sender, command[0]);
|
2013-03-23 07:29:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
targetDim=0;
|
|
|
|
shouldGo=false;
|
2013-10-02 04:50:43 +02:00
|
|
|
sender.sendChatToPlayer("Error-Invalid argument, delete_all_links <targetDimID>");
|
2013-03-23 07:29:20 +01:00
|
|
|
}
|
2013-06-18 16:23:31 +02:00
|
|
|
|
2013-03-23 07:29:20 +01:00
|
|
|
if(shouldGo)
|
|
|
|
{
|
2013-10-02 04:50:43 +02:00
|
|
|
|
|
|
|
NewDimData dim = PocketManager.getDimensionData(targetDim);
|
|
|
|
ArrayList<DimLink> linksInDim = dim.getAllLinks();
|
2013-06-18 16:23:31 +02:00
|
|
|
|
2013-10-02 04:50:43 +02:00
|
|
|
for (DimLink link : linksInDim)
|
2013-03-23 07:29:20 +01:00
|
|
|
{
|
2013-10-02 04:50:43 +02:00
|
|
|
World targetWorld = PocketManager.loadDimension(targetDim);
|
|
|
|
targetWorld.setBlock(link.source().getX(), link.source().getY(), link.source().getZ(), 0);
|
|
|
|
dim.deleteLink(link);
|
|
|
|
//TODO Probably should check what the block is, but thats annoying so Ill do it later.
|
2013-06-18 16:23:31 +02:00
|
|
|
|
|
|
|
linksRemoved++;
|
2013-03-23 07:29:20 +01:00
|
|
|
}
|
2013-06-18 16:23:31 +02:00
|
|
|
sender.sendChatToPlayer("Removed " + linksRemoved + " links.");
|
2013-10-02 04:50:43 +02:00
|
|
|
|
2013-03-23 07:29:20 +01:00
|
|
|
}
|
2013-06-26 05:24:21 +02:00
|
|
|
return DDCommandResult.SUCCESS; //TEMPORARY HACK
|
2013-03-23 07:29:20 +01:00
|
|
|
}
|
|
|
|
}
|