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
31 changes: 19 additions & 12 deletions AI.md → AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
| **Core API** | [pumpkin-plugin-api](https://github.com/Pumpkin-MC/Pumpkin) | Minecraft server plugin API |
| **Language** | Rust 2024 | Systems language |
| **Build Tool** | Cargo | Build automation |
| **Serialization** | serde + toml | Config serialization |
| **Config** | figment | TOML config with merge semantics |
| **Serialization** | serde + json | Config serialization |
| **Config** | figment | JSON config with merge semantics |
| **Logging** | tracing | Structured logging |
| **Docs** | rustdoc (via `cargo doc`) | API documentation |

Expand All @@ -38,11 +38,11 @@
## Quick Commands

```bash
# Build the WASM plugin (debug)
cargo build --target wasm32-wasip2
# Build the WASM plugin (debug) and copy to .server/plugins/
powershell -ExecutionPolicy Bypass -File build.ps1

# Build the WASM plugin (release, optimized)
cargo build --release --target wasm32-wasip2
# Build the WASM plugin (release)
powershell -ExecutionPolicy Bypass -File build.ps1 -Release

# Generate documentation
cargo doc --no-deps --target wasm32-wasip2
Expand All @@ -56,7 +56,7 @@ cargo doc --no-deps --target wasm32-wasip2

1. **Registration**: Via `register_plugin!(PumpkinPlus)` macro
2. **`on_load`**:
- Initializes `ConfigManager` (loads/creates `config.toml`)
- Initializes `ConfigManager` (loads/creates `config.json`)
- Registers all module configs
- Calls `Module::register` for each enabled module
3. **`on_unload`**: Logs farewell message
Expand All @@ -79,7 +79,7 @@ Modules are plain structs (not singletons) instantiated with `Default::default()

**`ConfigManager`** (`src/config.rs`) — JSON-backed config with merge semantics:

- Config located at `{data_folder}/config.toml`
- Config located at `{data_folder}/config.json`
- On first load: creates file with all registered defaults
- On subsequent loads: merges user values with defaults (preserves extra fields)
- Each module owns a nested `Config` struct with `enabled: bool` field
Expand All @@ -90,7 +90,8 @@ Config key derived from type name automatically (e.g., `PlayerConfig` → `"play

| Module | File | Description |
|-----------|------------------------------------|-------------------------------------------------------------------------------|
| `Player` | `src/modules/mechanics/player.rs` | Custom join/leave/kick messages, chat format/filter |
| `Messages`| `src/modules/mechanics/player/messages.rs` | Custom join/leave/kick messages |
| `Chat` | `src/modules/mechanics/server/chat.rs` | Chat format/filter |
| `Tablist` | `src/modules/mechanics/tablist.rs` | Dynamic tab list header/footer with `{player}`, `{online}`, `{tps}`, `{mspt}` |
| `Locator` | `src/modules/mechanics/locator.rs` | Locator bar personalization (`/locator` command, stub) |

Expand All @@ -113,9 +114,15 @@ src/
└── modules/
├── module.rs # `Module` trait definition
└── mechanics/
├── player.rs # Join/leave/kick messages, chat
├── tablist.rs # Tab list header/footer
└── locator.rs # Locator bar commands
├── player/
│ ├── messages.rs # Join/leave/kick messages
│ ├── enderchest.rs # Enderchest sharing
│ └── locator.rs # Locator bar commands
├── server/
│ ├── chat.rs # Chat format/filter
│ └── tablist.rs # Tab list header/footer
└── world/
└── openable.rs # Double door sync
```

### Key Conventions
Expand Down
31 changes: 16 additions & 15 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ PumpkinPlus is a Pumpkin Minecraft plugin that enhances base gameplay. Built wit
## Build & Run Commands

```bash
# Build the WASM plugin (debug)
cargo build --target wasm32-wasip2
# Build the WASM plugin (debug) and copy to .server/plugins/
powershell -ExecutionPolicy Bypass -File build.ps1

# Build the WASM plugin (release, with LTO + strip)
cargo build --release --target wasm32-wasip2
# Build the WASM plugin (release)
powershell -ExecutionPolicy Bypass -File build.ps1 -Release
```

Testing is done via integration testing: build the WASM plugin and load it in a Pumpkin server.
Expand All @@ -23,7 +23,7 @@ Testing is done via integration testing: build the WASM plugin and load it in a
### Entry Point

- **`PumpkinPlus`** — implements `Plugin` from `pumpkin_plugin_api`. Registered via `register_plugin!(PumpkinPlus)`.
- `on_load`: initializes `ConfigManager` (loads or creates `config.toml`), then registers all modules via `Module::register`.
- `on_load`: initializes `ConfigManager` (loads or creates `config.json`), then registers all modules via `Module::register`.
- `on_unload`: logs a farewell message.

### Module System
Expand All @@ -40,31 +40,32 @@ Modules are plain structs (not singletons) instantiated with `Default::default()

### Configuration

**`ConfigManager`** (`src/config.rs`) is a single TOML-backed struct that aggregates all module configs. On `on_load`:
**`ConfigManager`** (`src/config.rs`) is a single JSON-backed struct that aggregates all module configs. On `on_load`:

- If `config.toml` exists in the plugin data folder, it is deserialized and returned.
- If `config.json` exists in the plugin data folder, it is deserialized and merged with defaults.
- If not found, the default config is written to disk and returned.
- Any other I/O error is surfaced as a plugin load error.

Each module owns a nested **`Config`** struct (derived `Serialize`/`Deserialize`) with an `enabled: bool` field and any module-specific fields. `ConfigManager` holds one field per module config.
- Each module owns a nested **`Config`** struct (derived `Serialize`/`Deserialize`) with an `enabled: bool` field and any module-specific fields. `ConfigManager` holds one field per module config.

### Modules

| Module | File | Status | Description |
|-----------|------------------------------------|--------|----------------------------------------------------------------------------------------------------------------------------------|
| `Player` | `src/modules/mechanics/player.rs` | Active | Custom join/leave/kick messages. Handles `PlayerJoinEvent`, `PlayerLeaveEvent`, `PlayerLoginEvent`. Uses `{player}` placeholder. |
| `Messages` | `src/modules/mechanics/player/messages.rs` | Active | Custom join/leave/kick messages. Handles `PlayerJoinEvent`, `PlayerLeaveEvent`, `PlayerLoginEvent`. Uses `{player}` placeholder. |
| `Chat` | `src/modules/mechanics/server/chat.rs` | Active | Chat formatting and word filtering. Handles `PlayerChatEvent`. Uses `{player}` and `{message}` placeholders. |
| `Motd` | `src/modules/mechanics/motd.rs` | Stub | Custom server list MOTD. API not yet available in `pumpkin-plugin-api`. |
| `Tablist` | `src/modules/mechanics/tablist.rs` | Stub | Custom tab-list header/footer. No events or commands yet. |
| `Locator` | `src/modules/mechanics/locator.rs` | Stub | Locator bar personalisation. Registers `/locator` (`/lc`) with `color`, `hex`, `reset` subcommands. Implementation pending API. |
| `Tablist` | `src/modules/mechanics/server/tablist.rs` | Active | Dynamic tab list header/footer with `{player}`, `{online}`, `{tps}`, `{mspt}` placeholders. |
| `Openable`| `src/modules/mechanics/world/openable.rs` | Active | Double door synchronization. Handles `PlayerInteractEvent`. |

### Package Structure

| Path | Contents |
|--------------------------|---------------------------------------------------------|
| `src/lib.rs` | `PumpkinPlus` plugin struct, entry point |
| `src/config.rs` | `ConfigManager` — TOML config load/save |
| `src/config.rs` | `ConfigManager` — JSON config load/save/merge |
| `src/modules/module.rs` | `Module` trait definition |
| `src/modules/mechanics/` | Feature modules: `player`, `motd`, `tablist`, `locator` |
| `src/modules/mechanics/player/` | Player features: messages, enderchest, locator |
| `src/modules/mechanics/server/` | Server features: chat, tablist |
| `src/modules/mechanics/world/` | World features: openable (double doors) |

### Key Conventions

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ crate-type = ["cdylib"]
pumpkin-plugin-api = { version = "0.1.0", git = "https://github.com/Pumpkin-MC/Pumpkin" }
tracing = "0.1"
serde = { version = "1.0.228", features = ["derive"] }
figment = { version = "0.10", features = ["toml"] }
toml = "1.1.2"
serde_json = "1.0"
figment = { version = "0.10", features = ["json"] }

[profile.release]
lto = true
Expand Down
61 changes: 34 additions & 27 deletions GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,35 +59,38 @@ Build the plugin yourself using Rust.

## Configuration

The plugin uses a TOML configuration file (`config.toml`) that is automatically created on first run.
The plugin uses a JSON configuration file (`config.json`) that is automatically created on first run.

### Default Config Structure

```toml
[player]
enabled = true
join_message = "Welcome {player}!"
leave_message = "Goodbye {player}!"
kick_message = "{player} was kicked"

[motd]
enabled = false

[tablist]
enabled = false

[locator]
enabled = false
```json
{
"messages": {
"enabled": true,
"join_msg": "Welcome {player}!",
"leave_msg": "Goodbye {player}!",
"kick_msg": "{player} was kicked"
},
"chat": {
"enabled": false,
"chat_format": "",
"chat_filter": []
},
"tablist": {
"enabled": false,
"header": "",
"footer": ""
}
}
```

### Configuration Options

| Module | Description | Default |
|-----------|---------------------------------|----------|
| `player` | Custom join/leave/kick messages | Enabled |
| `motd` | Custom server MOTD | Disabled |
| `tablist` | Custom tablist header/footer | Disabled |
| `locator` | Locator bar personalization | Disabled |
| Module | Description | Default |
|------------|---------------------------------|----------|
| `messages` | Custom join/leave/kick messages | Enabled |
| `chat` | Chat format and word filtering | Disabled |
| `tablist` | Custom tablist header/footer | Disabled |

### Placeholders

Expand All @@ -97,18 +100,22 @@ enabled = false

1. Place `pumpkinplus.wasm` in your Pumpkin server's `plugins/` directory
2. Start the server
3. The plugin will load and create `config.toml` in the plugin data folder
4. Stop the server and edit `config.toml` as needed
3. The plugin will load and create `config.json` in the plugin data folder
4. Stop the server and edit `config.json` as needed
5. Restart the server

## Usage

Once installed, the plugin runs automatically. Available features depend on enabled modules:

### Player Module
### Messages Module

Active by default. Provides custom join/leave/kick messages.

### Chat Module

When enabled, provides chat formatting and word filtering.

### Locator Module

When enabled, provides the `/locator` (or `/lc`) command:
Expand All @@ -131,13 +138,13 @@ When enabled, provides the `/locator` (or `/lc`) command:

### "Config not loading"

- Check that `config.toml` is valid TOML
- Check that `config.json` is valid JSON
- The plugin will regenerate the config if it's invalid
- Stop the server before editing the config file

### Commands not working

- Ensure the module is enabled in `config.toml`
- Ensure the module is enabled in `config.json`
- Check that you have the required permission node
- Verify the plugin loaded successfully in server logs

Expand Down
15 changes: 15 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
param(
[switch]$Release
)

$ErrorActionPreference = "Stop"

if ($Release) {
cargo build --release --target wasm32-wasip2
} else {
cargo build --target wasm32-wasip2
$src = "target/wasm32-wasip2/debug/pumpkinplus.wasm"
$dst = ".server/plugins/pumpkinplus.wasm"
Copy-Item $src $dst -Force
Write-Host "Copied $src -> $dst"
}
19 changes: 19 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"

PROFILE="debug"
if [[ "${1:-}" == "--release" ]] || [[ "${1:-}" == "-r" ]]; then
PROFILE="release"
fi

cargo build --target wasm32-wasip2 ${PROFILE:+--$PROFILE}

if [ "$PROFILE" == "debug" ]; then
SRC="target/wasm32-wasip2/debug/pumpkinplus.wasm"
DST=".server/plugins/pumpkinplus.wasm"
cp "$SRC" "$DST"
echo "Copied $SRC -> $DST"
fi
Loading
Loading