# 1. Setup & Integration

To use GWorld v2 in your plugin, you must add it as a dependency.

## 1. Maven Dependency

<span style="white-space: pre-wrap;">Add the </span>`<span class="editor-theme-code">core</span>`<span style="white-space: pre-wrap;"> module from GWorld to your </span>`<span class="editor-theme-code">pom.xml</span>`<span style="white-space: pre-wrap;">. Since the API is provided by the server at runtime, we use the </span>`<span class="editor-theme-code">provided</span>`<span style="white-space: pre-wrap;"> scope.</span>

```XML
<dependency>
  <groupId>de.gilljan</groupId>
  <artifactId>gworld-core</artifactId>
  <version>2.0.1-SNAPSHOT</version>
  <scope>provided</scope>
</dependency>
```

We use the GitHub Maven Package Registry. To use it, please refer to the GitHub documentation:  
[https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#installing-a-package](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#installing-a-package)

## 2. plugin.yml

<span style="white-space: pre-wrap;">To ensure that your plugin can access GWorld, it must be loaded </span>**after**<span style="white-space: pre-wrap;"> GWorld. To do this, add the entry to your </span>`<span class="editor-theme-code">plugin.yml</span>`:

```YAML
depend: [GWorld]
# Alternatively, if GWorld is optional:
# softdepend: [GWorld]
```

## 3. Access to the API

<span style="white-space: pre-wrap;">The main entry point is the </span>`<span class="editor-theme-code">GWorldAPI</span>`<span style="white-space: pre-wrap;"> interface. You can obtain the instance using the static method of the main class.</span>

```JAVA
import de.gilljan.gworld.GWorld;
import de.gilljan.gworld.api.GWorldAPI;
import de.gilljan.gworld.api.IWorldManager;

public class MyPlugin extends JavaPlugin {
    
    private IWorldManager worldManager;

    @Override
    public void onEnable() {
        if (Bukkit.getPluginManager().isPluginEnabled("GWorld")) {
            // Retrieve API instance
            GWorldAPI api = GWorld.getInstance();
            
            // Load the manager for worlds
            this.worldManager = api.getWorldManager();
        }
    }
}
```