Changes to Commands
Made some minor changes to the way that we register commands with Minecraft. Also changed the way that we generate onCommandUsage() strings so that the style of our outputs is consistent with that of Minecraft and Forge commands. It seems the way the messages were generated changed for MC 1.6. Finally, removed compareTo() from DDCommandBase since it was completely unnecessary (CommandBase already does the same) and casting objects to CommandBase was causing errors with some Chicken Bones commands that directly implemented ICommand.
This commit is contained in:
parent
a8e37da4bc
commit
62bd3bd19e
9 changed files with 26 additions and 64 deletions
|
@ -32,14 +32,6 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
|||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender)
|
||||
{
|
||||
return "Usage: /dd-rift <dungeon name>\r\n" +
|
||||
" /dd-rift list\r\n" +
|
||||
" /dd-rift random";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
|
|
|
@ -21,11 +21,6 @@ public class CommandCreatePocket extends DDCommandBase
|
|||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "Usage: /dd-create";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
|
|
|
@ -28,11 +28,6 @@ public class CommandDeleteAllLinks extends DDCommandBase
|
|||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "Usage: /dd-deletelinks <targetDimensionID>";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
|
|
|
@ -28,11 +28,6 @@ public class CommandDeleteRifts extends DDCommandBase
|
|||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "Usage: /dd-??? <dimension ID>";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
|
|
|
@ -26,13 +26,6 @@ public class CommandExportDungeon extends DDCommandBase
|
|||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "Usage: /dd-export <dungeon type> <dungeon name> open <weight>\r\n" +
|
||||
" /dd-export <dungeon type> <dungeon name> closed <weight>\r\n" +
|
||||
" /dd-export <schematic name> override";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
|
|
|
@ -28,11 +28,6 @@ public class CommandResetDungeons extends DDCommandBase
|
|||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "/dd-resetdungeons";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
|
|
|
@ -23,17 +23,11 @@ public class CommandTeleportPlayer extends DDCommandBase
|
|||
public static CommandTeleportPlayer instance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new CommandTeleportPlayer();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "Usage: /dd-tp <player name> <dimension id> <x> <y> <z>";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO- Change to accept variety of input, like just coords, just dim ID, or two player names.
|
||||
*/
|
||||
|
|
|
@ -39,12 +39,22 @@ public abstract class DDCommandBase extends CommandBase
|
|||
return name;
|
||||
}
|
||||
|
||||
/*
|
||||
* Registers the command at server startup.
|
||||
*/
|
||||
public void register(FMLServerStartingEvent event)
|
||||
@Override
|
||||
public final String getCommandUsage(ICommandSender sender)
|
||||
{
|
||||
event.registerServerCommand(this);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append('/');
|
||||
builder.append(name);
|
||||
builder.append(' ');
|
||||
builder.append(formats[0]);
|
||||
for (int index = 1; index < formats.length; index++)
|
||||
{
|
||||
builder.append(" OR /");
|
||||
builder.append(name);
|
||||
builder.append(' ');
|
||||
builder.append(formats[index]);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -66,10 +76,10 @@ public abstract class DDCommandBase extends CommandBase
|
|||
//Send the argument formats for this command
|
||||
for (String format : formats)
|
||||
{
|
||||
sendChat(player,("Usage: " + name + " " + format));
|
||||
sendChat(player, "Usage: " + name + " " + format);
|
||||
}
|
||||
}
|
||||
sendChat(player,(result.getMessage()));
|
||||
sendChat(player, result.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,12 +88,5 @@ public abstract class DDCommandBase extends CommandBase
|
|||
ChatMessageComponent cmp = new ChatMessageComponent();
|
||||
cmp.addText(message);
|
||||
player.sendChatToPlayer(cmp);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object par1Obj)
|
||||
{
|
||||
return this.getCommandName().compareTo(((CommandBase)par1Obj).getCommandName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -307,16 +307,16 @@ public class mod_pocketDim
|
|||
//TODO- load dims with forced chunks on server startup here
|
||||
|
||||
// Register commands with the server
|
||||
CommandResetDungeons.instance().register(event);
|
||||
CommandCreateDungeonRift.instance().register(event);
|
||||
CommandDeleteAllLinks.instance().register(event);
|
||||
event.registerServerCommand( CommandResetDungeons.instance() );
|
||||
event.registerServerCommand( CommandCreateDungeonRift.instance() );
|
||||
event.registerServerCommand( CommandDeleteAllLinks.instance() );
|
||||
//CommandDeleteDimensionData.instance().register(event);
|
||||
CommandDeleteRifts.instance().register(event);
|
||||
CommandExportDungeon.instance().register(event);
|
||||
event.registerServerCommand( CommandDeleteRifts.instance() );
|
||||
event.registerServerCommand( CommandExportDungeon.instance() );
|
||||
//CommandPrintDimensionData.instance().register(event);
|
||||
//CommandPruneDimensions.instance().register(event);
|
||||
CommandCreatePocket.instance().register(event);
|
||||
CommandTeleportPlayer.instance().register(event);
|
||||
event.registerServerCommand( CommandCreatePocket.instance() );
|
||||
event.registerServerCommand( CommandTeleportPlayer.instance() );
|
||||
|
||||
// Initialize a new DeathTracker
|
||||
String deathTrackerFile = DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/data/deaths.txt";
|
||||
|
|
Loading…
Reference in a new issue