Backpacks API

The EdToolsBackpackAPI provides a comprehensive set of tools for developers to interact with the player backpack system. You can retrieve backpack data, manage its contents, and handle upgrades externally.

Get API Instance

To begin using the Backpack API, you first need to get an instance of it from the main EdToolsAPI class.

EdToolsBackpackAPI backpackAPI = EdToolsAPI.getInstance().getBackpackAPI();

Methods

getPlayerBackpackInInventory(Player player)

Retrieves the actual ItemStack representing the player's backpack from their inventory.

  • player: The player whose backpack item you want to find.

  • Returns: The ItemStack of the backpack, or null if the player does not have it in their inventory.

getBackpackItems(UUID uuid)

Gets a map of all items and their quantities stored in a player's backpack.

  • uuid: The unique ID of the player.

  • Returns: A Map<String, Double> where the key is the item ID and the value is the amount stored.

getBackpackWeight(UUID uuid)

Calculates the total number of items currently inside a player's backpack.

  • uuid: The unique ID of the player.

  • Returns: A double representing the sum of all item amounts in the backpack.

sellBackpackItems(Player player)

Triggers a sale of all items currently in the player's backpack, clearing its contents.

  • player: The player whose backpack items will be sold.

upgradeBackpackAsPlayer(Player player)

Attempts to upgrade the player's backpack to the next available tier. This method internally handles checking for the next upgrade and deducting the cost from the player's balance.

  • player: The player who is attempting to upgrade their backpack.

setBackpackUpgrade(UUID uuid, String upgrade)

Directly sets a player's backpack to a specific upgrade tier, bypassing any cost checks.

  • uuid: The unique ID of the player.

  • upgrade: The ID of the target backpack tier (e.g., "2", "3", "vip-pack").

getBackpackUpgrade(UUID uuid)

Retrieves the ID of the player's current backpack upgrade tier.

  • uuid: The unique ID of the player.

  • Returns: A String containing the ID of the current backpack tier.

getBackpackNextUpgrade(UUID uuid)

Determines the next available upgrade tier for a player based on their current one.

  • uuid: The unique ID of the player.

  • Returns: A String with the ID of the next upgrade tier, or null if the player is at the maximum level.

getBackpackUpgrades()

Gets a collection of all configured backpack upgrade tier IDs.

  • Returns: A Set<String> containing all available backpack tier IDs from backpacks.yml.

getBackpackUpgradeMultiplier(String upgrade)

Retrieves the item collection multiplier for a specific backpack tier.

  • upgrade: The ID of the backpack tier.

  • Returns: A double representing the multiplier (e.g., 0.2 for 20%).

getBackpackUpgradeCost(String upgrade)

Gets the upgrade cost for a specific backpack tier.

  • upgrade: The ID of the backpack tier.

  • Returns: A double representing the cost amount.

getBackpackUpgradeCurrency(String upgrade)

Gets the currency type required to upgrade to a specific backpack tier.

  • upgrade: The ID of the backpack tier.

  • Returns: A String with the ID of the currency (e.g., "farm-coins").

getBackpackUpgradeSize(String upgrade)

Retrieves the total storage capacity for a specific backpack tier.

  • upgrade: The ID of the backpack tier.

  • Returns: A double representing the maximum capacity.

Last updated

Was this helpful?