Skip to content

Storage

banco provides a BancoStorage interface that you can implement to support other inventories (backpacks, vaults, banks...). There is also BancoInventory and BancoContainer which already contain all the logic to add and remove items.

Registering a BancoStorage

An instance of BancoStorage has to be registered in the BancoStorageRegistry for it to work.

BancoInventory customInventory = new CustomInventory();
BancoContainer customContainer = new CustomContainer();

BancoStorageRegistry storageRegistry = banco.getStorageRegistry();
storageRegistry.register(
    customInventory, customContainer
);

Unregistering a BancoStorage

Unregistering a BancoStorage at any time is also possible with the BancoStorageRegistry::unregister method, giving developers more control over their implementations.

storageRegistry.unregister(
    customInventory, customContainer
);

Friendly names

friendlyName() can be overriden in any BancoStorage implementation. This friendly name gives server owners the possibility of giving priority to your add-on in their settings.yml. For example:

CustomInventory.java
public final class CustomInventory {

    @Override
    public String friendlyName() {
        return "CUSTOM_INVENTORY";
    }

    ...

}
settings.yml
currency:
  inventoryOrder:
  - CUSTOM_INVENTORY # CUSTOM_INVENTORY will be given priority to add/remove balance
  - BUNDLE
  - PLAYER_INVENTORY
  - ENDER_CHEST

BancoStorage

An interface that must be implemented with:

  • value(uuid), which returns uuid's stored balance
  • add(uuid, amount), which adds amount to uuid's instance of this storage
  • remove(uuid, amount), which removes amount from uuid's instance of this storage
  • Pros


    Gives developers more control over their storage implementations

    Generally more stable

  • Cons


    Developers have to code their own logic to add and remove balance

BancoInventory

An abstract class that must be extended with:

  • get(uuid), which returns uuid's Inventory
  • Pros


    Easiest to implement

    Uses native Bukkit API

  • Cons


    Needs a valid Bukkit Inventory that is stored properly

BancoContainer

An abstract class that must be extended with:

  • get(uuid), which returns a list containing every stored ItemStack
  • addItem(uuid, item), which adds item into this container and returns items that could not be added
  • removeItem(uuid, item), which removes item from this container
  • Pros


    Works for almost any use case

  • Cons


    More prone to changes