API feature request - canBuild(location, location)
LadyCailinBot opened this issue ยท 2 comments
WORLDGUARD-3273 - Reported by BigScary
I'm taking a soft dependency on WG, and I need to quickly/efficiently determine whether or not a player has permission to build in all of a rectangular region I specify. I've tried calling WGPlugin.canBuild(location) hundreds of times as a workaround, but I'm sure you'll understand that results in very bad performance. Alternatively, asking WG to find all regions in an area and then asking about permissions in those regions works performantly, but that requires me to take a HARD dependency... if WG is not installed, my code now throws exceptions like this:
java.lang.NoClassDefFoundError: com/sk89q/worldguard/protection/regions/ProtectedRegion
I hope you can find the time to provide an API to help me do this work efficiently without taking a hard dependency, which is out of the question for my case. Thanks for taking the time to consider my request!
There are more details including my code in a WG Forums post (see link below) - I haven't received any response from the community there yet.
http://forum.enginehub.org/threads/api-problem-finding-all-regions-in-an-area.15867/
Comment by BigScary
The solution doesn't have to be exactly what I suggested in the title - I'll be VERY happy with anything at all I can use to solve my problem without taking a hard dependency. :) Thanks!
Comment by sk89q
Even if I provide an API, you would have to reference it somehow, and thus you'd have the same problem. I could provide a separate dependency that you could shade into your plugin, but if another plugin provides an older version of this dependency, then all hell may break loose.
You can work around missing API by moving all WG-referencing code into its own dedicated class, and then try {} catch {} the code that instantiates this dedicated class to handle the situation when WG is not available.