Withdraw API
Overview
Getting Started
1
import me.fergs.phantomdungeons.modules.withdraw.api.WithdrawAPI;
// Get the singleton instance
WithdrawAPI withdrawAPI = WithdrawAPI.get();2
import me.fergs.phantomdungeons.modules.withdraw.api.WithdrawAPI;
import me.fergs.phantomdungeons.modules.withdraw.api.WithdrawAPIProvider;
public class MyPlugin extends JavaPlugin {
private WithdrawAPI withdrawAPI;
@Override
public void onEnable() {
if (!WithdrawAPIProvider.isAvailable()) {
getLogger().warning("Withdraw module not loaded!");
return;
}
this.withdrawAPI = WithdrawAPI.get();
getLogger().info("Hooked into withdraw!");
}
public WithdrawAPI getWithdrawAPI() {
return withdrawAPI;
}
}3
import me.fergs.phantomdungeons.modules.withdraw.api.WithdrawAPI;
import me.fergs.phantomdungeons.modules.withdraw.api.WithdrawAPIProvider;
if (!WithdrawAPIProvider.isAvailable()) {
getLogger().warning("Withdraw API not available!");
return;
}
WithdrawAPI api = WithdrawAPI.get();Core Operations
1
Set<String> currencies = withdrawAPI.getAvailableCurrencies();
boolean canWithdrawMoney = withdrawAPI.canWithdraw("money");
boolean enabled = withdrawAPI.isEnabled();2
double minMoney = withdrawAPI.getMinAmount("money");
double maxMoney = withdrawAPI.getMaxAmount("money");3
ItemStack note = withdrawAPI.createWithdrawItem("money", 1000.0);
if (note != null) {
player.getInventory().addItem(note);
}UUID customId = UUID.randomUUID();
ItemStack note = withdrawAPI.createWithdrawItem("money", 5000.0, customId);4
if (!withdrawAPI.isWithdrawItem(item)) {
return;
}
String currencyId = withdrawAPI.getCurrencyFromItem(item);
double amount = withdrawAPI.getAmountFromItem(item);
UUID withdrawUuid = withdrawAPI.getUuidFromItem(item);5
withdrawAPI.withdraw(player, "money", 2500.0)
.thenAccept(success -> {
if (!success) {
player.sendMessage("failed");
return;
}
Bukkit.getScheduler().runTask(plugin, () ->
player.sendMessage("done"));
});6
withdrawAPI.redeem(player, item)
.thenAccept(success -> {
if (success) {
Bukkit.getScheduler().runTask(plugin, () ->
player.sendMessage("Withdraw note redeemed!"));
}
});Cooldown Access
1
if (withdrawAPI.isOnCooldown(player)) {
int remainingSeconds = withdrawAPI.getRemainingCooldown(player);
player.sendMessage("You must wait " + remainingSeconds + "s before withdrawing again.");
}Config & Item Behavior
1
2
Events API
1
Method
Returns
2
Method
Returns
FAQ
Last updated