|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdata.scripts.console.Console
public final class Console
Executes commands and handles console output. Instances hold custom settings.
Field Summary | |
---|---|
static java.lang.String |
COMMAND_PACKAGE
The package all console commands must be in |
static java.lang.String |
COMMAND_SEPARATOR
To enter multiple commands at once, separate them with the following |
static java.awt.Color |
CONSOLE_COLOR
The color of messages posted by showMessage(java.lang.String) |
static int |
DEFAULT_CONSOLE_KEY
This is the LWJGL constant of the default keyboard key to summon the console |
static long |
INPUT_FRAMERATE
How often (in milliseconds) between polling the keyboard for input |
static int |
LINE_LENGTH
How long a line can be before being split by showMessage(java.lang.String) |
static int |
REBIND_KEY
This is the LWJGL constant of the keyboard key which, combined with shift, rebinds the console |
static boolean |
REQUIRE_DEV_MODE
Does the console require devMode=true in settings.json to function? |
static boolean |
REQUIRE_RUN_WINDOWED
Does the console require the game to be run windowed to function? |
static java.util.List<java.lang.Integer> |
RESTRICTED_KEYS
A list of LWJGL keyboard constants that can't be bound to summon the console |
static boolean |
SHOW_STACK_TRACE_ON_EXCEPTION
Should we display the entire stack trace when an exception occurs? |
Constructor Summary | |
---|---|
Console()
|
Method Summary | ||
---|---|---|
boolean |
addAlias(java.lang.String alias,
java.lang.String command)
Registers an alias to be used in place of a longer command. |
|
static void |
addScript(java.lang.String name,
com.fs.starfarer.api.Script script)
Registers a script to be executable with the RunScript command. |
|
void |
advance(com.fs.starfarer.api.campaign.SectorAPI sector,
com.fs.starfarer.api.campaign.LocationAPI location)
Automatically called by the game - don't call this manually. |
|
protected void |
checkQueue()
Runs any commands that are queued for execution. |
|
java.util.List<java.lang.String> |
getAliases(java.lang.String command)
Returns all aliases associated with a command |
|
protected static com.fs.starfarer.api.combat.CombatEngineAPI |
getCombatEngine()
Returns the CombatEngineAPI used by in-battle commands. |
|
com.fs.starfarer.api.campaign.LocationAPI |
getLocation()
Gets the current LocationAPI this console uses |
|
static com.fs.starfarer.api.Script |
getScript(java.lang.String name)
Retrieve a script from RunScript 's script storage. |
|
protected
|
getVar(java.lang.String varName,
java.lang.Class<T> type)
Retrieves the value of the variable varName, if any. |
|
protected java.lang.Class |
getVarType(java.lang.String varName)
Get the runtime type of the variable with the supplied name. |
|
protected boolean |
hasVar(java.lang.String varName)
Checks for the existence of a variable with the supplied name. |
|
protected static boolean |
isInBattle()
Check if the player is on the battle map. |
|
java.lang.Object |
readResolve()
Automatically called by the JRE - don't call this manually. |
|
void |
registerCommand(java.lang.Class commandClass)
Registers a command with the Console . |
|
protected static void |
setCombatEngine(com.fs.starfarer.api.combat.CombatEngineAPI engine)
Sets the CombatEngineAPI used by in-battle commands. |
|
protected static void |
setInBattle(boolean isInBattle)
Tells the Console whether to allow battle-only commands or not. |
|
protected void |
setVar(java.lang.String varName,
java.lang.Object varData)
Creates/sets a persistent variable that can be accessed by all console commands. |
|
static void |
showError(java.lang.String preamble,
java.lang.Exception ex)
Displays information to the user about an exception that has occurred. |
|
static void |
showMessage(java.lang.String message)
Formats and word-wraps the supplied text, then outputs it to the player. |
|
static void |
showMessage(java.lang.String preamble,
java.lang.String message,
boolean indent)
Formats and word-wraps the supplied text, then outputs it to the player. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean REQUIRE_DEV_MODE
public static final boolean REQUIRE_RUN_WINDOWED
public static final boolean SHOW_STACK_TRACE_ON_EXCEPTION
public static final java.lang.String COMMAND_PACKAGE
public static final java.lang.String COMMAND_SEPARATOR
public static final java.awt.Color CONSOLE_COLOR
showMessage(java.lang.String)
public static final int LINE_LENGTH
showMessage(java.lang.String)
public static final long INPUT_FRAMERATE
public static final int DEFAULT_CONSOLE_KEY
public static final int REBIND_KEY
public static final java.util.List<java.lang.Integer> RESTRICTED_KEYS
Constructor Detail |
---|
public Console()
Method Detail |
---|
public java.lang.Object readResolve()
public void registerCommand(java.lang.Class commandClass) throws java.lang.Exception
Console
.
Commands must pass validation, otherwise registration will fail!
Validation consists of the following:
- Checking that there isn't a built-in command with the same name
- Checking that the command's class is in the correct package
- Checking that the command extends BaseCommand
commandClass
- the class object of the command to register
java.lang.Exception
- if the command doesn't pass validationpublic boolean addAlias(java.lang.String alias, java.lang.String command)
alias
- the alias (shorthand) for the commandcommand
- the command to replace alias with
public java.util.List<java.lang.String> getAliases(java.lang.String command)
command
- the command to check for aliases of
protected static void setInBattle(boolean isInBattle)
Console
whether to allow battle-only commands or not.
isInBattle
- protected static boolean isInBattle()
protected static void setCombatEngine(com.fs.starfarer.api.combat.CombatEngineAPI engine)
CombatEngineAPI
used by in-battle commands.
engine
- the active CombatEngineAPI
BaseCombatHook
protected static com.fs.starfarer.api.combat.CombatEngineAPI getCombatEngine()
CombatEngineAPI
used by in-battle commands.
CombatEngineAPI
protected void setVar(java.lang.String varName, java.lang.Object varData)
Important: ensure you use unique names for your variables to avoid conflict!
varName
- the unique key this variable can be retrieved withvarData
- the data this variable should holdprotected <T> T getVar(java.lang.String varName, java.lang.Class<T> type)
T
- varName
- the name of the variable to retrievetype
- the type to be returned (e.g. Script.class)
protected boolean hasVar(java.lang.String varName)
varName
- the name of the variable to check
protected java.lang.Class getVarType(java.lang.String varName)
varName
- the name of the variable to check
public com.fs.starfarer.api.campaign.LocationAPI getLocation()
LocationAPI
this console uses
protected void checkQueue()
public static void addScript(java.lang.String name, com.fs.starfarer.api.Script script)
name
- The name of the script (for retrieval)script
- The script to be addedpublic static com.fs.starfarer.api.Script getScript(java.lang.String name)
RunScript
's script storage.
name
- The name of the script to be retrieved
public static void showMessage(java.lang.String preamble, java.lang.String message, boolean indent)
preamble
- the header for this message, won't be indentedmessage
- the main body of textindent
- whether to indent each line of the main bodypublic static void showMessage(java.lang.String message)
message
- the message to outputpublic static void showError(java.lang.String preamble, java.lang.Exception ex)
preamble
- A short message to be shown before the exceptionex
- The exception to displaypublic void advance(com.fs.starfarer.api.campaign.SectorAPI sector, com.fs.starfarer.api.campaign.LocationAPI location)
advance
in interface com.fs.starfarer.api.campaign.SpawnPointPlugin
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |