📗
Wiki
  • WIKI
  • Plugins
    • InfoHeads
      • Installation
      • FAQ
      • Using the Wizard
    • MailMe
      • Updating to MailMe Rewrite
      • FAQ
      • Setup
      • Tutorials
        • Niche
        • MailPresets
      • API
        • Setup
        • Interacting with the Database
  • Libraries
    • ProtectionAPI
      • Introduction
      • Getting Started
      • Tutorials
        • Creating a UniversalRegion
        • Collision Detection
      • Change Log
    • HexiTextLib
      • Introduction
      • Setup
        • Gradle
        • Maven
      • Using HexResolver
      • Using FontResolver
      • Change Log
Powered by GitBook
On this page
  • What is ProtectionAPI?
  • Adding it as a Dependency
  • Plugin.yml
  • Timings (1.15.2)
  • Why does this exist?
  • How does it work?

Was this helpful?

  1. Libraries
  2. ProtectionAPI

Introduction

Brief Explanation of what it is, why it's here and how it works

PreviousProtectionAPINextGetting Started

Last updated 5 years ago

Was this helpful?

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 to keep updated

Adding it as a Dependency

This step is relatively simple.

For Maven projects:

pom.xml
<dependencies>
  <dependency>
    <groupId>com.haroldstudios</groupId>
    <artifactId>ProtectionAPI</artifactId>
    <version>{VERSION}</version>
  </dependency>
</dependencies>

Remember to change the version with the latest version in the change log.

For Gradle projects:

build.gradle
repositories {
    mavenCentral()
}

dependencies {
    compileOnly 'com.haroldstudios:ProtectionAPI:{VERSION}'
}

Manually adding

IntelliJ

  1. Click on File -> Project Structure (Ctrl + Alt + Shift + S on windows)

  2. Go to the tab Modules

  3. Click the + on the right side and choose Library... -> Java

  4. Select the ProtectionAPI.jar (You can download this on the resource homepage)

Eclipse

  1. Rightclick your project and choose "Properties -> Java Build Path".

  2. 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.

// Can't function without it?
depend: [ProtectionAPI]
// Can function without it?
soft-depend: [ProtectionAPI]

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.

If for some reason you don't use maven or gradle, you can still add the jar manually to your classpath. See .

change log
why you should use maven