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.
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.
Some examples
Here is an example on how to create a player auction.
Here is an example on how to access a auction player by their UUID.
/*
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
*/
PlayerAuctionsAPI api = PlayerAuctionsAPI.getInstance();
PlayerAuctionsAPI.getInstance(api -> { // accessing the instance when its ready.
});
PlayerAuctionsAPI.getInstance(api -> {
APlayer seller = api.getAuctionPlayer(UUID.randomUUID());
// now this could possibly throw an error if the default product provider is not an ItemStack provider.
// By default player auctions does use an ItemStack provider, but another plugin might integrate and change it.
AProductProvider<ItemStack> provider = (AProductProvider<ItemStack>) api.getDefaultProductProvider();
ItemStack itemStack = new ItemStack(Material.DIAMOND, 1);
// you can either create your own itemstack object, it grab the item safely from their hand using provider#setupProduct(long, Player)
api.createPlayerAuction(1000d,
seller,
provider.setupProduct(1L, itemStack),
false,
auction -> {
// the auction instance.
});
});
PlayerAuctionsAPI.getInstance(api -> {
APlayer player = api.getAuctionPlayer(UUID.randomUUID());
// set all the auctions as expired.
player.getPlayerAuctions().forEach(auction -> auction.setExpireTime(null, null, false));
});