|
2 | 2 |
|
3 | 3 | [](https://github.com/EndstoneMC/python-example-plugin/actions/workflows/build.yml) |
4 | 4 |
|
5 | | -An example Python plugin for [Endstone](https://github.com/EndstoneMC/endstone) servers, demonstrating commands, |
6 | | -events, configuration, and permissions. |
| 5 | +A starter template for building [Endstone](https://github.com/EndstoneMC/endstone) plugins in Python. |
| 6 | +Demonstrates commands, events, configuration, and permissions. |
7 | 7 |
|
8 | | -## Prerequisites |
| 8 | +## Use This Template |
9 | 9 |
|
10 | | -- Python 3.10 or higher |
11 | | -- [uv](https://docs.astral.sh/uv/) (recommended) or pip |
| 10 | +1. Click **Use this template** on GitHub (or fork/clone it) |
| 11 | +2. Rename the following to match your plugin: |
12 | 12 |
|
13 | | -## Getting Started |
| 13 | +| What | Where | Example | |
| 14 | +|------|-------|---------| |
| 15 | +| Package name | `pyproject.toml` `[project] name` | `endstone-my-plugin` | |
| 16 | +| Package directory | `src/endstone_example/` | `src/endstone_my_plugin/` | |
| 17 | +| Entry point | `pyproject.toml` `[project.entry-points."endstone"]` | `my-plugin = "endstone_my_plugin:MyPlugin"` | |
| 18 | +| Plugin class | `plugin.py` class name + `prefix` | `MyPlugin`, `prefix = "MyPlugin"` | |
| 19 | +| Permission prefix | `plugin.py` `permissions` dict keys | `my_plugin.command.*` | |
14 | 20 |
|
15 | | -1. **Clone this repository** |
| 21 | +3. Set `api_version = "0.11"` (or the Endstone version you target) |
| 22 | +4. Delete the example command/listener code and start building |
16 | 23 |
|
17 | | - ```bash |
18 | | - git clone https://github.com/EndstoneMC/python-example-plugin.git |
19 | | - cd python-example-plugin |
20 | | - ``` |
| 24 | +## Development |
21 | 25 |
|
22 | | -2. **Install in development mode** |
23 | | - |
24 | | - ```bash |
25 | | - uv sync --extra dev |
26 | | - ``` |
| 26 | +```bash |
| 27 | +git clone https://github.com/EndstoneMC/python-example-plugin.git |
| 28 | +cd python-example-plugin |
| 29 | +uv sync --extra dev # Install dependencies |
| 30 | +uv run ruff check src/ # Lint |
| 31 | +``` |
27 | 32 |
|
28 | | -3. **Run linting** |
| 33 | +For live development on a running server, activate the server's virtualenv and install in |
| 34 | +editable mode: |
29 | 35 |
|
30 | | - ```bash |
31 | | - uv run ruff check src/ |
32 | | - ``` |
| 36 | +```bash |
| 37 | +pip install -e . |
| 38 | +``` |
33 | 39 |
|
34 | | -4. **Build a wheel for distribution** |
| 40 | +Then use `/reload` in-game to pick up code changes without restarting. |
35 | 41 |
|
36 | | - ```bash |
37 | | - uv build |
38 | | - ``` |
| 42 | +## Project Structure |
39 | 43 |
|
40 | | - Copy the `.whl` from `dist/` into your Endstone server's `plugins/` folder. |
| 44 | +``` |
| 45 | +src/endstone_example/ |
| 46 | + __init__.py Re-exports the plugin class |
| 47 | + plugin.py Plugin lifecycle, commands, config |
| 48 | + listener.py Event listener (player join/quit) |
| 49 | + config.toml Default config (copied on first run) |
| 50 | +``` |
41 | 51 |
|
42 | | -## Structure |
| 52 | +## Install on a Server |
43 | 53 |
|
| 54 | +```bash |
| 55 | +uv build |
44 | 56 | ``` |
45 | | -python-example-plugin/ |
46 | | -├── src/ |
47 | | -│ └── endstone_example/ |
48 | | -│ ├── __init__.py # Package entry point, re-exports ExamplePlugin |
49 | | -│ ├── plugin.py # Plugin class: lifecycle, config, commands |
50 | | -│ ├── listener.py # Event listener: player join/quit |
51 | | -│ └── config.toml # Default plugin configuration |
52 | | -├── .github/ |
53 | | -│ ├── dependabot.yml # Automated dependency updates |
54 | | -│ └── workflows/ |
55 | | -│ ├── build.yml # CI: lint |
56 | | -│ └── release.yml # Release automation |
57 | | -├── CHANGELOG.md # Release notes (keepachangelog format) |
58 | | -├── pyproject.toml # Build config, dependencies, tool settings |
59 | | -├── LICENSE # MIT License |
60 | | -└── README.md # This file |
61 | | -``` |
| 57 | + |
| 58 | +Copy the `.whl` from `dist/` into your server's `plugins/` folder and restart. |
| 59 | + |
| 60 | +## Releasing |
| 61 | + |
| 62 | +This template includes a GitHub Actions release workflow. To make a release: |
| 63 | + |
| 64 | +1. Add your changes under `## [Unreleased]` in `CHANGELOG.md` |
| 65 | +2. Go to **Actions > Release > Run workflow** |
| 66 | +3. Enter the version (e.g. `0.5.0`) and run |
| 67 | + |
| 68 | +The workflow validates the version, updates the changelog, creates a git tag and GitHub release, |
| 69 | +builds the wheel, publishes to PyPI (if configured), and attaches the `.whl` to the release. |
| 70 | + |
| 71 | +Use **dry run** to preview without making changes. |
| 72 | + |
| 73 | +Versioning is handled automatically by [hatch-vcs](https://github.com/ofek/hatch-vcs): tagged |
| 74 | +commits get clean versions (e.g. `0.5.0`), untagged commits get dev versions |
| 75 | +(e.g. `0.5.1.dev3`). |
62 | 76 |
|
63 | 77 | ## Documentation |
64 | 78 |
|
65 | | -For more on the Endstone API, see the [documentation](https://endstone.readthedocs.io). |
| 79 | +For more on the Endstone API, see the [documentation](https://endstone.dev/latest/). |
66 | 80 |
|
67 | 81 | ## License |
68 | 82 |
|
69 | | -This project is licensed under the MIT License. See [LICENSE](LICENSE) for details. |
| 83 | +[MIT License](LICENSE) |
0 commit comments