Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mclicense.org/llms.txt

Use this file to discover all available pages before exploring further.

Adding the library

We offer two ways to add MC License to your plugin: Option 1 — Dependency (recommended) Add the following repository and dependency to your build file:
<repository>
    <id>flyte-repository-releases</id>
    <name>Flyte Repository</name>
    <url>https://repo.flyte.gg/releases</url>
</repository>

<dependency>
    <groupId>org.mclicense</groupId>
    <artifactId>library</artifactId>
    <version>1.5.1</version>
    <scope>compile</scope>
</dependency>
Option 2 — Single class (copy/paste) If you’re having trouble shading the library into your plugin, or simply prefer not to manage external dependencies, you can copy a single class directly into your project instead. Head to the mcl-library-one-class repo and copy either MCLicense.java or MCLicense.kt into your project. No shading needed — all required dependencies are already on the Paper server classpath at runtime.
With the single-class approach you’ll need to manually check that repo for updates, rather than just bumping a version number in your build file.

Checking a license

Each license check requires two things: the pluginId and the license key. The pluginId is a unique identifier for your plugin, and the license key is the key that the user has set in the mclicense.txt file in your plugin’s folder (the library will create this file). You’ll need the pluginId for the validate function. To find it, head to the plugin on your dashboard and copy the random string of characters from the URL. It’ll look something like this: 3gd7u9r4 (8 characters). To validate a license in your plugin, simply add the following code snippet to your onEnable:
if (!MCLicense.validateKey(this, "yourPluginId")) {
    Bukkit.getPluginManager().disablePlugin(this);
    return;
}
As you can see, the validateKey function returns a Boolean. In the above code snippet, if the key is invalid, the plugin will be disabled. If the key is valid, the plugin will continue to load.
The library will handle the console logging for you, whether successful or rejected.

Not building a Minecraft plugin?

MC License isn’t limited to Minecraft plugins — you can protect any software that can make HTTP requests. Check out our guide for non-Minecraft use cases.