From f16508dae45c49a6ebcf0e556f855b7244db2325 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sat, 28 Mar 2020 17:27:44 -0700 Subject: [PATCH] Removed unecessary breaks. --- .../erik/mobibot/commands/links/View.kt | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/links/View.kt b/src/main/java/net/thauvin/erik/mobibot/commands/links/View.kt index daec0f2..628ace6 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/links/View.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/links/View.kt @@ -90,36 +90,29 @@ class View : AbstractCommand() { // Do nothing } } + var entry: EntryLink var sent = 0 - while (i < max) { + while (i < max && sent < maxEntries) { entry = getEntry(i) if (lcArgs.isNotEmpty()) { if (entry.link.toLowerCase().contains(lcArgs) || entry.title.toLowerCase().contains(lcArgs) || entry.nick.toLowerCase().contains(lcArgs)) { - if (sent > maxEntries) { - bot.send( - sender, "To view more, try: " - + Utils.bold("${bot.nick}: $command ${i + 1} $lcArgs") - ) - break - } bot.send(sender, EntriesUtils.buildLink(i, entry, true)) sent++ } } else { - if (sent > maxEntries) { - bot.send( - sender, - "To view more, try: " + Utils.bold("${bot.nick}: $command ${i + 1}") - ) - break - } bot.send(sender, EntriesUtils.buildLink(i, entry, true)) sent++ } i++ + if (sent == maxEntries) { + bot.send( + sender, + "To view more, try: " + Utils.bold("${bot.nick}: $command ${i + 1} $lcArgs") + ) + } } } else { bot.send(sender, "There is currently nothing to view. Why don't you post something?")