# Admin Panel

`/lbadmin panel` opens **Lootbag Admin**, one window for everything an admin changes in game. With KyuubiSoft Core installed it is also a "Lootbag Admin" tile in Core's `/ksadmin` hub (the hub itself needs `ks.admin`). Both ways need `ks.lootbag.admin`; the panel checks it again on every click.

:::note
The pictures on this page are design previews of the in-game windows. The layout is the same as in the game; names, values and icons are examples.
:::

## Layout

- **Header:** the title, a line like "150 bags · 12 drop rules · changes apply after Save", the status line (green for done, red for errors and questions), **Reload** and **X**.
- **Navigation** on the left:
  - *Content:* **Bags** and **Drop rules**, each with its count. The count turns gold while that section has unsaved changes.
  - *Management:* **Give** and **Statistics**.
  - *System:* **Settings**.
- **Reload** reloads `config.json`, the bag files and the drop rules from disk (like `/lbadmin reload`) and throws away every unsaved change in the panel.

### Nothing is live before Save

Changes in Bags, Drop rules and Settings are drafts until you click **Save** in that section. Switching to another section keeps them, including text you typed. **Discard** throws away the changes of the current bag or of the drop rules; **Reload** throws away all of them.

---

## Bags

![The Bags section: bag list with search and tier filter, and the editor of one bag](../../../../assets/lootbags/lootbags-admin-bags.png)
*The bag editor: tier, picks, duplicates, guaranteed items, the random pool with weights and live chances, and the item search.*

### Bag list (left)

- **Search** by name or ID; click **Go** or press Enter.
- **Tier filter:** All, Com, Unc, Rar, Epi, Leg.
- "12 of 150 bags", then 10 bags per page with arrows. Each row shows the bag's icon, its name with tier ("Crystal Lootbag · Epic") in the tier color, its ID and a short summary: `4g · 3/6` means 4 guaranteed items and 3 draws from a pool of 6.
- A gold diamond marks bags with unsaved changes. New, still unsaved bags are listed first; then the shipped styles in catalog order, then your own styles, each from Common to Legendary.
- **New bag:** type an ID in the field at the bottom and click **+ New** (or press Enter). IDs have 3 to 48 letters, digits or `_` and must not exist yet. The new bag starts as Common with one pick and no items.

Click a bag to edit it. Unchanged bags you leave are forgotten; bags with changes keep them, so you can edit several bags and save them one by one.

### Bag editor (right)

| Part | What it does |
|------|--------------|
| Name | Text field. Empty for shipped bags that use their translated style name (the placeholder shows it). Type a name to give the bag your own; clearing the field brings the shipped name back |
| ID line | "ID Crystal_Lootbag · Style Crystal · shipped". The last part is *shipped*, *shipped, edited* (your copy in `custom_lootbags.json`), *custom bag* or *new, unsaved* |
| Rarity | Five tier buttons. A bag that changes its tier moves to that tier in the catalog |
| Picks | **-** / **+**, 0 to 20: how many items are drawn from the pool |
| Duplicates allowed | Toggle: whether the pool may draw the same item twice |
| Guaranteed | "always in the bag (4)": item (icon, name, ID), amount field (1 to 9999), chance (always 100 %), red **x** to remove it. 3 rows per page with arrows |
| Random pool | "3 of 6 drawn, no duplicates": item, amount (1 to 9999), weight (1 to 100000), chance per bag, red **x**. 5 rows per page with arrows |
| Add to | **Guaranteed** or **Pool**, a search field ("Search item id (min. 2 letters)") and **Search**. Up to 6 matching item IDs with their icon appear; click one to add it with amount 1 (pool: weight 10). An item can be in each list only once |

The chances are recalculated when you press Enter in an amount or weight field, and with every other click. They are the real chance per bag with all draws counted, the same numbers the catalog shows players.

Fixed items (`items` in the JSON) appear as guaranteed items and are saved as such.

### Save, Discard, Delete, Reset

At the bottom the editor shows "Unsaved" or "No changes" and these buttons:

| Button | Effect |
|--------|--------|
| **Save** | Writes this bag to `custom/custom_lootbags.json` and makes it live. Refused when an item ID does not exist ("1 unknown item(s) first: ..."), or when the bag would give nothing ("Bag would be empty - add items") |
| **Discard** | Throws away this bag's changes (a new bag disappears) |
| **Delete** | Only for your own bags: removes the bag from `custom_lootbags.json`. Click twice ("Confirm?") |
| **Reset** | Only for shipped bags you changed: removes your copy, the shipped bag is back. Click twice |

