Open TheBusyBiscuit opened 3 years ago
Thanks for the input!
you're missing the helper method in the PaperLib class (and its javadocs)
Whoops, I somehow completely forgot about that, thanks for spotting it. I agree with the name changes for the classes as they seem more reflective of the internal logic here, also implemented the reflection-check you suggested for the method. Probably much better than simply relying on people to update their software.
https://github.com/PaperMC/Paper/pull/4687 has introduced the ability to get an
OfflinePlayer
by their name without making a web request.To properly utilise this feature in a Spigot-compatible environment, we currently need to rely on an
isPaper
and a version check to even see whether one is able to optimize for that. I think this is a perfect opportunity for aPaperLib
implementation.This is just a basic implementation which was done in a similar manner to how the
BlockStateSnapshot
is handled. The booleanmakeWebRequest
determines whether a web request is allowed. In environments that do not supportBukkit.getOfflinePlayerIfCached()
, this boolean is just ignored. Similar to howBlockStateSnapshot
will ignore theuseSnapshot
boolean if unsupported.Of course, the
Bukkit.getOfflinePlayerIfCached()
method will not be available in every single 1.16.4-compatible build of Paper I presume, but I am gonna assume the typical "old versions are not supported anyway" situation here for now. Lemme know if there is anything that should be changed or documented.