# kencenggame/piggycustomenchants architecture

> Architecture diagram of the GitHub repository kencenggame/piggycustomenchants, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kencenggame/piggycustomenchants
- Repository: https://github.com/kencenggame/piggycustomenchants

## Overview

PiggyCustomEnchants is a PocketMine-MP plugin for applying and running more than 90 custom enchantments. Its user-facing path is a player issuing `/ce enchant` to create an enchanted book, then combining that book with an item; equipped or held enchantments subsequently react to game events, tick, or toggle effects. The plugin initializes configuration, registrations, command handling, and event/tick dispatch. The README documents configurable enchant metadata, disabled-enchantment settings, and explosive world damage. Several enchant implementations are unsampled, so their detailed behavior and links are not inferred.

Main entry points: [`src/DaPigGuy/PiggyCustomEnchants/PiggyCustomEnchants.php`](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/PiggyCustomEnchants.php) (Plugin startup), [`src/DaPigGuy/PiggyCustomEnchants/enchants`](https://github.com/kencenggame/piggycustomenchants/tree/master/src/DaPigGuy/PiggyCustomEnchants/enchants) (Enchant implementations), [`src/DaPigGuy/PiggyCustomEnchants/EventListener.php`](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/EventListener.php) (Event listener), [`src/DaPigGuy/PiggyCustomEnchants/CustomEnchantManager.php`](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/CustomEnchantManager.php) (Enchant registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Plugin core"]
  node_plugin["Plugin startup"]
  node_manager["Enchant registry"]
  node_listener["Event listener<br/>[EventListener.php]"]
  node_ticktask["Tick scheduler"]
end

subgraph group_commands["Player commands"]
  node_command["Command router"]
  node_enchantcmd["Enchant item command"]
  node_othercmds["Other CE commands"]
end

subgraph group_enchantments["Enchant runtime"]
  node_catalog["Enchant implementations"]
  node_base["Enchant base<br/>[CustomEnchant.php]"]
  node_ids["Enchant identifiers"]
  node_reactive["Reactive enchant API"]
  node_reactivetrait["Reactive behavior"]
  node_ticking["Ticking enchant API"]
  node_toggle["Toggle enchant API"]
  node_traits["Tick and toggle traits"]
end

subgraph group_gameplay["Gameplay systems"]
  node_projectiles["Custom projectiles"]
  node_tracker["Projectile tracker"]
  node_explosion["Explosion behavior<br/>[PiggyExplosion.php]"]
  node_obsidian["Obsidian block<br/>[PiggyObsidian.php]"]
  node_utils["Gameplay utilities<br/>[Utils.php]"]
end

node_player(("Player"))
node_pmserver["PocketMine server"]

node_player -->|"issues command"| node_command
node_command -->|"routes subcommand"| node_enchantcmd
node_command -->|"registers subcommands"| node_othercmds
node_player -->|"requests book enchant"| node_enchantcmd
node_enchantcmd -->|"looks up enchants"| node_manager
node_enchantcmd -->|"applies enchanted book"| node_player
node_plugin -.->|"registers enchants"| node_manager
node_manager -->|"registers implementations"| node_catalog
node_manager -->|"uses enchant IDs"| node_ids
node_catalog -->|"extends enchant base"| node_base
node_base -->|"uses identifier constants"| node_ids
node_reactive -->|"uses behavior trait"| node_reactivetrait
node_toggle -->|"uses toggle trait"| node_traits
node_listener -->|"dispatches reactions"| node_reactive
node_listener -->|"dispatches toggles"| node_toggle
node_plugin -->|"registers events"| node_listener
node_plugin -->|"schedules ticks"| node_ticktask
node_ticktask -->|"ticks equipped enchants"| node_catalog
node_reactivetrait -->|"tracks projectiles"| node_tracker
node_listener -->|"handles projectile entities"| node_projectiles
node_plugin -->|"registers plugin services"| node_pmserver
node_catalog -->|"uses explosion helper"| node_explosion
node_catalog -->|"uses gameplay helpers"| node_utils
node_plugin -.->|"initializes block integration"| node_obsidian

click node_plugin "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/PiggyCustomEnchants.php"
click node_manager "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/CustomEnchantManager.php"
click node_listener "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/EventListener.php"
click node_ticktask "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/tasks/TickEnchantmentsTask.php"
click node_command "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/commands/CustomEnchantsCommand.php"
click node_enchantcmd "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/commands/subcommands/EnchantSubCommand.php"
click node_othercmds "https://github.com/kencenggame/piggycustomenchants/tree/master/src/DaPigGuy/PiggyCustomEnchants/commands/subcommands"
click node_catalog "https://github.com/kencenggame/piggycustomenchants/tree/master/src/DaPigGuy/PiggyCustomEnchants/enchants"
click node_base "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/enchants/CustomEnchant.php"
click node_ids "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/enchants/CustomEnchantIds.php"
click node_reactive "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/enchants/ReactiveEnchantment.php"
click node_projectiles "https://github.com/kencenggame/piggycustomenchants/tree/master/src/DaPigGuy/PiggyCustomEnchants/entities"
click node_tracker "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/utils/ProjectileTracker.php"
click node_explosion "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/utils/PiggyExplosion.php"
click node_obsidian "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/blocks/PiggyObsidian.php"
click node_utils "https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/utils/Utils.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_plugin,node_manager,node_listener,node_ticktask toneBlue
class node_command,node_enchantcmd,node_othercmds toneAmber
class node_catalog,node_base,node_ids,node_reactive,node_reactivetrait,node_ticking,node_toggle,node_traits,node_pmserver toneMint
class node_projectiles,node_tracker,node_explosion,node_obsidian,node_utils toneRose
class node_player toneIndigo
```

## Components

### Plugin core

- [Plugin startup](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/PiggyCustomEnchants.php): `src/DaPigGuy/PiggyCustomEnchants/PiggyCustomEnchants.php`
- [Enchant registry](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/CustomEnchantManager.php): `src/DaPigGuy/PiggyCustomEnchants/CustomEnchantManager.php`
- [Event listener](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/EventListener.php): `src/DaPigGuy/PiggyCustomEnchants/EventListener.php`
- [Tick scheduler](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/tasks/TickEnchantmentsTask.php): `src/DaPigGuy/PiggyCustomEnchants/tasks/TickEnchantmentsTask.php`

### Player commands

- [Command router](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/commands/CustomEnchantsCommand.php): `src/DaPigGuy/PiggyCustomEnchants/commands/CustomEnchantsCommand.php`
- [Enchant item command](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/commands/subcommands/EnchantSubCommand.php): `src/DaPigGuy/PiggyCustomEnchants/commands/subcommands/EnchantSubCommand.php`
- [Other CE commands](https://github.com/kencenggame/piggycustomenchants/tree/master/src/DaPigGuy/PiggyCustomEnchants/commands/subcommands): `src/DaPigGuy/PiggyCustomEnchants/commands/subcommands`

### Enchant runtime

- [Enchant implementations](https://github.com/kencenggame/piggycustomenchants/tree/master/src/DaPigGuy/PiggyCustomEnchants/enchants): `src/DaPigGuy/PiggyCustomEnchants/enchants`
- [Enchant base](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/enchants/CustomEnchant.php): `src/DaPigGuy/PiggyCustomEnchants/enchants/CustomEnchant.php`
- [Enchant identifiers](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/enchants/CustomEnchantIds.php): `src/DaPigGuy/PiggyCustomEnchants/enchants/CustomEnchantIds.php`
- [Reactive enchant API](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/enchants/ReactiveEnchantment.php): `src/DaPigGuy/PiggyCustomEnchants/enchants/ReactiveEnchantment.php`
- **Reactive behavior**
- **Ticking enchant API**
- **Toggle enchant API**
- **Tick and toggle traits**

### Gameplay systems

- [Custom projectiles](https://github.com/kencenggame/piggycustomenchants/tree/master/src/DaPigGuy/PiggyCustomEnchants/entities): `src/DaPigGuy/PiggyCustomEnchants/entities`
- [Projectile tracker](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/utils/ProjectileTracker.php): `src/DaPigGuy/PiggyCustomEnchants/utils/ProjectileTracker.php`
- [Explosion behavior](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/utils/PiggyExplosion.php): `src/DaPigGuy/PiggyCustomEnchants/utils/PiggyExplosion.php`
- [Obsidian block](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/blocks/PiggyObsidian.php): `src/DaPigGuy/PiggyCustomEnchants/blocks/PiggyObsidian.php`
- [Gameplay utilities](https://github.com/kencenggame/piggycustomenchants/blob/master/src/DaPigGuy/PiggyCustomEnchants/utils/Utils.php): `src/DaPigGuy/PiggyCustomEnchants/utils/Utils.php`

### Other components

- **Player**
- **PocketMine server**

## Connections

- Player → Command router: issues command (evidence: `README.md`)
- Command router → Enchant item command: routes subcommand (evidence: `src/DaPigGuy/PiggyCustomEnchants/commands/CustomEnchantsCommand.php`)
- Command router → Other CE commands: registers subcommands (evidence: `src/DaPigGuy/PiggyCustomEnchants/commands/CustomEnchantsCommand.php`)
- Player → Enchant item command: requests book enchant (evidence: `README.md`)
- Enchant item command → Enchant registry: looks up enchants (evidence: `src/DaPigGuy/PiggyCustomEnchants/commands/subcommands/EnchantSubCommand.php`)
- Enchant item command → Player: applies enchanted book (evidence: `README.md`)
- Plugin startup → Enchant registry: registers enchants (evidence: `src/DaPigGuy/PiggyCustomEnchants/CustomEnchantManager.php`)
- Enchant registry → Enchant implementations: registers implementations (evidence: `src/DaPigGuy/PiggyCustomEnchants/CustomEnchantManager.php`)
- Enchant registry → Enchant identifiers: uses enchant IDs (evidence: `src/DaPigGuy/PiggyCustomEnchants/CustomEnchantManager.php`)
- Enchant implementations → Enchant base: extends enchant base (evidence: `src/DaPigGuy/PiggyCustomEnchants/enchants/armor/boots/JetpackEnchant.php`)
- Enchant base → Enchant identifiers: uses identifier constants (evidence: `src/DaPigGuy/PiggyCustomEnchants/enchants/CustomEnchant.php`)
- Reactive enchant API → Reactive behavior: uses behavior trait (evidence: `src/DaPigGuy/PiggyCustomEnchants/enchants/ReactiveEnchantment.php`)
- Toggle enchant API → Tick and toggle traits: uses toggle trait
- Event listener → Reactive enchant API: dispatches reactions (evidence: `src/DaPigGuy/PiggyCustomEnchants/EventListener.php`)
- Event listener → Toggle enchant API: dispatches toggles (evidence: `src/DaPigGuy/PiggyCustomEnchants/EventListener.php`)
- Plugin startup → Event listener: registers events (evidence: `src/DaPigGuy/PiggyCustomEnchants/PiggyCustomEnchants.php`)
- Plugin startup → Tick scheduler: schedules ticks (evidence: `src/DaPigGuy/PiggyCustomEnchants/PiggyCustomEnchants.php`)
- Tick scheduler → Enchant implementations: ticks equipped enchants (evidence: `src/DaPigGuy/PiggyCustomEnchants/tasks/TickEnchantmentsTask.php`)
- Reactive behavior → Projectile tracker: tracks projectiles
- Event listener → Custom projectiles: handles projectile entities (evidence: `src/DaPigGuy/PiggyCustomEnchants/EventListener.php`)
- Plugin startup → PocketMine server: registers plugin services (evidence: `src/DaPigGuy/PiggyCustomEnchants/PiggyCustomEnchants.php`)
- Enchant implementations → Explosion behavior: uses explosion helper (evidence: `src/DaPigGuy/PiggyCustomEnchants/utils/PiggyExplosion.php`)
- Enchant implementations → Gameplay utilities: uses gameplay helpers (evidence: `src/DaPigGuy/PiggyCustomEnchants/enchants/CustomEnchant.php`)
- Plugin startup → Obsidian block: initializes block integration (evidence: `src/DaPigGuy/PiggyCustomEnchants/PiggyCustomEnchants.php`)
