data.scripts.console
Class BaseCommand

java.lang.Object
  extended by data.scripts.console.BaseCommand

public abstract class BaseCommand
extends java.lang.Object

The basic command object that all console commands must extend.


Constructor Summary
BaseCommand()
           
 
Method Summary
protected  com.fs.starfarer.api.combat.CombatEngineAPI getCombatEngine()
          A convenient alias for Console.getCombatEngine().
protected  Console getConsole()
          A convenient alias for Console.getConsole().
protected abstract  java.lang.String getHelp()
          A block of text displayed via the 'help' command.
protected  com.fs.starfarer.api.campaign.LocationAPI getLocation()
          Returns the current LocationAPI.
 java.lang.String getName()
          Returns the name of this command.
protected  com.fs.starfarer.api.campaign.SectorAPI getSector()
          Returns the current SectorAPI.
protected  com.fs.starfarer.api.campaign.StarSystemAPI getStarSystem()
          Returns the current StarSystemAPI.
protected abstract  java.lang.String getSyntax()
          A line of text displayed when a command is entered incorrectly.
protected static
<T> T
getVar(java.lang.String varName, java.lang.Class<T> type)
          A convenient alias for Console.getVar(java.lang.String, java.lang.Class).
protected static java.lang.Class getVarType(java.lang.String varName)
          A convenient alias for Console.getVarType(java.lang.String).
protected static boolean hasVar(java.lang.String varName)
          A convenient alias for Console.hasVar(java.lang.String).
protected  boolean isCombatOnly()
          Returns whether this command is restricted to battles only.
protected abstract  boolean runCommand(java.lang.String args)
          Run this command with the supplied arguments.
protected static void setVar(java.lang.String varName, java.lang.Object varData)
          A convenient alias for Console.setVar(java.lang.String, java.lang.Object).
protected static void showError(java.lang.String preamble, java.lang.Exception ex)
          A convenient alias for Console.showError(java.lang.String, java.lang.Exception).
 void showHelp()
          Displays the helpfile returned by getHelp().
protected static void showMessage(java.lang.String message)
          A convenient alias for Console.showMessage(java.lang.String).
protected static void showMessage(java.lang.String preamble, java.lang.String message, boolean indent)
          A convenient alias for Console.showMessage(java.lang.String, java.lang.String, boolean).
 void showSyntax()
          Displays the syntax returned by getSyntax().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseCommand

public BaseCommand()
Method Detail

getSector

protected final com.fs.starfarer.api.campaign.SectorAPI getSector()
Returns the current SectorAPI.

Returns:
the SectorAPI object used by this campaign

getLocation

protected final com.fs.starfarer.api.campaign.LocationAPI getLocation()
Returns the current LocationAPI.

Returns:
the LocationAPI the player fleet is occupying

getStarSystem

protected final com.fs.starfarer.api.campaign.StarSystemAPI getStarSystem()
Returns the current StarSystemAPI.

Returns:
the StarSystemAPI the player fleet is occupying

getName

public java.lang.String getName()
Returns the name of this command.

Returns:
the name of this command's implementation's class

getConsole

protected final Console getConsole()
A convenient alias for Console.getConsole().

See Also:
Console.getConsole()

getCombatEngine

protected final com.fs.starfarer.api.combat.CombatEngineAPI getCombatEngine()
A convenient alias for Console.getCombatEngine().

See Also:
Console.getCombatEngine()

getVar

protected static <T> T getVar(java.lang.String varName,
                              java.lang.Class<T> type)
A convenient alias for Console.getVar(java.lang.String, java.lang.Class).

See Also:
Console.getVar(java.lang.String, java.lang.Class)

setVar

protected static void setVar(java.lang.String varName,
                             java.lang.Object varData)
A convenient alias for Console.setVar(java.lang.String, java.lang.Object).

See Also:
Console.setVar(java.lang.String, java.lang.Object)

hasVar

protected static boolean hasVar(java.lang.String varName)
A convenient alias for Console.hasVar(java.lang.String).

See Also:
Console.hasVar(java.lang.String)

getVarType

protected static java.lang.Class getVarType(java.lang.String varName)
A convenient alias for Console.getVarType(java.lang.String).

See Also:
Console.getVarType(java.lang.String)

showMessage

protected static void showMessage(java.lang.String preamble,
                                  java.lang.String message,
                                  boolean indent)
A convenient alias for Console.showMessage(java.lang.String, java.lang.String, boolean).

See Also:
Console.showMessage(java.lang.String, java.lang.String, boolean)

showMessage

protected static void showMessage(java.lang.String message)
A convenient alias for Console.showMessage(java.lang.String).

See Also:
Console.showMessage(java.lang.String)

showError

protected static void showError(java.lang.String preamble,
                                java.lang.Exception ex)
A convenient alias for Console.showError(java.lang.String, java.lang.Exception).

See Also:
Console.showError(java.lang.String, java.lang.Exception)

showHelp

public final void showHelp()
Displays the helpfile returned by getHelp().


showSyntax

public final void showSyntax()
Displays the syntax returned by getSyntax().


isCombatOnly

protected boolean isCombatOnly()
Returns whether this command is restricted to battles only.

Returns:
true if this command can only be run on the battle map

getHelp

protected abstract java.lang.String getHelp()
A block of text displayed via the 'help' command.

Returns:
the text to be displayed by showHelp().

getSyntax

protected abstract java.lang.String getSyntax()
A line of text displayed when a command is entered incorrectly.

Returns:
the text to be displayed by showSyntax().

runCommand

protected abstract boolean runCommand(java.lang.String args)
Run this command with the supplied arguments.

Parameters:
args - the String arguments passed by the Console.
Returns:
true if the command succeeded, false if it failed