Skip to content

Creating your first module

Kirill Dunchenko edited this page Sep 15, 2026 · 2 revisions

This guide is written with the assumption that the reader understands how to use Gradle, the Paper API, and has basic knowledge of the Java programming language.

Setting up project

Adding dependency

First of all, you should add hitori as Gradle dependency. hitori is published on our repository modoru repository.

repositories {
    // ...
    maven { url 'https://repository.modoru.fun/releases' }
}
dependencies {
    // ...
    implementation 'su.hitori:hitori:version'
}

Declaring module metadata

Module metadata is declared in hitori.module.json file. You should place it into your resources/ folder.

{
  "key": "docs:example",
  "version": "1.0.0",
  "main": "docs.example.ExampleModule",
  "packages": [
    "docs.example"
  ],
  "depends": {
    "java": ">=25",
    "hitori": ">=2.0.0"
  }
}

Metadata fields

Each field serves a specific purpose:

key — unique identifier of the module. It is used to identify the module inside hitori.
version — version of the module. This should follow Semantic Versioning.
main — fully qualified class name of the module's main class. This class must extend su.hitori.api.module.Module.
packages — list of base packages that belong to the module.
depends — declares the versions of Java and hitori required by the module. Both java and hitori dependencies are required.

The key and main fields are especially important because hitori uses them to identify the module and locate its main class.

The depends section tells hitori which environment is required to run the module:

{
  "depends": {
    "java": ">=25",
    "hitori": ">=2.0.0"
  }
}

This means that the module requires Java 25 or newer and hitori 2.0.0 or newer.

Version requirements support the following operators:

Operator Description
> Version must be greater than the specified version
= Version must exactly match the specified version
>= Version must be greater than or equal to the specified version

For example:

"java": ">=25"

requires Java 25 or newer, while:

"hitori": "=2.0.0"

requires exactly hitori 2.0.0.

Additional hitori modules can also be declared inside depends when the module requires them.

Main module class

Main module class should be the same as specified in properties, main field.

As specified in properties, example module class should look like this:

package docs.example;

import su.hitori.api.module.Module;
import su.hitori.api.module.enable.EnableContext;

public final class ExampleModule extends Module {

    @Override
    public void enable(EnableContext context) {
    }

    @Override
    public void disable() {
    }

}

Clone this wiki locally