Developer API
FioVoucher exposes a small public API for plugin integrations.
Package names
import com.itzfabb.fiovoucher.api.FioVoucherAPI;
import com.itzfabb.fiovoucher.api.VoucherRedeemResult;
import com.itzfabb.fiovoucher.model.Voucher;
Accessing the API
Static access:
FioVoucherAPI api = FioVoucherAPI.get();
if (api != null && api.isPluginReady()) {
// use it
}
Main methods
Voucher getVoucher(String voucherCode);
boolean hasVoucher(String voucherCode);
Collection<Voucher> getVouchers();
Set<String> getVoucherCodes();
ItemStack createVoucherItem(String voucherCode);
List<ItemStack> createVoucherItems(String voucherCode, int amount);
boolean giveVoucher(Player player, String voucherCode, int amount);
int giveVoucherToAll(String voucherCode, int amount);
VoucherRedeemResult canRedeem(Player player, String voucherCode);
VoucherRedeemResult redeem(Player player, String voucherCode);
List<String> getPlayerHistory(Player player);
Redeem result
VoucherRedeemResult tells you whether a redeem action succeeded.
Status values:
SUCCESSPLUGIN_NOT_READYPLAYER_REQUIREDBEDROCK_BLOCKEDVOUCHER_NOT_FOUNDVOUCHER_DISABLEDVOUCHER_FROZENVOUCHER_BLACKLISTEDWORLD_BLOCKEDREGION_BLOCKEDNO_USES_LEFTMAX_CLAIM_REACHEDPERMISSION_BLOCKED
Example integration
FioVoucherAPI api = FioVoucherAPI.get();
if (api != null && api.isPluginReady()) {
VoucherRedeemResult result = api.redeem(player, "vip");
if (!result.isSuccess()) {
player.sendMessage(result.getMessage());
}
}
plugin.yml advice
Add FioVoucher as a soft or hard dependency:
softdepend:
- FioVoucher
Use depend if your plugin cannot function without it.
Notes for developers
redeem(...)executes the voucher if validation passes.canRedeem(...)validates without consuming the voucher.giveVoucher(...)creates and gives voucher items directly.getPlayerHistory(...)returns formatted history lines.