Textbook

Textbook

24.9k Downloads

Add byte amount to fitsOnPage(), to comply with paperMC server settings

Mumberthrax opened this issue ยท 3 comments

commented

Is your feature request related to a problem? Please describe.
When pasting text of fullwidth characters using Textbook, everything works flawlessly in singleplayer; however on paper servers (depending on the settings in paper.yml under book-size -> page-max and total-multiplier) after closing the book gui, the pages may be truncated to fit a certain byte amount for the page, leaving the result of the pasted text fragmented and missing a portion at the end of most pages.

Describe the solution you'd like

  1. A user-editable value in a config file, to define the maximum amount of bytes a page may be when Textbook imports a text. Default value should be at minimum 2560 256 (Edit: paper.yml specifies 2560 for some reason-not entirely sure how it works), but most likely higher so as to not affect users of the mod in singleplayer or on servers without book restrictions.
  2. The fitsOnPage() function should, in addition to checking total character length and wrapped lines height as it currently does, check whether the total number of bytes in the string for the page is below or at the aforementioned value in the configuration file.

Additional context
Using https://lingojam.com/FullWidthTextGenerator to convert plaintext to fullwidth characters results in an easier-to-read text in MC books. An added effect is, despite the name, the text is often more compact, which means more characters fit on a page than the default plaintext in minecraft books. This means the byte size per page is greater when filled with fullwidth text.

2021-12-08_20 29 33
Import of the text through textbook.

2021-12-08_20 30 16
Import through textbook of fullwidth version of the text, converted by lingojam's conversion page linked above.

2021-12-08_20 30 37
After closing and re-opening the book edit gui on a paperMC server with default config settings, the text on each page has been truncated by the server to conform to a byte amount which is often less than the page originally imported by textbook when using fullwidth characters, as shown here.
.

commented

Thank you for the feature request, this level of detail is very helpful. I will look in to this with the next big update, though I'm not sure yet when that will be.

commented

It would be nice if paper did NOT impose these limitations, since it restricts the amount of creative freedom to explore with written books in minecraft, but because mojang designed minecraft in a way that permits book bans, it seems paper's solution is the most reasonable for now.

I tried searching on paperMC's github for the config value name, to see how they check the byte amount of the string. I found this, but it doesn't look like a proper source file to me (I'm not a java programmer) so idk if this is the actual code they're using or not but it might be useful to you: https://github.com/PaperMC/Paper/blob/c728c78c7b62eb4cf56ecd7d5aed7c0ad397ebbf/patches/server/0297-Book-Size-Limits.patch

commented

That is helpful, it looks like it's a patch they apply to the actual source file to create that limitation.