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.
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:
public final class CustomInventory {
@Override
public String friendlyName() {
return "CUSTOM_INVENTORY";
}
...
}
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 balanceadd(uuid, amount), which addsamounttouuid's instance of this storageremove(uuid, amount), which removesamountfromuuid'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'sInventory
-
Pros
Easiest to implement
Uses native Bukkit API
-
Cons
Needs a valid Bukkit
Inventorythat is stored properly
BancoContainer
An abstract class that must be extended with:
get(uuid), which returns a list containing every stored ItemStackaddItem(uuid, item), which addsiteminto this container and returns items that could not be addedremoveItem(uuid, item), which removesitemfrom this container
-
Pros
Works for almost any use case
-
Cons
More prone to changes