# Shop Editor

# Shop Editor

Since Core 2.9.0, NPC shops have an in-game editor in the KS Premium look. You can create, copy, edit and delete shops, link merchant NPCs and check everything in a player preview — without touching JSON. The editor writes the same files as described in [Configuration](https://wiki.kyuubisoft.com/hytale/shop-system/configuration/).

:::caution
The shop editor has not been tested on a live server yet.
:::

## Opening the Editor

1. Run `/ksadmin` in game (needs `ks.admin`).
2. On the **Mods** tab, click the tile **NPC Shops**.

The tile only shows when Core's shop module is on. The editor checks `ks.admin` again on every save; in showcase mode nothing is saved.

## Shop List

The left side lists every shop with its name, number of entries and linked NPC.

- **Search** over shop names, IDs, entries and NPC names.
- **Filter** All / Core / Mods. Shops that another mod registers (for example the Quests token shop) are **read-only** and show that mod's name. You can view them, test them in the preview, or use **Copy as Core shop** to make an editable copy.
- **+ New shop** starts a new shop (see below).

The header of the selected shop shows status chips (new, changed, errors, needs permission, read-only) and the actions **Duplicate** and **Delete**.

## Tabs

### Settings

![The Settings tab of the shop editor](../../../../assets/shop-system/shop-admin-settings.png)

| Section | What you set |
|---|---|
| **General** | Name in the window (text or language key), ID (also the file name), icon, currency and the permission to open the shop. |
| **Daily offer** | "A new pick every day" and how many entries per day. Each player gets their own pick, new at midnight (server time). |
| **Buying** | "Offer buying" (off = a pure buy-back shop) and "Buy several at once" (the quantity stepper). |
| **Opens via** | Anywhere, only at the NPC, or only by command (`openVia`). |
| **NPCs** | **Link NPC** opens a list of all NPCs. An NPC opens exactly one shop; the link is saved together with the shop. NPCs in a locked NPC file cannot be changed. |

**Renaming a shop** (changing its ID) replaces the file. By default, linked NPCs move to the new ID ("Move NPCs to the new id"); turn this off only if you want the NPCs to keep pointing at the old ID.

### Offer

The list of entries with search and paging. Each entry can be:

- switched off (hidden from players and from the daily rotation),
- sorted, duplicated or reset to its saved state,
- an **Item** (with item picker) or a **Command** (run as console or as the buyer).

Per entry you set the quantity and price, the purchase limit per day, the display name (empty = the game's item name in the player's language), description, category, weight for the daily rotation, an optional permission and an own buy-back price.

**Adjust prices** is a price tool for all entries or one category: −99 % to +1000 %, rounding normal/down/up, optionally including the own buy-back prices, with a preview table before you apply. It only changes the draft; players notice nothing until you save.

### Buy-back

"Offer buy-back", the share of the buy price for entries without their own buy-back price, the payout currency, the lists **Only buy these items** (whitelist) and **Never buy** (blacklist), and **fixed buy-back prices** for items that are not in the offer (`sellItems`), each with a daily limit. A read-only list shows the NPCs that buy back here.

### Preview

Shows the shop as a player sees it — the draft, not the saved file. You can switch between today's pick and the whole offer, and between "with" and "without permissions". Nothing is bought or charged in the preview.

## Creating a Shop

**+ New shop** offers three ways to start. The shop is a draft and only exists after **Save**.

| Start from | Result |
|---|---|
| **Preset** | Empty, With daily offer (6 a day), Buy-back only, or Only at the NPC — settings only, no entries. |
| **Shipped shop** | One of Core's shipped shops as a template, with its entries and prices. |
| **Copy** | A copy of any existing shop, also of a mod shop. NPCs are not copied. |

## Saving, Drafts and Checks

- All changes go into a **draft**. The footer shows the number of unsaved changes; **Save** writes the file, **Discard** throws the draft away. Players see changes the next time they open the shop.
- **Errors** (missing ID, unknown currency or item, missing price, invalid numbers) block saving and jump to the first problem. **Warnings** (for example a buy-back price above the buy price, an unregistered command, no NPC linked although the shop opens only at its NPC) only ask "Save anyway?".
- **Drafts survive Esc:** if you close the window with unsaved changes, the draft is kept for 30 minutes and offered again when you come back. If the shop was changed meanwhile, the editor tells you that saving overwrites that change.
- Saving is atomic, and renaming a shop removes the old file.
- Deleting a shipped shop is remembered, so it is not extracted again on the next start.

## Console Commands

Command entries that run as the **console** have full server rights, no matter who buys. Without `ks.core.admin.dialog.console`:

- such entries are locked: you cannot add, change or remove them, and their permission is read-only (prices, names and limits stay editable),
- new command entries run as the buyer,
- copying, duplicating or deleting a shop that has console entries is refused.

The rule is checked again on the server when you save. See [Permissions](https://wiki.kyuubisoft.com/hytale/shop-system/permissions/).

## Other Ways to Edit

- **JSON files** in `mods/kyuubisoft_core/shops/` and `custom/`, then `/ksadmin reload`.
- **Web editor** (`/kseditor`), see [Developer Tools](https://wiki.kyuubisoft.com/hytale/dev-tools/). Imports keep existing console entries unless the editor's owner has `ks.core.admin.dialog.console`.