inventory-framework
inventory-framework copied to clipboard
Pagination#canAdvance and Pagination#canBack always true
Is there an existing issue for this?
- [X] I have searched the existing issues
🐛 Describe the bug
Hello I have an Kotlin extension function looking like this:
@JvmStatic
fun RenderContext.pagination(state: State<Pagination>, fallBack: ViewItems = ViewItems.MENU_PLACEHOLDER) {
"NP".forEach { layoutSlot(it, fallBack.get()) }
layoutSlot('N', ViewItems.NEXT_PAGE.get()).displayIf { c -> state.get(c).canAdvance() }
.updateOnStateChange(state)
.onClick { context ->
val pagination = state.get(context)
pagination.advance()
CustomSounds.MENU_CLICK.playSound(this.player)
}
layoutSlot('P').displayIf { c -> state.get(c).canBack() }
.updateOnStateChange(state)
.onClick { context ->
val pagination = state.get(context)
pagination.back()
CustomSounds.MENU_CLICK.playSound(this.player)
}
}
It adds next and Previous buttons to a layout, my issue is here that they are always added, no matter of there is just 1 or 50 Items in the Pennington.
This Problem only exists with all computedPagintons
✔️ Expected behavior
Well, that the items are not displayed if there is no next or previous site.
👣 Steps to Reproduce
No response
💻 Platform
- [X] Bukkit
- [ ] Sponge
- [ ] Other
⭐ Server Version
Paper version 1.21.1-122-master@4430e96 (2024-10-12T21:18:42Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
📚 Library Version
3.0.11
✍️ Additional context
No response