Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# ChestShop Database

A Paper plugin for Minecraft 1.21.8 that persists [ChestShop](https://www.spigotmc.org/resources/chestshop.51856/) data to a MariaDB database, enabling server-wide shop search, price browsing, and hologram previews.

Built for [DemocracyCraft](https://www.democracycraft.net/) and [StateCraft](https://www.mcstatecraft.com).

## Features

- **Shop tracking** — Automatically records shops as they are created, destroyed, and restocked in real time.
- **Search GUI** — `/csdb find` Opens a paginated chest GUI; filter by shop type (buy/sell), hide empty or full shops, and sort by price, stock, quantity, or distance.
- **Hologram previews** — Floating item displays above each shop sign, loaded per-chunk; togglable per player.
- **WorldEdit / FastAsyncWorldEdit (FAWE) integration** — Shops removed by a WorldEdit operation are automatically cleaned up from the database.
- **WorldGuard integration** — Exposes a `%region-name%` placeholder usable in shop display templates.

## Requirements

| Dependency | Required |
|---|---|
| Paper 1.21.8 | Yes |
| ChestShop | Yes |
| MariaDB | Yes |
| WorldEdit or FastAsyncWorldEdit (FAWE) | No |
| WorldGuard | No |

## Installation

1. Drop the plugin JAR into your `plugins/` folder.
2. Start the server once to generate config files, then stop it.
3. Edit `plugins/ChestShopDatabase/database-settings.yml` with your MariaDB connection details.
4. Run the SQL schema in `sql/create_tables_maria.sql` against your database.
5. Start the server.

## Commands

| Command | Permission | Description |
|---|---|---|
| `/csdb find` | `csdb.find` | Open the shop search GUI |
| `/csdb find toggle preview <true\|false>` | `csdb.preview.toggle` | Toggle hologram previews for yourself |
| `/csdb find toggle visibility <true\|false>` | `csdb.visibility.toggle` | Show or hide a shop in search results |
| `/csdb resync <chunksPerTick>` | `csdb.resync` | Full database resync by scanning all loaded chunks |
| `/csdb reload` | op | Reload config, messages, and item code groupings |

**Note:** In DemocracyCraft server, these commands are just "/find" or "/find toggle preview", with no "csdb" required.

## Configuration

| File | Purpose |
|---|---|
| `database-settings.yml` | MariaDB URL, username, password |
| `settings.yml` | Shop icon templates, lore, click command, preview scale |
| `item-code-groupings.yml` | Item code aliases mapped to canonical item codes |
| `messages.yml` | Player-facing messages |

## Building

```bash
./gradlew build
```

Output JARs are placed in each module's `build/libs/` directory.

## Project Structure

```
chestshop-database/
├── core/ # Shared models, DB interfaces, utilities
├── chestshop-database-bukkit/ # Main plugin (commands, GUI, listeners)
├── adapters/
│ ├── worldedit/ # WorldEdit integration
│ ├── fawe/ # FastAsyncWorldEdit integration
│ └── worldguard/ # WorldGuard region placeholder
└── sql/
└── create_tables_maria.sql
```
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ private static Component ownerName(@Nonnull Shop shop) {
return Component.text(shop.ownerName());
}


private static Component buyPrice(@Nonnull Shop shop) {
return Component.text(priceToString(shop.buyPrice()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ public ChestshopItem(@NotNull ChestshopItem other) {
public ItemStack itemStack() {
return this.itemStack.clone();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@ public void triggerCompleted() {
runnable.run();
}
}

}