Developers

View the Developer API for Vouchers.

VoucherRedeemEvent

This event is fired when the player tries to redeem a voucher by right-clicking it. This event is only fired on a successful fire, meaning not in a blacklisted region or world.

@EventHandler
public void onVoucherRedeem(VoucherRedeemEvent e) {
 // Player redeeming the pouch.
 Player player = e.getPlayer();
 
 // The voucher object (one being redeemed).
 Voucher pouch = e.getVoucher();
 
 // The randomly generated amount.
 Long amount = e.getAmount();
 
 // The itemstack for the pouch.
 ItemStack voucherItem = e.getItem();
 
 // The slot this voucher is being redeemed in.
 // Applies only to mc version 1.9+.
 VoucherSlot slot = e.getSlot();
  
 // Is the event cancelled? Returns boolean.
 e.isCancelled();
 
 // Should we cancel the event?
 e.setCancelled(boolean);
}

Last updated