From efbde62ac5d6d3f9eed51457d39b77a56ef6a047 Mon Sep 17 00:00:00 2001 From: Song Minjae Date: Tue, 20 Dec 2016 14:35:49 +0900 Subject: [PATCH] fixed bug in commandinterpreter where space(s) behind semicolon, without secondary command (e.g. "nc; ") caused crash Former-commit-id: 6b7afd141964ecefaae4f8952551859ca6c25c9d Former-commit-id: dd21356206c45bde1c9f17fc604755d372189d7e --- .../terrarum/console/CommandInterpreter.kt | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/net/torvald/terrarum/console/CommandInterpreter.kt b/src/net/torvald/terrarum/console/CommandInterpreter.kt index d0ae08740..da3f2667b 100644 --- a/src/net/torvald/terrarum/console/CommandInterpreter.kt +++ b/src/net/torvald/terrarum/console/CommandInterpreter.kt @@ -37,9 +37,12 @@ object CommandInterpreter { val error = Error() for (single_command in cmd) { + + if (single_command == null || single_command.argsCount == 0) continue + var commandObj: ConsoleCommand? = null try { - if (single_command!!.name.toLowerCase().startsWith("qqq")) { + if (single_command.name.toLowerCase().startsWith("qqq")) { commandObj = CommandDict["qqq"] } else if (commandsNoAuth.contains(single_command.name.toLowerCase())) { @@ -54,28 +57,20 @@ object CommandInterpreter { throw NullPointerException() // if not authorised, say "Unknown command" } } - } - catch (e: NullPointerException) { - } - finally { Echo("$ccW> $single_command") // prints out the input println("${ZonedDateTime.now()} [CommandInterpreter] issuing command '$single_command'") try { - if (commandObj != null) { - commandObj.execute(single_command!!.toStringArray()) - } - else { - echoUnknownCmd(single_command!!.name) - // System.out.println("ee3"); - } + commandObj.execute(single_command.toStringArray()) } catch (e: Exception) { System.err.print("[CommandInterpreter] ") e.printStackTrace() EchoError(Lang["ERROR_GENERIC_TEXT"]) } - + } + catch (e: NullPointerException) { + echoUnknownCmd(single_command.name) } } }