A new bag gets its item when you save it: it looks like the Default bag of its tier and is sent to every online player at once. Delete and Reset reload the bag files, the config and the drop rules.

:::caution
Bags of a deleted custom bag that players still hold can no longer be opened. Drop rules that point to it are shown in red in the Drop rules section; delete those rules as well.
:::

---

## Drop rules

![The Drop rules section: switches, drop factor, rule table and the rule editor](../../../../assets/lootbags/lootbags-admin-drops.png)
*Drop rules: creature and mining rules with pattern, bag, chance and amount, and the editor below.*

**Top:** "Bags drop from creatures and mining; patterns use * as wildcard".

| Setting | Saved as |
|---------|----------|
| Drops active | `dropEnabled` in `config.json` |
| Ignore self-placed blocks | `ignorePlacedBlocks` in `config.json` (see [Configuration](./configuration#configjson)) |
| Drop factor ("x all chances"), 0 to 100 | `dropMultiplier` in `config.json` |

**Rules** ("if several patterns match, each rule rolls on its own"): creature rules first, then mining rules, 10 per page.

| Column | Content |
|--------|---------|
| Kind | Creature or Mining |
| Pattern | e.g. `Trork_*` |
| Bag | Icon and "Bone Lootbag · Uncommon"; a missing bag shows in red: "Bag X does not exist - never drops" |
| Chance | in percent |
| Amount | `1` or a range like `1 - 3` |
| Edit / Del | **Edit** loads the rule into the editor; **Del** needs a second click ("Sure?") |

**Editor** ("Add rule" or "Edit rule 3"):

| Field | Rules |
|-------|-------|
| Creature / Mining | Kind of the rule |
| Pattern | Required, at most 96 characters, no spaces. `*`, `Trork_*` or an exact ID |
| Bag id | Must be an existing bag. A stale ID such as `Crystal_Lootbag_Epic` is replaced by the bag of the same style and tier |
| Chance | Percent, 0.001 to 100. Comma or dot both work |
| min / max | 1 to 64 bags. Empty min = 1, empty max = min |

**Add** appends the rule, **Apply** replaces the rule you are editing, **Cancel** leaves edit mode. Every change is marked "(not saved)". **Save** writes all rules to `configs/drop_tables.json` (the old file stays as `.bak`) and the three settings above to `config.json`. **Discard** goes back to the saved state.

---

## Give

"Give lootbags - To an online player, straight into the inventory".

| Field | Description |
|-------|-------------|
| Player | Name of an online player (any world, not case-sensitive). **Check** (or Enter) shows "Steve is online" or "Steve is not online" |
| Bag | Bag ID. Filled in with the bag you last picked in **Bags**. The icon and name of the bag appear next to it |
| Amount | 1 to 64 per give |

- **Give** hands out the amount of that bag.
- **Whole set (all 5 tiers)** hands out one bag of every tier of that bag's style.

If not everything fits into the inventory, the rest lands at the player's feet. The status line confirms the give, for example "Gave 5x Crystal Lootbag · Epic to Steve".

---

## Statistics

Server totals over **all** players, offline players included: the plugin reads every file in `data/players/` in the background (online players are taken from memory). The count starts when you open the section for the first time after a restart; **Refresh** counts again. The hint shows "Counting player files..." or "All players, offline included - as of 14:32". The result is shared by every admin until the next refresh.

| Part | Content |
|------|---------|
| Totals | Bags opened, Items handed out, Players with data |
| Opened per tier | One bar per tier |
| Most opened bags | The five bags opened most often, with "1,204x opened" |

---

## Settings

"Saved to config.json".

| Setting | Field | Note |
|---------|-------|------|
| Lootbags active | `enabled` | The hint says "Opening, catalog and drops". Off stops right-click opening, F on placed bags, all drops and the catalog (players get "Lootbags are turned off on this server."); `/kslootbags stats` and `settings` keep working |
| Show result window | `revealPageEnabled` | Off = every opening is listed in the chat only. Players can also turn the window off for themselves |
| Show drop sources | `showDropSources` | The catalog's *Where to find* section |
| Open cooldown | `openCooldownMs` | 0 to 600000 ms, prevents accidental double opening |
| Language | | Information only: the panel follows each player's language (`/kslang`) and shows how many languages are loaded |

Toggles change only after **Save**. There is no Discard button here; **Reload** brings back the saved values.

---

## Showcase servers

On a server that runs the KyuubiSoft Showcase, the showcase key opens this panel. Visitors can look around and click through; their drafts stay in the open window. Saving, deleting, giving bags, **Reload** and the statistics count are refused on the server. The **Statistics** section shows "Player data is hidden", and **Give** does not tell whether a typed name is online. A normal server is not affected.