Overview
This repository provides a minimal Minecraft server plugin using the Spigot API (Maven project). The plugin offers:
- /trash command — opens a 9-slot "Trash Bin" chest GUI
- A confirmation GUI (Confirm/Delete or Cancel) opened after the player closes the trash GUI
- Pending items are deleted on Confirm, or returned/dropped on Cancel
Requirements
- Java 8 or newer (project set to 1.8 compatibility)
- Maven (for building the plugin)
- Spigot / Paper server compatible with the spigot-api version in
pom.xml (the project uses a snapshot API in the example)
Build
From the project root (where pom.xml lives):
mvn -DskipTests package
On success the plugin jar will be produced at:
target/trash-plugin-1.0-SNAPSHOT.jar
Install on a server
- Copy the built jar to your server's
plugins/ directory. Example (PowerShell):
Copy-Item -Path '.\target\trash-plugin-1.0-SNAPSHOT.jar' -Destination 'C:\path\to\server\plugins\' -Force
- Start or restart your Spigot/Paper server. Accept the EULA if required (
eula.txt).
- Check server logs for the plugin enabling: look for "TrashPlugin enabled"
Usage
- In-game type:
/trash
- A 9-slot chest GUI titled
Trash Bin opens. Place items into it (drag or shift-click).
- Close the GUI to open a confirmation screen. Click Confirm Delete to delete items, or Cancel to return them.
Command & Permissions
The plugin currently registers one command in plugin.yml:
trash — opens the trash GUI (no permission by default). To add permissions, update plugin.yml and check in the command executor.
Behavior & Implementation Notes
- GUI identification is title-based. If you run into localization/component-title differences on newer servers, this can be changed to a more robust check.
- To avoid recursive inventory events (which can crash the server on some builds), the confirmation GUI is opened on the next server tick using the scheduler.
- When Cancel is chosen, the plugin attempts to return items to the player's inventory; overflow items are dropped at the player's location.
- When Confirm is chosen, pending items are removed from memory and not returned (permanent delete).
Development notes
Key source files:
src/main/java/com/example/trash/TrashPlugin.java — main plugin class and pending-trash storage
src/main/java/com/example/trash/TrashCommand.java — command executor for /trash
src/main/java/com/example/trash/TrashInventoryListener.java — inventory logic and confirmation GUI
src/main/resources/plugin.yml — plugin metadata and command registration
Suggested next dev tasks:
- Add
config.yml to make titles, GUI size, and button items configurable
- Add a permission
trash.use and check it in the command executor
- Add unit/integration tests and a CI workflow that runs
mvn package
Troubleshooting
- Server crashed or StackOverflow on inventory events: Ensure the confirmation GUI is opened on the next tick instead of directly inside the close event. The code in this repo already follows that pattern.
- Plugin not loading: Check server logs for
plugin.yml errors, API version mismatches, or EULA not accepted.
- Items not returned on Cancel: Check player inventory overflow — overflow items are dropped at the player's location by design.
License
This project is provided as-is. Add a LICENSE file in the repo root to declare a license (MIT/Apache/etc.) if you want to distribute it.