Added addon request system to request data from an addon in spigot plugins #400
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So I've been trying to directly get a players island level from one of my plugins but I've been having issues because spigot plugins can not use classes from Addons. (This was discussed in this issue: #352)
I see there is an option to listen for AddonEvent to receive data, but this would requiring caching of any data received, and this could be a struggle if wanting to obtain offline player levels (as it was in my case)
I've added this system so that you can request data from Addons, and Addons can add handlers for these requests.
Here is an example of a request handler (to be put in an Addons code), for responding to a level request. This code would be ran through the main class of the Addon using #registerRequestHandler.
Here is an example of request to an Addon (to be put in a spigot plugin), to request a player's island level.
I've tested this myself and it works perfectly. This would be an amazing help for developers trying to obtain data from Addons as it would remove the need to cache data after listening through AddonEvent.
I made an effort to maintain the code style of your plugin, there shouldn't be any inconsistencies.
I hope you consider my pull request.