DevSrSouza/KotlinBukkitAPI

Pagination documentation?

Closed this issue · 2 comments

I want to try it but I had no clue, here's what I've written:

menu(+"Main Page", 3, true) {
	val list = (1..100).toMutableList().asObservable()
	val prev = slot(3, 1, item(Material.DIAMOND_SWORD).displayName("Previous Page")) {}
	val next = slot(3, 9, item(Material.GOLD_INGOT).displayName(+"Next Page")) {}

	list.observe {
		logger.info(it.toString())
	}

	pagination(list, prev, next) {}
	openToPlayer(sender)
}

Suppose we have a situation that we want to write a pagination to list past players recorded in the database and check their criminal records (bruh) and stuff, how do you know which player did you clicked in the menu? Also, is it possible we can use fragment frames like in Android so that we can compose the menu from different smaller pieces?

I don't got much time to do the Pagination Documentation because can get a little complex. Here is a sample code of how you can listen and set the items in the pagination.

pagination(list, prev, next) {
  slot {
    onRender { oneListEntry ->
       showingItem = item(Material.PAPER).displayName("Number: $oneListEntry")
    }
   onClick { oneListEntry ->
       player.msg("you click at the number: $oneListEntry")
   }
  }
}

Hope this helps you until I have a proper documentation for it. Pagination can do much more than that, like filtering/reorder your list content based on Player Data, this could be used to order for the player with the most "criminal records". I will cover all of it in the documentation soon.

I never think about doing something like fragment frames but I will see more about that.