Developer API
Here you can view some examples and usages on how to use the developer API for Player Warps.

Java Docs

Here you can view the Java Docs here 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.
1
<repositories>
2
...
3
<repository>
4
<id>olzie-repo</id>
5
<url>https://repo.olziedev.com/</url>
6
</repository>
7
</repositories>
Copied!
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.
1
<dependencies>
2
...
3
<dependency>
4
<groupId>com.olziedev</groupId>
5
<artifactId>playerwarps-api</artifactId>
6
<version>VERSION_HERE</version>
7
<scope>provided</scope>
8
</dependency>
9
</dependencies>
Copied!

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.
1
/*
2
Accessing the instance, can return null if not loaded.
3
4
This instance can also change when a plugin reload has
5
happened, so its not advisted to use this
6
*/
7
PlayerWarpsAPI api = PlayerWarpsAPI.getInstance();
8
9
PlayerWarpsAPI.getInstance(api -> { // accessing the instance when its ready.
10
11
});
Copied!

Some examples

Here is an example on how to create a player warp.
1
PlayerWarpsAPI.getInstance(api -> {
2
Location loc = new Location(Bukkit.getWorld("world"), 0, 64, 0);
3
WPlayer owner = api.getWarpPlayer(UUID.randomUUID())
4
api.createPlayerWarp("Warp", loc, owner, Bukkit.getConsoleSender(), warp -> {
5
6
});
7
});
Copied!
Here is an example on how to access a player warp by its name.
1
PlayerWarpsAPI.getInstance(api -> {
2
Warp warp = api.getPlayerWarp("Warp");
3
if (warp == null) return; // warp doesn't exist.
4
5
warp.setWarpName("Warp2"); // set the name from "Warp" to "Warp2"
6
});
Copied!
Here is an example on how to access a warp player by their UUID.
1
PlayerWarpsAPI.getInstance(api -> {
2
WPlayer player = api.getWarpPlayer(UUID.randomUUID());
3
// set all the players warps as locked.
4
player.getWarps(false).forEach(warp -> warp.setWarpLocked(true));
5
});
Copied!
There are also some events provided by the API, here are some examples.
1
package example;
2
3
import com.olziedev.playerwarps.api.events.PlayerWarpCreateEvent;
4
import com.olziedev.playerwarps.api.events.PlayerWarpRemoveEvent;
5
import com.olziedev.playerwarps.api.warp.Warp;
6
import org.bukkit.Bukkit;
7
import org.bukkit.event.EventHandler;
8
import org.bukkit.event.Listener;
9
10
public class WarpEvents implements Listener {
11
12
public WarpEvents() {
13
Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
14
}
15
16
@EventHandler
17
public void onCreate(PlayerWarpCreateEvent event) {
18
Warp warp = event.getPlayerWarp();
19
if (!warp.getWarpName().equals("Warp")) return;
20
21
warp.setWarpLocked(true);
22
}
23
24
@EventHandler
25
public void onRemove(PlayerWarpRemoveEvent event) {
26
Warp warp = event.getPlayerWarp();
27
if (!warp.getWarpName().equals("Warp")) return;
28
29
event.setCancelled(true);
30
}
31
}
Copied!
Last modified 10d ago