2013-03-23 06:25:50 +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-03-23 06:25:50 +01:00
|
|
|
import StevenDimDoors.mod_pocketDim.DimData;
|
|
|
|
import StevenDimDoors.mod_pocketDim.LinkData;
|
2013-03-23 07:29:20 +01:00
|
|
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
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 CommandDeleteRifts extends DDCommandBase
|
2013-03-23 06:25:50 +01:00
|
|
|
{
|
2013-06-18 16:23:31 +02:00
|
|
|
private static CommandDeleteRifts instance = null;
|
|
|
|
|
|
|
|
private CommandDeleteRifts()
|
2013-06-14 01:01:54 +02:00
|
|
|
{
|
2013-07-16 23:00:25 +02:00
|
|
|
super("dd-???", "???");
|
2013-06-14 01:01:54 +02:00
|
|
|
}
|
2013-06-18 16:23:31 +02:00
|
|
|
|
|
|
|
public static CommandDeleteRifts instance()
|
2013-03-23 06:25:50 +01:00
|
|
|
{
|
2013-06-18 16:23:31 +02:00
|
|
|
if (instance == null)
|
|
|
|
instance = new CommandDeleteRifts();
|
|
|
|
|
|
|
|
return instance;
|
2013-03-23 06:25:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-06-25 19:55:13 +02:00
|
|
|
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
2013-03-23 06:25:50 +01:00
|
|
|
{
|
|
|
|
int linksRemoved=0;
|
|
|
|
int targetDim;
|
|
|
|
boolean shouldGo= true;
|
2013-06-18 16:23:31 +02:00
|
|
|
|
|
|
|
if(command.length==0)
|
2013-03-23 06:25:50 +01:00
|
|
|
{
|
2013-06-18 16:23:31 +02:00
|
|
|
targetDim= sender.worldObj.provider.dimensionId;
|
2013-03-23 06:25:50 +01:00
|
|
|
}
|
2013-06-18 16:23:31 +02:00
|
|
|
else if(command.length==1)
|
2013-03-23 06:25:50 +01:00
|
|
|
{
|
2013-06-18 16:23:31 +02:00
|
|
|
targetDim = parseInt(sender, command[0]);
|
2013-03-23 06:25:50 +01:00
|
|
|
if(!dimHelper.dimList.containsKey(targetDim))
|
|
|
|
{
|
2013-06-18 16:23:31 +02:00
|
|
|
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
|
2013-03-23 06:25:50 +01:00
|
|
|
shouldGo=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
targetDim=0;
|
|
|
|
shouldGo=false;
|
2013-06-18 16:23:31 +02:00
|
|
|
sender.sendChatToPlayer("Error-Invalid argument, delete_links <targetDimID> or blank for current dim");
|
2013-03-23 06:25:50 +01:00
|
|
|
}
|
2013-06-18 16:23:31 +02:00
|
|
|
|
2013-03-23 06:25:50 +01:00
|
|
|
if(shouldGo)
|
|
|
|
{
|
|
|
|
if(dimHelper.dimList.containsKey(targetDim))
|
|
|
|
{
|
|
|
|
DimData dim = dimHelper.dimList.get(targetDim);
|
2013-07-12 02:42:57 +02:00
|
|
|
ArrayList<LinkData> linksInDim = dim.getLinksInDim();
|
2013-06-18 16:23:31 +02:00
|
|
|
|
2013-03-23 06:25:50 +01:00
|
|
|
for(LinkData link : linksInDim)
|
|
|
|
{
|
|
|
|
World targetWorld = dimHelper.getWorld(targetDim);
|
2013-06-18 16:23:31 +02:00
|
|
|
|
2013-03-23 06:25:50 +01:00
|
|
|
if(targetWorld==null)
|
|
|
|
{
|
|
|
|
dimHelper.initDimension(targetDim);
|
|
|
|
}
|
|
|
|
else if(targetWorld.provider==null)
|
|
|
|
{
|
|
|
|
dimHelper.initDimension(targetDim);
|
|
|
|
}
|
2013-06-18 16:23:31 +02:00
|
|
|
targetWorld = dimHelper.getWorld(targetDim);
|
|
|
|
|
|
|
|
if (targetWorld.getBlockId(link.locXCoord, link.locYCoord, link.locZCoord) == mod_pocketDim.blockRift.blockID)
|
2013-03-23 07:29:20 +01:00
|
|
|
{
|
|
|
|
dim.removeLinkAtCoords(link);
|
2013-03-29 23:19:27 +01:00
|
|
|
targetWorld.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, 0);
|
2013-03-23 07:29:20 +01:00
|
|
|
linksRemoved++;
|
|
|
|
}
|
2013-03-23 06:25:50 +01:00
|
|
|
}
|
2013-06-18 16:23:31 +02:00
|
|
|
sender.sendChatToPlayer("Removed "+linksRemoved+" rifts.");
|
|
|
|
}
|
2013-03-23 06:25:50 +01:00
|
|
|
}
|
2013-06-26 05:24:21 +02:00
|
|
|
return DDCommandResult.SUCCESS; //TEMPORARY HACK
|
2013-03-23 06:25:50 +01:00
|
|
|
}
|
|
|
|
}
|