# Introduction

## 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](https://wiki.haroldstudios.com/protectionapi/change-log) to keep updated

## Adding it as a Dependency

This step is relatively simple.

**For Maven projects:**

{% code title="pom.xml" %}

```markup
<dependencies>
  <dependency>
    <groupId>com.haroldstudios</groupId>
    <artifactId>ProtectionAPI</artifactId>
    <version>{VERSION}</version>
  </dependency>
</dependencies>
```

{% endcode %}

{% hint style="info" %}
&#x20;Remember to change the version with the latest version in the change log.
{% endhint %}

**For Gradle projects:**

{% code title="build.gradle" %}

```bash
repositories {
    mavenCentral()
}

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

```

{% endcode %}

**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](https://www.geeksforgeeks.org/introduction-apache-maven-build-automation-tool-java-projects/).

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

```bash
// 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&#x20;
* **Octree enabled:**
* 100 Regions <1ms
* 1000 Regions 1-2ms&#x20;
* 10000 Regions 5-8ms
* 100000 Regions 14-20ms&#x20;

## 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.&#x20;

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://harrydrum0198.gitbook.io/wiki/libraries/protectionapi/introduction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
