Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Footer is always longer than header with Pagination #3

Open
501warhead opened this issue Jul 23, 2019 · 4 comments
Open

Footer is always longer than header with Pagination #3

501warhead opened this issue Jul 23, 2019 · 4 comments

Comments

@501warhead
Copy link

This may be a mistake on my end, attempting to integrate this API with my recent works and having some difficulty with pagination. No matter what I attempt to do, the footer is always slightly longer than the header. I've attempted at this point any number of fixes and tried digging for some potential solutions.

I do know this is still a very new feature, so I figured I'd at least provide a bug report for my findings to see if it helps

Version: 3.0.2

Using text-serializer-gson,text-feature-pagination, and text-api with text-bukkit-adapter

Platform is Paper

Width: 53
image

Width: 50
image

With longer title, width 50
image

Width 50 with dummy data to cause pagination
image

smol title
image

Code (In Kotlin) ((An abomination of formatting, I apologize in advance))

return Pagination.builder().line { cs ->
            cs.character('=')
        }.width(53).build(TextComponent.of("Charters").color(TextColor.GOLD), Pagination.Renderer.RowRenderer { value, index ->
            return@RowRenderer listOf(if (value == null) TextComponent.of("${index + 1}. ").color(TextColor.YELLOW).content("ERR?").color(TextColor.RED) else
                TextComponent.of("${index + 1}. ")
                        .color(TextColor.YELLOW)
                        .append(TextComponent.of(value.name).color(TextColor.GRAY))
                        .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to view this charter").color(TextColor.GRAY)))
                        .clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/charter info ${value.name}")))
        }, Pagination.PageCommandFunction { page -> "/charter list -page $page" })
        val rendered = settlementService.buildSettlementPagination().render(settlementService.dummyData().sortedBy { settlement -> settlement.name }, page)
        rendered.forEach { comp ->
            TextAdapter.sendComponent(p, comp)
        }
@lucko
Copy link
Member

lucko commented Jul 23, 2019

If you test in the console, they will match up ;)

This is because characters have different pixel lengths in the default Minecraft font.

@501warhead
Copy link
Author

That makes sense, but that's a bit difficult isn't it? Doesn't that mean if you use any non-minecraft language selection (I forget what they're called currently, Unicode fonts maybe?) it'd break if you automatically adjusted for the Minecraft font?

@lucko
Copy link
Member

lucko commented Jul 24, 2019

Yes, we could adjust for the Minecraft chat pixel lengths - but then it would be wrong in console, or if you used a different font in your resource pack.

@501warhead
Copy link
Author

501warhead commented Jul 24, 2019

Alright. I think I have a few hacky solutions to try then now that I understand the problem a bit better, though maybe it'd be nice to have some ability to disable the extra character padding? I don't think I saw anything obvious when I was using the API, though maybe setting styleandcharacter character to null might be it?

Anyway, thank you for the information!

@zml2008 zml2008 transferred this issue from KyoriPowered/adventure Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants