X-Git-Url: https://git.pterodactylus.net/?p=xudocci.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fxdcc%2Fui%2Fstdin%2FDownloadCommand.kt;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fxdcc%2Fui%2Fstdin%2FDownloadCommand.kt;h=8636e06830eeb4628342c95a960d4402a4282849;hp=79154725bd034583f718c958b013f6aea7393bd8;hb=dc255f5f3ac0071e491827f931d518e1d6616359;hpb=e8ff60c4c95f1c752e1a596a0b7002774c35bb6e diff --git a/src/main/java/net/pterodactylus/xdcc/ui/stdin/DownloadCommand.kt b/src/main/java/net/pterodactylus/xdcc/ui/stdin/DownloadCommand.kt index 7915472..8636e06 100644 --- a/src/main/java/net/pterodactylus/xdcc/ui/stdin/DownloadCommand.kt +++ b/src/main/java/net/pterodactylus/xdcc/ui/stdin/DownloadCommand.kt @@ -34,10 +34,11 @@ class DownloadCommand(private val core: Core) : Command { if (parameters.isEmpty()) { return state } - val index = Ints.tryParse(parameters[0]) - if (index != null && index < state.lastResults.size) { - core.fetch(state.lastResults[index].bot(), state.lastResults[index].pack()) - } + parameters + .mapNotNull { Ints.tryParse(it) } + .filter { it < state.lastResults.size } + .map { state.lastResults[it] } + .forEach { core.fetch(it.bot(), it.pack()) } return state }