# ILootTableManager
> Advanced interface for creating and managing loot tables programmatically.
`gg.lode.chestapi.api.ILootTableManager`
---
## Signature
```java
public interface ILootTableManager
```
---
## Methods
| Method | Return Type | Description |
|--------|-------------|-------------|
| `createLootTable(String id)` | `boolean` | Creates a new loot table. Returns `false` if it already exists. |
| `createLootTable(String id, String name)` | `boolean` | Creates a new loot table with a display name. |
| `deleteLootTableById(String id)` | `boolean` | Deletes a loot table and its file on disk. |
| `getLootTableById(String id)` | `ILootTable` | Returns the [[ILootTable]] instance, or `null` if not found. |
| `addItemToLootTable(String id, ItemStack item, int weight)` | `boolean` | Adds a weighted item to a loot table. Automatically saved to disk. |
| `removeItemFromLootTable(String lootTableName, int index)` | `boolean` | Removes an item by index. Automatically saved to disk. |
| `getLootTableItems(String id)` | `List<ILootTableItem>` | Returns all items in a loot table, or `null` if not found. |
| `getLootTableItemCount(String id)` | `int` | Returns the item count, or `-1` if the table doesn't exist. |
| `mergeLootTables(List<String> lootTableIds)` | `ILootTable` | Merges multiple tables into a temporary combined table. Non-existent IDs are skipped. |
| `populateInventory(String id, Inventory inventory)` | `boolean` | Populates an inventory with default item count (3–6). |
| `populateInventory(String id, Inventory inventory, int min, int max)` | `boolean` | Populates an inventory with custom item count bounds. |
| `saveLootTable(String id)` | `boolean` | Persists a loot table to disk. |
| `loadLootTable(String id)` | `boolean` | Loads a loot table from disk. |
| `getAvailableLootTables()` | `Set<String>` | Returns all available loot table IDs. |
| `lootTableExists(String id)` | `boolean` | Checks if a loot table exists. |
| `reload()` | `void` | Reloads all loot tables from disk. |
| `serializeItemStack(ItemStack item)` | `String` | Serializes an `ItemStack` to a string. |
| `deserializeItemStack(String data)` | `ItemStack` | Deserializes a string to an `ItemStack`. Supports base64, YAML, and `material;amount` formats. |
---
## Usage
```java
ILootTableManager manager = ChestAPI.getApi().getLootTableManager();
// Create a loot table and add items
manager.createLootTable("my_table", "My Loot Table");
manager.addItemToLootTable("my_table", new ItemStack(Material.DIAMOND), 10);
manager.addItemToLootTable("my_table", new ItemStack(Material.GOLDEN_APPLE, 2), 5);
// Populate a chest
manager.populateInventory("my_table", chestInventory, 2, 8);
```
---
## Related Pages
- [[IChestAPI]]
- [[ILootTable]]
- [[ILootTableItem]]