Improved and Renamed CommandRegenPocket

Renamed CommandRegenPocket to CommandResetDungeons. Changed command name
accordingly. Added a message for the user listing the number of dungeons
that were reset. Modified DimHelper slightly to add support for this.
Added error condition if user specifies arguments for the command.
This commit is contained in:
SenseiKiwi 2013-06-25 14:28:11 -04:00
parent e0ccb59d15
commit d15f372c59
4 changed files with 68 additions and 61 deletions

View file

@ -1,43 +0,0 @@
package StevenDimDoors.mod_pocketDim.commands;
import java.io.File;
import net.minecraft.entity.player.EntityPlayer;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
public class CommandRegenPocket extends DDCommandBase
{
private static CommandRegenPocket instance = null;
private CommandRegenPocket()
{
super("dd-regenDungeons");
}
public static CommandRegenPocket instance()
{
if (instance == null)
instance = new CommandRegenPocket();
return instance;
}
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
DungeonHelper dungeonHelper = DungeonHelper.instance();
DDProperties properties = DDProperties.instance();
for(DimData data : dimHelper.dimList.values())
{
if(data.isDimRandomRift)
{
dimHelper.instance.regenPocket(data);
}
}
}
}

View file

@ -0,0 +1,51 @@
package StevenDimDoors.mod_pocketDim.commands;
import net.minecraft.entity.player.EntityPlayer;
import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
public class CommandResetDungeons extends DDCommandBase
{
private static CommandResetDungeons instance = null;
private CommandResetDungeons()
{
super("dd-resetdungeons", "");
}
public static CommandResetDungeons instance()
{
if (instance == null)
instance = new CommandResetDungeons();
return instance;
}
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
if (command.length > 0)
{
return DDCommandResult.TOO_FEW_ARGUMENTS;
}
int dungeonCount = 0;
int resetCount = 0;
for (DimData data : dimHelper.dimList.values())
{
if (data.isDimRandomRift)
{
dungeonCount++;
if (dimHelper.instance.resetPocket(data))
{
resetCount++;
}
}
}
//Notify the user of the results
sender.sendChatToPlayer("Reset complete. " + resetCount + " out of " + dungeonCount + " dungeons were reset.");
return DDCommandResult.SUCCESS;
}
}

View file

@ -38,6 +38,7 @@ import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.LinkData;
import StevenDimDoors.mod_pocketDim.ObjectSaveInputStream;
import StevenDimDoors.mod_pocketDim.PacketHandler;
import StevenDimDoors.mod_pocketDim.Point3D;
import StevenDimDoors.mod_pocketDim.TileEntityRift;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
@ -64,7 +65,7 @@ public class dimHelper extends DimensionManager
* ArrayList containing any blocks in limbo that have been placed by the player. Cycled through in the common tick manager
* @Return
*/
public static ArrayList blocksToDecay= new ArrayList();
public static ArrayList<Point3D> blocksToDecay = new ArrayList<Point3D>();
/**
* instance of the dimHelper
@ -812,33 +813,31 @@ public class dimHelper extends DimensionManager
}
}
public void regenPocket(DimData dimData)
public boolean resetPocket(DimData dimData)
{
if(this.getWorld(dimData.dimID)!=null ||!dimData.isPocket)
//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)
{
return;
return false;
}
File save = new File( this.getCurrentSaveRootDirectory()+"/DimensionalDoors/pocketDimID" + dimData.dimID);
File save = new File(getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimData.dimID);
DeleteFolder.deleteFolder(save);
dimData.hasBeenFilled=false;
dimData.hasDoor=false;
dimData.hasBeenFilled = false;
dimData.hasDoor = false;
for(LinkData link : dimData.printAllLinkData())
{
link.hasGennedDoor=false;
LinkData linkOut =this.getLinkDataFromCoords(link.destXCoord, link.destYCoord, link.destZCoord, link.destDimID);
if(linkOut!=null)
link.hasGennedDoor = false;
LinkData linkOut = this.getLinkDataFromCoords(link.destXCoord, link.destYCoord, link.destZCoord, link.destDimID);
if (linkOut != null)
{
linkOut.hasGennedDoor=false;
linkOut.hasGennedDoor = false;
}
}
return true;
}
/**
* method called when the client disconects/server stops to unregister dims.
* method called when the client disconnects/server stops to unregister dims.
* @Return
*/
public void unregsisterDims()

View file

@ -29,7 +29,7 @@ import StevenDimDoors.mod_pocketDim.commands.CommandDeleteRifts;
import StevenDimDoors.mod_pocketDim.commands.CommandEndDungeonCreation;
import StevenDimDoors.mod_pocketDim.commands.CommandPrintDimensionData;
import StevenDimDoors.mod_pocketDim.commands.CommandPruneDimensions;
import StevenDimDoors.mod_pocketDim.commands.CommandRegenPocket;
import StevenDimDoors.mod_pocketDim.commands.CommandResetDungeons;
import StevenDimDoors.mod_pocketDim.commands.CommandStartDungeonCreation;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;