Changes to Commands
1. Fixed some warnings in the affected commands. 2. Removed checks for whether a command is running on the server or client side. We have performed those checks inconsistently throughout our commands without problems. I assume that they must be running on the server side only. If I'm wrong, we can add a check to DDCommandBase. 3. Minor punctuation change in DDCommandResult
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.commands;
|
package StevenDimDoors.mod_pocketDim.commands;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||||
@@ -9,12 +13,6 @@ import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
|||||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||||
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
|
|
||||||
public class CommandCreateDungeonRift extends DDCommandBase
|
public class CommandCreateDungeonRift extends DDCommandBase
|
||||||
{
|
{
|
||||||
private static CommandCreateDungeonRift instance = null;
|
private static CommandCreateDungeonRift instance = null;
|
||||||
@@ -38,10 +36,6 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
|||||||
NewDimData dimension;
|
NewDimData dimension;
|
||||||
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
||||||
|
|
||||||
if (sender.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
return DDCommandResult.SUCCESS;
|
|
||||||
}
|
|
||||||
if (command.length == 0)
|
if (command.length == 0)
|
||||||
{
|
{
|
||||||
return DDCommandResult.TOO_FEW_ARGUMENTS;
|
return DDCommandResult.TOO_FEW_ARGUMENTS;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.commands;
|
package StevenDimDoors.mod_pocketDim.commands;
|
||||||
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||||
|
|
||||||
@@ -23,11 +22,6 @@ public class CommandCreatePocket extends DDCommandBase
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||||
{
|
|
||||||
//TODO: Some commands have isRemote checks, some do not. Why? Can commands even run locally anyway?
|
|
||||||
//What does it mean when you run a command locally? ~SenseiKiwi
|
|
||||||
|
|
||||||
if (!sender.worldObj.isRemote)
|
|
||||||
{
|
{
|
||||||
if (command.length > 0)
|
if (command.length > 0)
|
||||||
{
|
{
|
||||||
@@ -42,8 +36,8 @@ public class CommandCreatePocket extends DDCommandBase
|
|||||||
DungeonHelper.instance().createCustomDungeonDoor(sender.worldObj, x, y, z);
|
DungeonHelper.instance().createCustomDungeonDoor(sender.worldObj, x, y, z);
|
||||||
|
|
||||||
//Notify the player
|
//Notify the player
|
||||||
sendChat(sender,("Created a door to a pocket dimension. Please build your dungeon there."));
|
sendChat(sender, "Created a door to a pocket dimension. Please build your dungeon there.");
|
||||||
}
|
|
||||||
return DDCommandResult.SUCCESS;
|
return DDCommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,10 +39,6 @@ public class CommandCreateRandomRift extends DDCommandBase
|
|||||||
NewDimData dimension;
|
NewDimData dimension;
|
||||||
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
||||||
|
|
||||||
if (sender.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
return DDCommandResult.SUCCESS;
|
|
||||||
}
|
|
||||||
if (command.length > 1)
|
if (command.length > 1)
|
||||||
{
|
{
|
||||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||||
@@ -118,9 +114,6 @@ public class CommandCreateRandomRift extends DDCommandBase
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return matches.get( random.nextInt(matches.size()) );
|
return matches.get( random.nextInt(matches.size()) );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,13 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.commands;
|
package StevenDimDoors.mod_pocketDim.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class CommandDeleteAllLinks extends DDCommandBase
|
public class CommandDeleteAllLinks extends DDCommandBase
|
||||||
{
|
{
|
||||||
private static CommandDeleteAllLinks instance = null;
|
private static CommandDeleteAllLinks instance = null;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package StevenDimDoors.mod_pocketDim.commands;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
@@ -10,7 +9,6 @@ import StevenDimDoors.mod_pocketDim.core.DimLink;
|
|||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class CommandDeleteRifts extends DDCommandBase
|
public class CommandDeleteRifts extends DDCommandBase
|
||||||
{
|
{
|
||||||
private static CommandDeleteRifts instance = null;
|
private static CommandDeleteRifts instance = null;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package StevenDimDoors.mod_pocketDim.commands;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||||
@@ -60,25 +59,15 @@ public class CommandExportDungeon extends DDCommandBase
|
|||||||
//Export the schematic
|
//Export the schematic
|
||||||
return exportDungeon(sender, command[0]);
|
return exportDungeon(sender, command[0]);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//The schematic name contains illegal characters. Inform the user.
|
//The schematic name contains illegal characters. Inform the user.
|
||||||
return new DDCommandResult("Error: Invalid schematic name. Please use only letters, numbers, dashes, and underscores.");
|
return new DDCommandResult("Error: Invalid schematic name. Please use only letters, numbers, dashes, and underscores.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//The command is malformed in some way. Assume that the user meant to use
|
//The command is malformed in some way. Assume that the user meant to use
|
||||||
//the 3-argument version and report an error.
|
//the 3-argument version and report an error.
|
||||||
return DDCommandResult.TOO_FEW_ARGUMENTS;
|
return DDCommandResult.TOO_FEW_ARGUMENTS;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//The user must have used the 3-argument version of this command
|
//The user must have used the 3-argument version of this command
|
||||||
//TODO: Why do we check remoteness here but not before? And why not for the other export case?
|
|
||||||
//Something feels wrong... ~SenseiKiwi
|
|
||||||
if (!sender.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
//TODO: This validation should be in DungeonHelper or in another class. We should move it
|
//TODO: This validation should be in DungeonHelper or in another class. We should move it
|
||||||
//during the save file format rewrite. ~SenseiKiwi
|
//during the save file format rewrite. ~SenseiKiwi
|
||||||
|
|
||||||
@@ -100,8 +89,7 @@ public class CommandExportDungeon extends DDCommandBase
|
|||||||
{
|
{
|
||||||
return exportDungeon(sender, join(command, "_", 0, 3));
|
return exportDungeon(sender, join(command, "_", 0, 3));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//Validate the weight argument
|
//Validate the weight argument
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -112,16 +100,12 @@ public class CommandExportDungeon extends DDCommandBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) { }
|
catch (Exception e) { }
|
||||||
}
|
|
||||||
|
|
||||||
//If we've reached this point, then we must have an invalid weight.
|
//If we've reached this point, then we must have an invalid weight.
|
||||||
return new DDCommandResult("Invalid dungeon weight. Please specify a weight between "
|
return new DDCommandResult("Invalid dungeon weight. Please specify a weight between "
|
||||||
+ DungeonHelper.MIN_DUNGEON_WEIGHT + " and " + DungeonHelper.MAX_DUNGEON_WEIGHT + ", inclusive.");
|
+ DungeonHelper.MIN_DUNGEON_WEIGHT + " and " + DungeonHelper.MAX_DUNGEON_WEIGHT + ", inclusive.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return DDCommandResult.SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static DDCommandResult exportDungeon(EntityPlayer player, String name)
|
private static DDCommandResult exportDungeon(EntityPlayer player, String name)
|
||||||
{
|
{
|
||||||
DDProperties properties = DDProperties.instance();
|
DDProperties properties = DDProperties.instance();
|
||||||
@@ -137,11 +121,8 @@ public class CommandExportDungeon extends DDCommandBase
|
|||||||
dungeonHelper.registerDungeon(exportPath, dungeonHelper.getDungeonPack("ruins"), false, true);
|
dungeonHelper.registerDungeon(exportPath, dungeonHelper.getDungeonPack("ruins"), false, true);
|
||||||
return DDCommandResult.SUCCESS;
|
return DDCommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return new DDCommandResult("Error: Failed to save dungeon schematic!");
|
return new DDCommandResult("Error: Failed to save dungeon schematic!");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static String join(String[] source, String delimiter, int start, int end)
|
private static String join(String[] source, String delimiter, int start, int end)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package StevenDimDoors.mod_pocketDim.commands;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
@@ -10,7 +9,6 @@ import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
|||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class CommandResetDungeons extends DDCommandBase
|
public class CommandResetDungeons extends DDCommandBase
|
||||||
{
|
{
|
||||||
private static CommandResetDungeons instance = null;
|
private static CommandResetDungeons instance = null;
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.commands;
|
package StevenDimDoors.mod_pocketDim.commands;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraftforge.common.DimensionManager;
|
|
||||||
|
|
||||||
public class CommandTeleportPlayer extends DDCommandBase
|
public class CommandTeleportPlayer extends DDCommandBase
|
||||||
{
|
{
|
||||||
private static CommandTeleportPlayer instance = null;
|
private static CommandTeleportPlayer instance = null;
|
||||||
@@ -121,7 +116,7 @@ public class CommandTeleportPlayer extends DDCommandBase
|
|||||||
return DDCommandResult.SUCCESS;
|
return DDCommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInteger( String input )
|
public static boolean isInteger( String input )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class DDCommandResult {
|
|||||||
public static final DDCommandResult TOO_MANY_ARGUMENTS = new DDCommandResult(2, "Error: Too many arguments passed to the command", true);
|
public static final DDCommandResult TOO_MANY_ARGUMENTS = new DDCommandResult(2, "Error: Too many arguments passed to the command", true);
|
||||||
public static final DDCommandResult INVALID_DIMENSION_ID = new DDCommandResult(3, "Error: Invalid dimension ID", true);
|
public static final DDCommandResult INVALID_DIMENSION_ID = new DDCommandResult(3, "Error: Invalid dimension ID", true);
|
||||||
public static final DDCommandResult UNREGISTERED_DIMENSION = new DDCommandResult(4, "Error: Dimension is not registered", false);
|
public static final DDCommandResult UNREGISTERED_DIMENSION = new DDCommandResult(4, "Error: Dimension is not registered", false);
|
||||||
public static final DDCommandResult INVALID_ARGUMENTS = new DDCommandResult(5, "Error: Invalid arguments passed to the command.", true);
|
public static final DDCommandResult INVALID_ARGUMENTS = new DDCommandResult(5, "Error: Invalid arguments passed to the command", true);
|
||||||
|
|
||||||
public static final int CUSTOM_ERROR_CODE = -1;
|
public static final int CUSTOM_ERROR_CODE = -1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user