Skip to content

Event API

EmakiStorage exposes three Bukkit events so third-party plugins can intercept or record the deposit, withdraw and paid-expansion flows. The event classes live in the emaki.jiuwu.craft.storage.api.event package.

All three events below are plain Bukkit events for third-party consumption and are not CoreLib gameplay facts. Listen to them with a standard @EventHandler. All three implement Cancellable.

EventWhen it firesEffect of cancelling
StorageDepositEventOn the owning entity thread, immediately before the inventory removal and entry-table mutation.Aborts the whole transaction: nothing is removed from the inventory and no entry changes.
StorageWithdrawEventOn the owning entity thread, before the entry amount is debited. Fired by the GUI, command and action paths; EmakiStorageApi.withdraw does not fire it.Aborts the whole transaction: the stored amount is untouched.
StorageUnlockEventAfter the price has been computed but before any currency or item is taken.Cancelling costs the player nothing.

StorageDepositEvent

MethodDescription
playerId()The storage owner.
template()A copy of the item being deposited, amount normalised to 1. Mutating it has no effect on stored data.
requestedAmount()How many units the caller asked to deposit.
source()The originating surface: gui / command / api / action.

StorageWithdrawEvent

MethodDescription
playerId()The storage owner.
template()A copy of the item being withdrawn, amount normalised to 1.
requestedAmount()How many units the caller asked to withdraw.
storedAmount()How many units the entry held before this operation.
source()The originating surface.

EmakiStorageApi.withdraw debits the entry directly and does not fire this event; the transactional implementation behind the GUI, command and action paths does. That is the fact of the current implementation and it is asymmetric with StorageDepositEvent. If your plugin relies on the withdraw event for validation, note that the API path cannot be intercepted.

StorageUnlockEvent

MethodDescription
playerId()The storage owner.
slotAmount()How many slots are being unlocked in this operation.
purchasedSlotsBefore()How many slots the player had already purchased.
currencyCost()The summed currency price, computed per slot rather than unit price times count.
source()The originating surface.

Listener Example

java
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import emaki.jiuwu.craft.storage.api.event.StorageDepositEvent;

public final class StorageListener implements Listener {

    @EventHandler
    public void onDeposit(StorageDepositEvent event) {
        if (event.template().getType() == org.bukkit.Material.BEDROCK) {
            event.setCancelled(true);
        }
    }
}