mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-17 00:56:07 +09:00
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
This commit is contained in:
@@ -37,9 +37,12 @@ object CommandInterpreter {
|
|||||||
val error = Error()
|
val error = Error()
|
||||||
|
|
||||||
for (single_command in cmd) {
|
for (single_command in cmd) {
|
||||||
|
|
||||||
|
if (single_command == null || single_command.argsCount == 0) continue
|
||||||
|
|
||||||
var commandObj: ConsoleCommand? = null
|
var commandObj: ConsoleCommand? = null
|
||||||
try {
|
try {
|
||||||
if (single_command!!.name.toLowerCase().startsWith("qqq")) {
|
if (single_command.name.toLowerCase().startsWith("qqq")) {
|
||||||
commandObj = CommandDict["qqq"]
|
commandObj = CommandDict["qqq"]
|
||||||
}
|
}
|
||||||
else if (commandsNoAuth.contains(single_command.name.toLowerCase())) {
|
else if (commandsNoAuth.contains(single_command.name.toLowerCase())) {
|
||||||
@@ -54,28 +57,20 @@ object CommandInterpreter {
|
|||||||
throw NullPointerException() // if not authorised, say "Unknown command"
|
throw NullPointerException() // if not authorised, say "Unknown command"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (e: NullPointerException) {
|
|
||||||
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
Echo("$ccW> $single_command") // prints out the input
|
Echo("$ccW> $single_command") // prints out the input
|
||||||
println("${ZonedDateTime.now()} [CommandInterpreter] issuing command '$single_command'")
|
println("${ZonedDateTime.now()} [CommandInterpreter] issuing command '$single_command'")
|
||||||
try {
|
try {
|
||||||
if (commandObj != null) {
|
commandObj.execute(single_command.toStringArray())
|
||||||
commandObj.execute(single_command!!.toStringArray())
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
echoUnknownCmd(single_command!!.name)
|
|
||||||
// System.out.println("ee3");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (e: Exception) {
|
catch (e: Exception) {
|
||||||
System.err.print("[CommandInterpreter] ")
|
System.err.print("[CommandInterpreter] ")
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
EchoError(Lang["ERROR_GENERIC_TEXT"])
|
EchoError(Lang["ERROR_GENERIC_TEXT"])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (e: NullPointerException) {
|
||||||
|
echoUnknownCmd(single_command.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user