# Importing Data

# Importing Data

The Mod Editor can load your existing server configuration files so you can view, edit, and extend them. All processing happens in your browser -- nothing is uploaded anywhere.

## Drop Zone

The main import interface is the **drop zone** on the onboarding screen (visible when no data is loaded) or available via the import area on each page.

You have three ways to import:

### 1. Drag & Drop a Folder (Recommended)

Drag your entire `mods/` folder (or the deployed mod folders) directly onto the drop zone. The editor will:

1. **Scan** the folder structure for known config paths
2. **Show a preview** of all detected files, grouped by mod (Quest Mod, Achievement Mod, Core Mod)
3. **Wait for confirmation** before loading

Click **"Load All X Files"** to import, or **"Cancel"** to abort.

:::tip Smart Folder Scanning
The editor only visits known config paths -- it never iterates through your entire folder tree. This means it works fast even with large mod directories containing thousands of files.
:::

### 2. Select Mods Folder (Chrome/Edge only)

Click the **"Select Mods Folder"** button to use the native folder picker. Select your `mods/` directory and the editor will scan it the same way as drag & drop.

:::info
This button requires the File System Access API and is only available in Chrome and Edge. In other browsers, the button appears grayed out.
:::

### 3. Individual Files

Click the **"Individual Files"** button to open a standard file picker. Select one or more `.json` files to import them individually. The editor auto-detects each file's type.

## Auto-Detected File Types

The editor recognizes **16 different file types** by filename and content structure:

| File Type | Detected By Filename | Example |
|-----------|---------------------|---------|
| **Quests** | `quests.json`, `custom_quests.json` | Side/daily/weekly quests |
| **Story Quests** | `story_quests.json`, `custom_story_quests.json` | Story quest chains |
| **Chapters** | `chapters.json`, `custom_chapters.json` | Story chapter ordering |
| **Daily Pool** | `daily_pool.json`, `custom_daily_pool.json` | Daily rotation pool |
| **Weekly Pool** | `weekly_pool.json`, `custom_weekly_pool.json` | Weekly rotation pool |
| **Token Shop** | Files containing `quest_token_shop` | Token shop items |
| **Achievements** | `achievements.json`, `custom_achievements.json` | Standard achievements |
| **MMO Achievements** | Files containing `mmo_achievements` | MMO skill achievements |
| **RPG Achievements** | Files containing `rpg_achievements` | RPG leveling achievements |
| **Citizens** | `citizens.json`, `custom_citizens.json` | NPC spawn definitions |
| **Lootbags** | Files containing `lootbags` | Loot table definitions |
| **English Locale** | Files containing `en-us` or `en_us` | English translations |
| **German Locale** | Files containing `de-de` or `de_de` | German translations |
| **NPC Profiles** | Structure: has `citizenId` + `quests` | Quest NPC dialog profiles |
| **Quest Packs** | Has `_editor_format: "questpack"` or `_pack_info` + `quests` | Bundled quest content |

:::note Fallback Detection
If the filename does not match a known pattern, the editor falls back to **structure-based detection**. For example, any JSON file with a top-level `quests` array is detected as a quest file, and files with `achievements` arrays are detected as achievement files.
:::

## Folder Structure Support

When scanning a folder, the editor reads the layout of the server's mod data folders:

**Server layout:**
```
mods/
├── kyuubisoft_questbook/
│   ├── configs/quests.json
│   ├── localization/en-US.json
│   └── quest_npc_profiles/*.json
├── kyuubisoft_achievements/
│   └── configs/achievements.json
└── kyuubisoft_core/
    └── citizens.json
```

The files are detected and loaded automatically.

## Quest Pack Import

`.questpack` files (or JSON files with the `_editor_format: "questpack"` marker) are self-contained bundles that can include:

- Quests and story quests
- Chapters
- NPC profiles
- EN/DE localization
- Custom reference data (item/entity/block IDs)

When you import a quest pack, all its contents are merged into the editor in one step.

## What Happens When You Import

Imported data **merges** with any data already loaded in the editor:

- **New items** are added to the existing lists
- **Existing items** with the same ID are updated/overwritten
- **Base data** (pre-loaded server defaults) remains available and is marked with a "BASE" badge
- **Your imports** are marked as "CUSTOM"

After import, each loaded file appears as a status badge showing the file type and item count (e.g., "Quests (42)").

:::caution Custom Files
Base server configs in `configs/` **may be replaced** when a mod update ships a newer version of them (the old file is kept as a backup). The editor exports your changes as **custom files** (in `custom/`) that are **never overwritten**. Your custom entries automatically merge with or override the base configs at runtime. Quests, Achievements and Info Hub can also be edited in their in-game admin windows.
:::

## Reference Data for Autocomplete

The editor ships with built-in reference data (item IDs, entity IDs, block IDs) that powers autocomplete suggestions and validation. This data loads automatically on startup.

If you want autocomplete for **custom items or entities** added by other mods, use `/ksdev items`, `/ksdev entities` and `/ksdev blocks` (or `/ksdev all`) on your server to generate reference files, then import those files into the editor.

## Next Steps

- [Quest Editing](./quest-editing) -- Start creating and editing quests
- [Objectives & Rewards](./objectives-rewards) -- Configure what players must do and what they earn