Consumer Team Chests

Table of contents

  1. Read team chest contents
  2. Set chest contents
  3. Add an item
  4. Remove an item
  5. Notes

TeamsChestService is optional. Always guard access with TeamsAPI.isChestAvailable() and handle false gracefully.

Read team chest contents

if (!TeamsAPI.isChestAvailable()) {
    player.sendMessage("Team chest support is unavailable.");
    return;
}

final TeamsChestService chests = TeamsAPI.getChestService();
final Collection<String> chestIds = chests.getChestIds(teamId);
final Collection<ItemStack> defaultContents = chests.getContents(teamId);
final Collection<ItemStack> vaultContents = chests.getContents(teamId, "vault");
player.sendMessage("Team chest count: " + chestIds.size());

Set chest contents

if (!TeamsAPI.isChestAvailable()) {
    player.sendMessage("Team chest support is unavailable.");
    return;
}

final TeamsChestService chests = TeamsAPI.getChestService();
final boolean replaced = chests.setContents(teamId, "vault", newContents);
player.sendMessage(replaced ? "Chest contents replaced." : "Could not replace chest contents.");

Add an item

if (!TeamsAPI.isChestAvailable()) {
    player.sendMessage("Team chest support is unavailable.");
    return;
}

final TeamsChestService chests = TeamsAPI.getChestService();
final boolean added = chests.addItem(teamId, "vault", itemStack);
player.sendMessage(added ? "Item added to team chest." : "Could not add item.");

Remove an item

if (!TeamsAPI.isChestAvailable()) {
    player.sendMessage("Team chest support is unavailable.");
    return;
}

final TeamsChestService chests = TeamsAPI.getChestService();
final boolean removed = chests.removeItem(teamId, "vault", itemStack);
player.sendMessage(removed ? "Item removed from team chest." : "Item not found.");

Notes

  • TeamsChestService methods are provider-defined for slot order, stacking, and removal matching behavior.
  • Single-chest providers can expose only the default chest id (default).
  • Treat getContents as read-only snapshot data and avoid mutating returned objects.
  • Keep chest logic optional so your plugin still works with providers that only implement the core TeamsService.