Before I forget, this is a warning about the next update I am going to post.
Update 4.0 is coming soon, and it includes some API breaking changes.
The biggest change to the API would be the
Expansion interface, which has been modified to require a different method for placeholder parsing. Now, instead of implementing
public Text onPlaceholderRequest(Player player, Optional<String> token), placeholders will be required to implement
public Object onValueRequest(Player player, Optional<String> token). This allows for several improvements both internally and externally, and standardizes the appearance of certain objects in
Text form. Of course, you could just return a
Text object like before, but I recommend returning the representative type of the placeholder token parsed. For instance,
%server_cores% would return an
Integer object, while
%server_motd% would return a
The next biggest change is the addition of
RelationalExpansion and relational placeholder parsing. This new specification allows placeholders to change the returned value based not only on who the information is about but who is observing said information. For example,
%rel_player_distance% gives the distance between the primary player and the observer, in number of blocks. Of course, this holds more power than just simple distance, and will become even more useful when this pull request is implemented. This change is breaking for any plugins (not that I expect there to be any because PlaceholderAPI provides the default implementation and should work for most if not all purposes) that implement
PlaceholderService. All relational placeholders regardless of identifier must start with
rel_ so as to denote that it is relational.
With relational placeholders there is also a minor change in the config, which is not there by default. It simply decides whether to parse relational placeholders like normal ones but for the observer. For example, if you parsed the placeholder
%rel_player_displayname% and this option was off, it would output
%rel_player_displayname%, however if it was on, it would output the displayname of the second player.
There are some other minor improvements coming with the next update as well, but I thought it would be important to mention these breaking changes and what they meant for the future of the plugin and any others that attach to it.
*As a note, I have been very busy recently so I have been unable to work very often on the plugin. This is likely to continue for the foreseeable future so any help would be appreciated, specifically with creating placeholders for other plugins. Every little bit counts, so if you have any ideas or comments, please let me know!