# Setup

### Step 1: Adding JAR file into the project

{% tabs %}
{% tab title="Maven" %}

```xml
<dependency>
            <groupId>be.alexandre01.dreamnetwork</groupId>
            <artifactId>DreamNetwork-Plugin</artifactId>
            <version>1.3.0-SNAPSHOT</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/libs/DreamNetwork-Plugin-api.jar</systemPath>
</dependency>
```

You need to set the code block in your dependencies inside your pom.xml
{% endtab %}
{% endtabs %}

### Step 2: Create and register a Bukkit/Bungee Listener

Create Listener class

{% tabs %}
{% tab title="Spigot Listener Class" %}

```java
public class InitializeListener implements Listener {
    final MainClass main;
    public InitializeListener(MainClass main){
        this.main = main;
    }
    @EventHandler
    public void onInitialize(ServerAttachedEvent event){
        main.setSpigotAPI((DNSpigotAPI) DNSpigotAPI.getInstance());
    }
}
```

{% endtab %}

{% tab title="Bungee Listener Class" %}

```java
public class InitializeListener implements Listener {
    final MainClass main;
    public InitializeListener(MainClass main){
        this.main = main;
    }
    @EventHandler
    public void onInitialize(ServerAttachedEvent event){
        main.setBungeeAPI((DNBungeeAPI) DNBungeeAPI.getInstance());
    }
}
```

{% endtab %}
{% endtabs %}

Register Listener

{% tabs %}
{% tab title="Spigot Main Class" %}

```java
public final class MainClass extends JavaPlugin {
    private static MainClass instance;
    private DNSpigotAPI dnSpigotAPI;

    @Override
    public void onEnable() {
        instance = this;
        getServer().getPluginManager().registerEvents(new InitializeListener(this),this);
    }

    public DNSpigotAPI getSpigotAPI() {
        return dnSpigotAPI;
    }

    public void setSpigotAPI(DNSpigotAPI dnSpigotAPI) {
        this.dnSpigotAPI = dnSpigotAPI;
    }
    public static MainClass getInstance() {
        return instance;
    }
}

```

{% endtab %}

{% tab title="Bungee Main class" %}

```java
public final class MainClass extends Plugin{
    private static MainClass instance;
    private DNBungeeAPI dnBungeeAPI;

    @Override
    public void onEnable() {
        instance = this;
        getProxy().getPluginManager().registerListener(new InitializeListener(this),this);
    }

    public DNBungeeAPI getBungeeAPI() {
        return dnBungeeAPI;
    }

    public void setBungeeAPI(DNBungee bungeeAPI) {
        this.dnSpigotAPI = dnSpigotAPI;
    }
    public static MainClass getInstance() {
        return instance;
    }
}

```

{% endtab %}
{% endtabs %}


---

# 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://altata01.gitbook.io/dreamnetwork-docs/java-api-for-developers/setup.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.
