Developer API
Here you can view some examples and usages on how to use the developer API for Player Auctions. You can view the official JavaDocs for Player Auctions here.

Java Docs

Here you can view the Java Docs here for Player Auctions which provides you all the usages and descriptions of the API.

Maven Repository

Do you want to integrate with Player Auctions in your plugin? You can use the OlzieDev repo to build against the Player Auctions 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 Auctions 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>playerauctions-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 Auctions 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
PlayerAuctionsAPI api = PlayerAuctionsAPI.getInstance();
8
9
PlayerAuctionsAPI.getInstance(api -> { // accessing the instance when its ready.
10
11
});
Copied!

Some examples

Here is an example on how to create a player auction.
1
PlayerAuctionsAPI.getInstance(api -> {
2
APlayer seller = api.getAuctionPlayer(UUID.randomUUID());
3
api.createPlayerAuction(1000, seller, false, auction -> {
4
5
});
6
});
Copied!
Here is an example on how to access a auction player by their UUID.
1
PlayerAuctionsAPI.getInstance(api -> {
2
APlayer player = api.getAuctionPlayer(UUID.randomUUID());
3
// set all the auctions as expired.
4
player.getPlayerAuctions().forEach(auction -> auction.setExpireTime(null, null, false, false));
5
});
Copied!
There are also some events provided by the API, here are some examples.
1
package example;
2
3
import com.olziedev.playerauctions.api.events.PlayerAuctionSellEvent;
4
import com.olziedev.playerauctions.api.events.PlayerAuctionBuyEvent;
5
import com.olziedev.playerauctions.api.auction.Auction;
6
import org.bukkit.Bukkit;
7
import org.bukkit.event.EventHandler;
8
import org.bukkit.event.Listener;
9
10
public class AuctionEvents implements Listener {
11
12
public AuctionEvents() {
13
Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
14
}
15
16
@EventHandler
17
public void onAuction(PlayerAuctionSellEvent event) {
18
Auction auction = event.getPlayerAuction();
19
if (auction.getPrice() < 10) return;
20
21
event.setCancelled(true);
22
}
23
24
@EventHandler
25
public void onBuy(PlayerAuctionBuyEvent event) {
26
Auction auction = event.getPlayerAuction();
27
if (auction.getAuctionPlayer().getName().equals("Olzie-12") return;
28
29
event.setCancelled(true);
30
}
31
}
Copied!
Last modified 10d ago