Skip to content

[Discussion] Adapt or overhaul message sending system #2391

@mdcfe

Description

@mdcfe

Discussion

Note that this is a discussion thread, and does not currently indicate any planned features. Instead, it exists to allow people to comment and suggest changes to a particular part of EssentialsX in one consolidated thread.

Summary
Several changes to or a total overhaul of how EssentialsX constructs and sends messages. (To clarify; "messages" means any text sent from the plugin to a user/the console, not private messages.)

Problems with the current system
Currently, EssentialsX stores its messages in several messages[...].properties files. These are accessed with the static I18n.tl method used throughout the plugin, which loads the corresponding message from the default or user-created messages files, substitutes in any required parameters like player names or other translated messages, and returns it ready to be sent out. However, this has some flaws:

  • Placeholders use a format that is not particularly descriptive (and feels non-standard)
    • You either have to guess what the placeholders do based on then default messages or read the EssentialsX source, both of which can be daunting for server admins and translators.
    • PlaceholderAPI isn't supported, and trying to add support was difficult as we needed to change every place a message was used in code just to provide a player to PlaceholderAPI.
  • Colour codes are currently recorded as \u00a7x, where \u00a7 is the § symbol and x is the hexadecimal colour code.
    • If you haven't memorised these colour codes, editing EssentialsX messages becomes a tedious chore.
    • Update: EssentialsX now uses Crowdin, which alleviates some of the issues with this.
  • There is absolutely no way to utilise Minecraft's modern chat features like hover/click events due to a lack of any JSON support.
    • This has been requested several times already, but isn't currently very easy to implement without significant changes.
  • Usage messages can only be controlled via plugin.yml, not in the standard messages file.

Possible improvements

  • Allow JSON in messages files.
    • This finally gives people the ability to use hover and click events.
  • Split messages across several files by category.
    • For example, we could have a "usage" file, an "errors" file, a "economy" file etc.
    • EssentialsX doesn't need to know where the messages come from as long as they're present.
    • Users can alter this structure however they want, and EssentialsX will just load all the files that match the right locale.
  • Use a chat component library like md_5's chat API (shipped with Spigot but not CB) or KyoriPowered/text (well-known)
    • Picking one of these libraries could make supporting JSON features much easier.
    • We would need to shade in the library, as they are not shipped with Bukkit itself.
    • These libraries would likely need additional supporting code to allow for more advanced features such as the ones mentioned below.
  • PlaceholderAPI support considered from day one.
    • PAPI includes supports for hundreds more placeholders than we could implement by ourselves.
    • PAPI requires a player to be provided as context, otherwise most expansions won't know what to retrieve placeholders for.
  • Support named placeholders in messages files, like {target} or {location}
    • These are easier for translators and server admins to understand, compared to the cryptic {0} {1} {2} littered throughout the messages files.
    • These could be extended to support tiny script-like expressions, like {player is god} -> "true"/"false" or {target afkmessage} -> "getting lunch", thought this likely wouldn't be a priority.
      • This could even be how we specify which player is used for PAPI placeholders - for example, {target %luckperms_track%}.

Concerns

  • Lots of servers already have pre-existing custom messages.properties files, and EssentialsX has several community translations in this format.
    • We'd need to either find a way of not breaking compatibility, or automatically migrating these files if we change the format.

This is the write-up of several thoughts I've had over the past few months. Any further suggestions or feedback on EssentialsX is welcome in the replies below.

Metadata

Metadata

Assignees

Labels

type: discussionThread for discussion of large changes to the plugin.type: enhancementFeatures and feature requests.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions