api

Complete guide to using the VaultPack API in your plugins.

Getting Started

VaultPack provides a comprehensive API for developers to integrate backpack functionality into their own plugins.

Adding VaultPack as a Dependency

Add JitPack repository:

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>

Add VaultPack dependency:

<dependency>
    <groupId>com.github.yourusername</groupId>
    <artifactId>VaultPack</artifactId>
    <version>2.0.0</version>
    <scope>provided</scope>
</dependency>

plugin.yml

Add VaultPack as a dependency:

API Instance

Getting the API

Note: Always check if the API instance is not null before using it, especially if you're using soft dependencies.

Backpack Management

Check if Player has Backpack

Open Backpack

Create Backpack

Get Backpack Contents

Get Backpack Information

Slot Management

Check if Slot is Unlocked

Unlock Slot Programmatically

Warning: This bypasses all checks! Use with caution.

Get Unlocked Slot Count

Player Statistics

Get Active Backpack Count

Get Total Storage Capacity

Ender Chest Management

Check if Ender Page is Unlocked

Unlock Ender Page

Open Ender Page

Get Ender Page Contents

Get Ender Storage Statistics

Unified Storage

Open Unified Storage GUI

Configuration

Check Blacklisted Items

Get Configuration Values

Events

VaultPack fires several events you can listen to:

BackpackOpenEvent

Called when a player opens a backpack (cancellable).

BackpackCloseEvent

Called when a player closes a backpack (cancellable).

BackpackCreateEvent

Called when a backpack is created (cancellable).

SlotUnlockEvent

Called when a player unlocks a backpack slot (cancellable).

Complete Integration Examples

Example 1: Reward System

Give players backpack slots as quest rewards:

Example 2: Storage Checker

Check if player has enough free storage:

Example 3: Combat Restriction

Prevent opening backpacks during combat:

Example 4: Statistics Display

Create a command to show storage stats:

Best Practices

1

Always Check for Null

2

Use Soft Dependencies

If VaultPack is optional for your plugin:

3

Listen to Events

Don't poll for changes - use events:

4

Respect Cancellation

If you cancel an event, provide feedback:

5

Save After Modifications

If you unlock slots/pages programmatically, data is saved automatically. However, if you're doing bulk operations, consider batch saving.

API Methods Reference

Backpack Methods

Method
Return Type
Description

hasBackpack(Player, int)

boolean

Check if slot has backpack

hasBackpack(UUID, int)

boolean

Check by UUID

openBackpack(Player, int)

void

Open specific backpack

openBackpackMenu(Player)

void

Open selector menu

createBackpack(Player, int, BackpackTier)

void

Create new backpack

getBackpackContents(Player, int)

Map<Integer, ItemStack>

Get backpack items

getBackpackSize(Player, int)

int

Get backpack size

getBackpackTier(Player, int)

BackpackTier

Get backpack tier

Slot Methods

Method
Return Type
Description

isSlotUnlocked(Player, int)

boolean

Check if slot unlocked

unlockSlot(Player, int)

void

Unlock slot

getUnlockedSlots(Player)

int

Get unlocked count

Statistics Methods

Method
Return Type
Description

getActiveBackpackCount(Player)

int

Active backpack count

getTotalStorageSlots(Player)

int

Total backpack storage

getTotalUsedSlots(Player)

int

Used backpack slots

Ender Chest Methods

Method
Return Type
Description

isEnderPageUnlocked(Player, int)

boolean

Check page unlocked

unlockEnderPage(Player, int)

void

Unlock ender page

openEnderPage(Player, int)

void

Open ender page

getEnderPageContents(Player, int)

Map<Integer, ItemStack>

Get page contents

getUnlockedEnderPages(Player)

int

Get unlocked count

getTotalEnderStorageSlots(Player)

int

Total ender storage

getTotalUsedEnderSlots(Player)

int

Used ender slots

Support

1

Check this documentation

2

Review the example code above

3

Join the Discord

https://discord.gg/joogiebear

4

Check the source code on GitHub

Version Information

Advanced: Direct Plugin Access

For advanced features not in the API:

Warning: Direct manager access is not part of the stable API and may change between versions!

Next Steps

  • View Event Examples

  • See PlaceholderAPI Integration

  • Check Configuration Options