AtriusX / Waystones

A small plugin that brings long-distance teleportation to Minecraft survival mode!
https://www.spigotmc.org/resources/waystones.93917/
11 stars 6 forks source link

Configurable Messages File #3

Closed luna-skye closed 3 years ago

luna-skye commented 3 years ago

It could be nice to have a YML file dedicated to configuring the messages displayed by the plugin for various actions, such as initiating a warp, successfully warping, canceling a warp, or getting info of a waystone. This could also be expanded to include the lore on linked Warp Keys.

These would just be simple string values within the file, utilizing some placeholders available through Waystones depending on context, such placeholders could be

%waystones_outofrange% - How far out of range a player is from Waystone
%waystones_distance% - Player's total distance from Waystone
%waystones_name% - Name of Waystone in question
%waystones_range% - Range a Waystone is capable of being teleported to from
%waystones_status% - Active status of Waystone, seen in InfoEvent
%waystones_coords% - Coordinates of Waystone, as seen in current WarpKey lore
%waystones_countdown% - Countdown during warmup to Waystone warp

These wouldn't have to be global like CMI or PlaceholderAPI, but rather just available through this messages config, the messages would then be parsed to replace these instances when used within the actual events.

This could also allow for custom color codes to be used, though that may require some refactoring of the Player.sendActionMessage() function within PlayerUtils.kt


The message file could look something like

InfoMessage: "&bName: %waystones_name% | Status: %waystones_active% | Range: %waystones_range%"
InitWarpMessage: "&aWarping to %waystones_name% in %waystones_countdown% second(s)"
CancelWarpMessage: "&cWarp cancelled"
OutOfRangeMessage: "&c%waystones_name% is out of range (%waystones_outofrange% block(s))"
# etc. etc.

Slightly unrelated, but this could also open up to the idea of localization, with locale files in a directory holding the messages in different languages. Though I'm unsure as to how this is actually implemented.

AtriusX commented 3 years ago

Localization is definitely a topic we haven't discussed yet. Though I personally think for the placeholder text those should be shorter and a bit more generic. Example: when we are talking about how far someone is from a waystone or how far a waystone can accept teleports from we are talking about range and distance. I don't feel there's a need to mention the plugin name in the template strings in this case.

The biggest concern is going to be determining how the system is meant to function though; since these messages are dependent on external data (waystone position, range, status, etc.) it becomes a bit harder to design the system similarly to other message templating utilities.

How localization files are managed will also affect this I think, though hopefully not too much.