ecaa90a438
Partially overhauled our command classes. Added DDCommandBase - it extends CommandBase and acts as a new base class for our commands. It removes a little redundancy in our code and provides increased convenience. Removed the static fields for our commands in mod_pocketDim. There was no point in keeping them when nothing was using them. Changed in-game command names to be shorter yet relevant. Converted all commands to singletons so proper instances can be retrieved if necessary. Migrated some of the custom dungeon start/ending logic to DungeonHelper and made customDungeonStatus private. Except for data objects, we shouldn't be exposing state variables like that without any kind of checks. I've rewritten the code in some commands but it's been quite tiring. Still need to fix up lots of things.
48 lines
1.2 KiB
Java
48 lines
1.2 KiB
Java
package StevenDimDoors.mod_pocketDim.commands;
|
|
|
|
import net.minecraft.command.CommandBase;
|
|
import net.minecraft.command.ICommandSender;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
|
|
|
/*
|
|
* An abstract base class for our Dimensional Doors commands. This cleans up the code a little and provides
|
|
* some convenience improvements.
|
|
*/
|
|
public abstract class DDCommandBase extends CommandBase
|
|
{
|
|
private String name;
|
|
|
|
public DDCommandBase(String name)
|
|
{
|
|
this.name = name;
|
|
}
|
|
|
|
/*
|
|
* When overridden in a derived class, processes the command sent by the server.
|
|
*/
|
|
protected abstract void processCommand(EntityPlayer sender, String[] command);
|
|
|
|
public final String getCommandName()
|
|
{
|
|
return name;
|
|
}
|
|
|
|
/*
|
|
* Registers the command at server startup.
|
|
*/
|
|
public void register(FMLServerStartingEvent event)
|
|
{
|
|
event.registerServerCommand(this);
|
|
}
|
|
|
|
/*
|
|
* Method invoked by the server to execute a command. The call is forwarded to a derived class
|
|
* to provide the sending player directly.
|
|
*/
|
|
public final void processCommand(ICommandSender sender, String[] command)
|
|
{
|
|
//Forward the command
|
|
processCommand(getCommandSenderAsPlayer(sender), command);
|
|
}
|
|
}
|