> For the complete documentation index, see [llms.txt](https://docs.olziedev.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.olziedev.com/projects/playerwarps/api.md).

# Plugin API

## Java Docs

Here you can view the Java Docs [here](https://javadocs.olziedev.com/playerwarps) for Player Warps which provides you all the usages and descriptions of the API.

## Maven Repository

Do you want to integrate with Player Warps in your plugin? You can use the OlzieDev repo to build against the Player Warps API.

Under `repositories` in your `pom.xml`, you need to add a new `repository` for the repo.

```java
<repositories>
    ...
    <repository>
        <id>olzie-repo</id>
        <url>https://repo.olziedev.com/</url>
    </repository>
</repositories>
```

Next, add Player Warps as a `dependency` under `dependencies`:

`VERSION_HERE` would be your exact plugin version, you will not need to update the API version every time a plugin update is out, only when an api update happens.

```java
<dependencies>
    ...
    <dependency>
        <groupId>com.olziedev</groupId>
        <artifactId>playerwarps-api</artifactId>
        <version>VERSION_HERE</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
```

## How to access the API

You can access the Player Warps API by getting the instance. If the plugin hasn't fully loaded the instance will return null, you can use a callback to access the API when its ready.

```java
/* 
Accessing the instance, can return null if not loaded.

This instance can also change when a plugin reload has 
happened, so its not advisted to use this
*/ 
PlayerWarpsAPI api = PlayerWarpsAPI.getInstance(); 

PlayerWarpsAPI.getInstance(api -> { // accessing the instance when its ready.

});
```

## Some examples

Here is an example on how to create a player warp.

```java
PlayerWarpsAPI.getInstance(api -> {
        Location loc = new Location(Bukkit.getWorld("world"), 0, 64, 0);
        WPlayer owner = api.getWarpPlayer(UUID.randomUUID());
        api.createPlayerWarp("Warp",
        api.createWarpLocation(loc),
        owner,
        WarpType.NORMAL,
        Bukkit.getConsoleSender(),
        warp -> {
        // the warp instance.
        });
});
```

Here is an example on how to access a player warp by its name.

```java
PlayerWarpsAPI.getInstance(api -> {
    Warp warp = api.getPlayerWarp("Warp");
    if (warp == null) return; // warp doesn't exist.
    
    warp.setWarpName("Warp2"); // set the name from "Warp" to "Warp2"
});
```

Here is an example on how to access a warp player by their UUID.

```java
PlayerWarpsAPI.getInstance(api -> {
    WPlayer player = api.getWarpPlayer(UUID.randomUUID());
    // set all the players warps as locked.
    player.getWarps(false).forEach(warp -> warp.setWarpLocked(true)); 
});
```
