TriumphTeam / triumph-gui

Simple lib to create inventory GUIs for Bukkit platforms.
MIT License
330 stars 57 forks source link

updateTitle accepts string only #97

Open JoJeki opened 1 year ago

JoJeki commented 1 year ago

I have a problem with refreshing the equipment title. The website states that this option accepts components, but in practice, it requires a string. When converting the component to a string, it loses its colors. I have the newest triumpgui version. image

LichtHund commented 1 year ago

Hello, yeah updateTitle is in a bit of a tough spot, due to the lib supporting both spigot and paper and also having components, adding the update title as component would be rough without major rewrite of how it works right now. Due to that I left it untouched for now. I would suggest just re-opening the gui if you need to update it. It's not that much different than what the updateTitle would do anyways.

JoJeki commented 1 year ago

But what when i use updateTitle right after ".next() .previous()"??? if i reopen gui it will open on first page but title will show "titlename (2/3)" ;/ there is any better solution or maybe small chance for remake of updatetitle to component?

LichtHund commented 1 year ago

There is 2 things you can do I guess, you can open the menu on a specific page instead of using next and previous, for example open(player, gui.getCurrentPageNum() + 1). Second thing you can do is call updateTile and serialize the component into string using the legacy serializer.

emmanuelvlad commented 1 year ago

There is also another issue when using the GuiBuilder, Translatable component doesn't work in title

Ex.

Gui.gui()
  .title(Component.translatable("gamerule.doInsomnia"))
  .create();

This should display Spawn phantoms but will display the translatable key instead (gamerule.doInsomnia)

iGabyTM commented 1 year ago

There is also another issue when using the GuiBuilder, Translatable component doesn't work in title

Ex.

Gui.gui()
  .title(Component.translatable("gamerule.doInsomnia"))
  .create();

This should display Spawn phantoms but will display the translatable key instead (gamerule.doInsomnia)

That happens because unlike the name & lore of the items which are set via reflection, the title can't be set in the same way in order to support components completely.