Fix pagination only removing a single layer

master
ALI Hamza 2020-04-05 22:50:28 +07:00
parent 8f46237750
commit b39672a256
No known key found for this signature in database
GPG Key ID: BCA8A46C87798C4C
1 changed files with 2 additions and 1 deletions

@ -7,6 +7,7 @@ import org.bukkit.configuration.ConfigurationSection
import org.bukkit.entity.Player import org.bukkit.entity.Player
import org.bukkit.inventory.Inventory import org.bukkit.inventory.Inventory
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import kotlin.math.max
val String.c: String val String.c: String
get() = ChatColor.translateAlternateColorCodes('&', this) get() = ChatColor.translateAlternateColorCodes('&', this)
@ -48,7 +49,7 @@ fun makeInventory(
if (page != total) setItem(menuRow + 8, buttons.forward) if (page != total) setItem(menuRow + 8, buttons.forward)
} }
val dropping = (page - 1) * (size - kotlin.math.max(0, menuRow)) val dropping = (page - 1) * (if(menuRow > 0) (size - 9) else size)
items.drop(dropping).forEach { items.drop(dropping).forEach {
if (firstEmpty() != -1) setItem(firstEmpty(), it.item) if (firstEmpty() != -1) setItem(firstEmpty(), it.item)
else return@apply else return@apply