diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandDeleteDimData.java b/StevenDimDoors/mod_pocketDim/commands/CommandDeleteDimData.java new file mode 100644 index 00000000..e4de3e33 --- /dev/null +++ b/StevenDimDoors/mod_pocketDim/commands/CommandDeleteDimData.java @@ -0,0 +1,106 @@ +package StevenDimDoors.mod_pocketDim.commands; + +import java.util.ArrayList; +import java.util.Collection; + +import cpw.mods.fml.common.FMLCommonHandler; + +import StevenDimDoors.mod_pocketDim.DimData; +import StevenDimDoors.mod_pocketDim.LinkData; +import StevenDimDoors.mod_pocketDim.dimHelper; +import StevenDimDoors.mod_pocketDim.mod_pocketDim; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.world.World; + +public class CommandDeleteDimData extends CommandBase +{ + public String getCommandName()//the name of our command + { + return "delete_dim_data"; + } + + + + + @Override + public void processCommand(ICommandSender var1, String[] var2) + + { + int linksRemoved=0; + int targetDim; + boolean shouldGo= true; + + if(var2.length==0) + { + targetDim= this.getCommandSenderAsPlayer(var1).worldObj.provider.dimensionId; + } + else if(var2.length==1) + { + targetDim= this.parseInt(var1, var2[0]); + if(!dimHelper.dimList.containsKey(targetDim)) + { + this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Error- dim "+targetDim+" not registered"); + shouldGo=false; + + } + } + else + { + targetDim=0; + shouldGo=false; + this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Error-Invalid argument, delete_dim_data or blank for current dim"); + + + } + + + + + if(shouldGo) + { + if(dimHelper.dimList.containsKey(targetDim)) + { + for(DimData dimData :dimHelper.dimList.values()) + { + Collection links= new ArrayList(); + links.addAll( dimData.printAllLinkData()); + + for(LinkData link : links) + { + if(link.destDimID==targetDim) + { + dimHelper.dimList.get(link.locDimID).removeLinkAtCoords(link); + dimHelper.instance.linksForRendering.remove(link); + linksRemoved++; + } + if(dimData.dimID==targetDim) + { + dimHelper.instance.linksForRendering.remove(link); + linksRemoved++; + } + } + + + } + + dimHelper.dimList.remove(targetDim); + this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Removed dimension "+targetDim+" from DimDoors and deleted "+linksRemoved+" links"); + + } + else + { + this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Error- dimension "+targetDim+" not registered with dimDoors"); + } + + } + + // this.getCommandSenderAsPlayer(var1).sendChatToPlayer(String.valueOf(var2)); + // this.getCommandSenderAsPlayer(var1).sendChatToPlayer(String.valueOf(var2.length)); + // this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Removed "+linksRemoved+" rifts."); + + + // TODO Auto-generated method stub + + } +} \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandPrintDimData.java b/StevenDimDoors/mod_pocketDim/commands/CommandPrintDimData.java new file mode 100644 index 00000000..e398671b --- /dev/null +++ b/StevenDimDoors/mod_pocketDim/commands/CommandPrintDimData.java @@ -0,0 +1,106 @@ +package StevenDimDoors.mod_pocketDim.commands; + +import java.util.ArrayList; +import java.util.Collection; + +import cpw.mods.fml.common.FMLCommonHandler; + +import StevenDimDoors.mod_pocketDim.DimData; +import StevenDimDoors.mod_pocketDim.LinkData; +import StevenDimDoors.mod_pocketDim.dimHelper; +import StevenDimDoors.mod_pocketDim.mod_pocketDim; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.world.World; + +public class CommandPrintDimData extends CommandBase +{ + public String getCommandName()//the name of our command + { + return "print_dim_data"; + } + + + + + @Override + public void processCommand(ICommandSender var1, String[] var2) + + { + int linksRemoved=0; + int targetDim; + boolean shouldGo= true; + + if(var2.length==0) + { + targetDim= this.getCommandSenderAsPlayer(var1).worldObj.provider.dimensionId; + } + else if(var2.length==1) + { + targetDim= this.parseInt(var1, var2[0]); + if(!dimHelper.dimList.containsKey(targetDim)) + { + this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Error- dim "+targetDim+" not registered"); + shouldGo=false; + + } + } + else + { + targetDim=0; + shouldGo=false; + this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Error-Invalid argument, print_dim_data or blank for current dim"); + + + } + + + + + if(shouldGo) + { + if(dimHelper.dimList.containsKey(targetDim)) + { + for(DimData dimData :dimHelper.dimList.values()) + { + Collection links= new ArrayList(); + links.addAll( dimData.printAllLinkData()); + + for(LinkData link : links) + { + if(link.destDimID==targetDim) + { + dimHelper.dimList.get(link.locDimID).removeLinkAtCoords(link); + dimHelper.instance.linksForRendering.remove(link); + linksRemoved++; + } + if(dimData.dimID==targetDim) + { + dimHelper.instance.linksForRendering.remove(link); + linksRemoved++; + } + } + + + } + + dimHelper.dimList.remove(targetDim); + this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Removed dimension "+targetDim+" from DimDoors and deleted "+linksRemoved+" links"); + + } + else + { + this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Error- dimension "+targetDim+" not registered with dimDoors"); + } + + } + + // this.getCommandSenderAsPlayer(var1).sendChatToPlayer(String.valueOf(var2)); + // this.getCommandSenderAsPlayer(var1).sendChatToPlayer(String.valueOf(var2.length)); + // this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Removed "+linksRemoved+" rifts."); + + + // TODO Auto-generated method stub + + } +} \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDim/mod_pocketDim.java b/StevenDimDoors/mod_pocketDim/mod_pocketDim.java index 203e0a36..c1b5c659 100644 --- a/StevenDimDoors/mod_pocketDim/mod_pocketDim.java +++ b/StevenDimDoors/mod_pocketDim/mod_pocketDim.java @@ -35,6 +35,7 @@ import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; import StevenDimDoors.mod_pocketDim.commands.CommandDeleteAllLinks; +import StevenDimDoors.mod_pocketDim.commands.CommandDeleteDimData; import StevenDimDoors.mod_pocketDim.commands.CommandDeleteRifts; import StevenDimDoors.mod_pocketDim.commands.CommandPruneDims; @@ -62,6 +63,7 @@ public class mod_pocketDim public static final ICommand removeRiftsCommand = new CommandDeleteRifts(); public static final ICommand pruneDimsCommand = new CommandPruneDims(); public static final ICommand removeAllLinksCommand = new CommandDeleteAllLinks(); + public static final ICommand deleteDimDataCommand = new CommandDeleteDimData(); public static int providerID; @@ -617,6 +619,7 @@ public class mod_pocketDim event.registerServerCommand(removeRiftsCommand); event.registerServerCommand(pruneDimsCommand); event.registerServerCommand(removeAllLinksCommand); + event.registerServerCommand(deleteDimDataCommand); dimHelper.instance.load();