Introduction
Brief Explanation of what it is, why it's here and how it works
What is ProtectionAPI?
ProtectionAPI is a developer api that creates a bridge across protection plugin providers for much easier querying. This API runs in a similar fashion to Vault and in fact uses some of its registry methods.
At the moment, the api currently only supports basic region contents such as region locations, owners, admins, members, welcome messages, farewell messages etc. However, with the design structure of the api it's very easy to expand upon this.
You can view the change log to keep updated
Adding it as a Dependency
This step is relatively simple.
For Maven projects:
Remember to change the version with the latest version in the change log.
For Gradle projects:
Manually adding
If for some reason you don't use maven or gradle, you can still add the jar manually to your classpath. See why you should use maven.
IntelliJ
Click on File -> Project Structure (Ctrl + Alt + Shift + S on windows)
Go to the tab Modules
Click the + on the right side and choose Library... -> Java
Select the ProtectionAPI.jar (You can download this on the resource homepage)
Eclipse
Rightclick your project and choose "Properties -> Java Build Path".
Click on "Add external jar" and add the ProtectionAPI.jar (You can download this on the resource homepage) to your project.
Plugin.yml
You need to add the API as a dependency to your plugin.yml.
Timings (1.15.2)
UniversalRegion - Assigning bounds & world:
100 Regions <1ms
1000 Regions 1-2ms
10000 Regions 4-8ms
100000 Regions 11-18ms
1Million Regions: 650-4000ms (Very varied, average 1500ms)
UniversalRegion - Assigning bounds & world & collision detection
10 Regions: <1ms
Octree enabled:
100 Regions <1ms
1000 Regions 1-2ms
10000 Regions 5-8ms
100000 Regions 14-20ms
Why does this exist?
Too many times have I come across a need to check if a structure / player is inside or intersecting with a protected area. However, there is no good way to check if someone is inside of a protected area with the ever-expanding region provider plugins. With this algorithm, it allows you to squash and merge some region providers' protected regions and check against them.
The end goal is to be like how Vault is with Economy and Permissions plugins.
How does it work?
This API registers all enabled and supported region provider plugins in a similar fashion to vault. So an interface interacts with the primary region provider modules.
Also, when checking for collision (intersection) after a set amount of regions is surpassed the octree kicks in and essentially splits the regions into their own octanes. This then allows the octree to check for near regions based upon the octane coordinates and their child nodes as oppose to cycling through every single region and running the intersection method.
Last updated