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

Support Enhanced Format Strings for Component #1144

Closed
aikar opened this issue Jun 10, 2018 · 7 comments
Closed

Support Enhanced Format Strings for Component #1144

aikar opened this issue Jun 10, 2018 · 7 comments
Labels
help wanted Community assistance requested, PRs welcome. status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. status: input wanted Looking for community feedback on this issue. type: feature Request for a new Feature.

Comments

@aikar
Copy link
Member

aikar commented Jun 10, 2018

While the component API is nice for when you can structure your messages in code, the API is not friendly for storing message formats, for solving I18N and the AsyncChatEvent

Adding a new chat event for components is messy and hard to understand (who is priority? how does 2+ plugins even manipulate the format? what if one wants components, then one that wants to be "last" wants text?)

Converting back and forth between every event is sloppy.

I propose we implement a Textual version of components like {click:url:https://google.com}go to google{/click}, that can be part of the legacy>component conversion API
@MiniDigger has a parser here: https://github.com/VoxelGamesLib/VoxelGamesLibv2/blob/master/VoxelGamesLib/src/main/java/com/voxelgameslib/voxelgameslib/lang/LangFormatter.java#L104

This looks to be a great fit if converted.

This enables you to then use this enhanced format strings in any chat message from plugins, enabling you to define them in I18N language files too.

This is also almost required for properly implementing I18N considering what text is modified might vary by language, which is insanely difficult to handle in code.

I suggest settings.enhanced-chat-format: true for config on to use this system.
I propose to the team the default be on, as the syntax used by VGL's parser is extremely unlikely to false positive hit an existing plugins chat messages.

We will need to strip the parser codes in ChatColor.stripColors too.

@aikar aikar added help wanted Community assistance requested, PRs welcome. type: feature Request for a new Feature. status: input wanted Looking for community feedback on this issue. status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. labels Jun 10, 2018
@aikar
Copy link
Member Author

aikar commented Jun 10, 2018

We would need to be sure to strip parser tokens from players input too, or maybe by permission check?

otherwise players could write parser tokens.

@MiniDigger
Copy link
Member

I am open to PRing this if this is something that the team wants. the parser would need to be converted from kashike's text lib to bungees chat lib which should be easy to do.
for the stripColors method it might be feasible to just reuse the toPlainText the bungee api offers.

for more examples of the format, see this file: https://github.com/VoxelGamesLib/VoxelGamesLibv2/blob/master/VoxelGamesLib/src/main/java/com/voxelgameslib/voxelgameslib/lang/LangKey.java#L59

@Brokkonaut
Copy link
Contributor

I would recommend escaping of special tokens instead of stripping, so no data would be lost. user input should be escaped by default. if a chatplugin decides the user is allowed to use those tokens it can unescape the string or parts of it

@mikroskeem
Copy link
Contributor

Tokens should be indeed escaped by default.

@MiniDigger
Copy link
Member

@MiniDigger
Copy link
Member

just a bit brainstorming here, looking for comments:

  • we need a way to convert enhanced format strings -> bungee chat components
  • do we need a way to convert bungee chat components -> enhanced format strings too?
  • we need a way to escape tokens (player input)
  • we need a way to strip tokens (ChatColor.stripColors, maybe bungees toPlainText can be of use)
  • we need a setEnhancedFormat method in ChatEvents (with placeholders for name and msg)
  • we need getters and setters that use the enhanced string format for chat events
  • we need a sendMessage method that uses the enhanced string format for players (what about console?)
  • we need a config option to hide the stuff behind (what exactly should it do? how should the api methods behave when the option is false?)

@kashike
Copy link
Member

kashike commented Dec 3, 2020

This is being folded into #4830.

@kashike kashike closed this as completed Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Community assistance requested, PRs welcome. status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. status: input wanted Looking for community feedback on this issue. type: feature Request for a new Feature.
Projects
None yet
Development

No branches or pull requests

5 participants