This guide walks you through creating a Hytale server plugin that integrates with HyCitizens. By the end you will have a working Gradle project that compiles against the HyCitizens JAR, obtains theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ElectroGamesDev/HyCitizens/llms.txt
Use this file to discover all available pages before exploring further.
CitizensManager at startup, and registers a listener for Citizen interaction events.
Prerequisites
Before you start, make sure you have the following available:- Hytale Server SDK (
com.hypixel.hytale:Server) — available from the Hytale Maven repository. - Java 25 — HyCitizens is compiled with the Java 25 toolchain; your plugin must match.
- Gradle — the build system used by HyCitizens and recommended for plugin development.
- HyCitizens JAR — because HyCitizens is not published to a Maven repository, you need the compiled JAR file. Download it and place it in your project’s
libs/directory.
Gradle setup
Add the Hytale repository and HyCitizens as a dependency
Open (or create) your
build.gradle.kts and add the Hytale Maven repository alongside mavenCentral(). Declare the Hytale server SDK and the HyCitizens JAR both as compileOnly dependencies — they will be provided at runtime by the server and by HyCitizens itself, so they must not be bundled into your plugin JAR.build.gradle.kts
Set the Java toolchain to Java 25
The
java { toolchain { ... } } block shown above instructs Gradle to compile your plugin with the Java 25 toolchain, matching the version HyCitizens itself targets. If you also want to hard-pin the --release flag (recommended for reproducibility), add:build.gradle.kts
Declare HyCitizens as a plugin dependency in your manifest
Your plugin’s metadata file must list
HyCitizens as a dependency. This guarantees the server loads and initialises HyCitizens before your plugin’s setup() method is called, making HyCitizensPlugin.get() safe to call at that point.The exact format depends on your plugin framework, but the dependency name to use is HyCitizens.Accessing the API
Once your Gradle project is configured, you can obtain theCitizensManager inside your plugin’s setup() method. The static method HyCitizensPlugin.get() returns the singleton plugin instance; from there, getCitizensManager() gives you the central API object.
MyPlugin.java
Listening to events
CitizensManager exposes add*Listener / remove*Listener methods for each event type. The example below registers a CitizenInteractListener that logs the interaction (using the interacting player’s UUID, which is the identifier available on PlayerRef) and shows how to cancel it when needed.
MyPlugin.java
event.setCancelled(true) is set, HyCitizens stops processing subsequent listeners for that interaction and skips executing the Citizen’s own commands and messages. The same cancellation pattern is available on CitizenDeathEvent.
Load order — ensure your plugin declares
HyCitizens as a dependency in its manifest so the server loads HyCitizens first. Without this declaration the load order is undefined and HyCitizensPlugin.get() may still be null when your setup() runs.Next steps
CitizensManager
Explore the full method reference: creating and removing Citizens, movement controls, group management, respawning, and more.
Events
Deep-dive into all four Citizen events, their available fields, and how cancellation works.