mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
Former-commit-id: 5a8de3e31e1f39e1591a5a60abc9d0dd37c3f87e Former-commit-id: 9c685d31d6f8c75b512f41e467fac8586a22bc59
51 lines
1.3 KiB
Kotlin
51 lines
1.3 KiB
Kotlin
package net.torvald.terrarum.console
|
|
|
|
import net.torvald.imagefont.GameFontBase
|
|
import net.torvald.terrarum.langpack.Lang
|
|
|
|
import java.util.Formatter
|
|
|
|
/**
|
|
* Created by minjaesong on 16-01-16.
|
|
*/
|
|
class CodexEdictis : ConsoleCommand {
|
|
|
|
val ccW = GameFontBase.colToCode["o"]
|
|
|
|
override fun execute(args: Array<String>) {
|
|
if (args.size == 1) {
|
|
printList()
|
|
}
|
|
else {
|
|
try {
|
|
val commandObj = CommandDict.get(args[1].toLowerCase())
|
|
commandObj.printUsage()
|
|
}
|
|
catch (e: NullPointerException) {
|
|
val sb = StringBuilder()
|
|
val formatter = Formatter(sb)
|
|
|
|
Echo().execute("Codex: " + formatter.format(Lang["DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"], args[1]).toString())
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
override fun printUsage() {
|
|
val echo = Echo()
|
|
echo.execute("Usage: codex (command)")
|
|
echo.execute("shows how to use 'command'")
|
|
echo.execute("leave blank to get list of available commands")
|
|
}
|
|
|
|
private fun printList() {
|
|
val echo = Echo()
|
|
echo.execute(Lang["DEV_MESSAGE_CONSOLE_AVAILABLE_COMMANDS"])
|
|
CommandDict.dict.forEach { name, cmd ->
|
|
echo.execute("$ccW• " + name)
|
|
cmd.printUsage()
|
|
}
|
|
}
|
|
|
|
}
|