From 0dd320def6e7cec44e360de1f098805402fd8936 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 2 Aug 2024 10:58:16 +0200 Subject: Fix: /shcommands empty page (#2287) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/features/commands/HelpCommand.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/HelpCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/HelpCommand.kt index 9bd3afce4..4d4c5d341 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/HelpCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/HelpCommand.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.chat.Text.style import at.hannibal2.skyhanni.utils.chat.Text.suggest import net.minecraft.util.EnumChatFormatting import net.minecraft.util.IChatComponent +import kotlin.math.ceil object HelpCommand { @@ -50,7 +51,7 @@ object HelpCommand { val filtered = commands.filter { it.name.contains(search, ignoreCase = true) || it.description.contains(search, ignoreCase = true) } - val maxPage = filtered.size / COMMANDS_PER_PAGE + 1 + val maxPage = ceil(filtered.size.toDouble() / COMMANDS_PER_PAGE).toInt() val page = page.coerceIn(1, maxPage) val title = if (search.isEmpty()) "§6SkyHanni Commands" else "§6SkyHanni Commands matching '$search'" -- cgit