MinecraftServerAPI is a powerful and flexible plugin for Minecraft servers, providing RESTful APIs to interact with the server programmatically. This project allows server administrators to automate tasks, gather information, manage the server more efficiently, and even trigger WebHooks for various server events.
- Java: JDK 20 or higher is required to build and run the project.
- Maven: Make sure Maven is installed on your system. You can download it here.
- Minecraft Server: Make sure you have a Paper or Spigot Minecraft server running on your machine.
- Docker: The Test Environment is set up using Docker. Make sure you have Docker installed on your system. You can download it here.
- Clone the repository to your local machine.
git clone [email protected]:Shweit/MinecraftServerAPI.git
cd MinecraftServerAPI
- Build the project using Maven.
mvn clean install
- Copy the generated JAR file to the
plugins
directory of your Minecraft server.
cp target/MinecraftServerAPI-1.0.jar /path/to/your/minecraft/server/plugins
- Start or restart your Minecraft server.
java -Xmx1024M -Xms1024M -jar paper-1.21.jar nogui
- Once the server is running, the plugin will be loaded automatically. You can verify it by running:
/plugins
- The API is accessible at
http://localhost:7000/
. You can test it by sending a GET request to the following endpoint:GET http://localhost:7000/api/v1/ping
.
- Get all Players:
curl -X 'GET' \
'http://localhost:7000/v1/players' \
-H 'accept: application/json' \
-H 'Authorization: <API_KEY>'
MinecraftServerAPI supports WebHooks, allowing you to trigger HTTP requests to specified URLs when certain events occur on your server (e.g., server start, server stop, plugin enable/disable).
- Define WebHooks URLs: In your
config.yml
located in theplugins/MinecraftServerAPI
, specify the URLs you want to trigger for different events. - Enable/Disable WebHooks: You can enable or disable WebHooks for specific events by setting the
enabled
flag totrue
orfalse
in theconfig.yml
file. Or you can enable/disable the WebHooks with the following commands:
- Enable a WebHook:
/webhook enable <event>
- Disable a WebHook:
/webhook disable <event>
- List all WebHooks:
/webhook list
MinecraftServerAPI allows you to send custom WebHook events to the URLs specified in your config.yml file. This feature enables you to trigger specific WebHook notifications manually.
To send a custom WebHook event, use the following command in-game or via the server console:
/webhook send <event>
For a detailed list of all available WebHooks and their default settings, please refer to the WebHooks Documentation.
The plugin is configured via a config.yml
file in the `plugins/MinecraftServerAPI directory. Here, you can set the authentication key and other settings.
Contributions are welcome! Please read the contributing guidelines to get started.