Leaf Documentation

repository·ver/26.2·Indexed 21 days ago

https://github.com/winds-studio/leaf

A high-performance, customizable fork of Paper for Minecraft server administrators and plugin developers. Leaf focuses on optimizations for async pathfinding, mob spawning, and entity tracking while maintaining compatibility with Spigot and Paper plugins. Documentation covers building from source, integrating the leaf-api via Gradle or Maven (requiring Java 25), and using server commands such as /leaf, /mspt, and /afk.

Tokens
2.6K
Snippets
14
Records
18
Agent score
75%

What's inside Leaf

  1. Build Leaf from source

    ver/26.2

    To build a Paperclip JAR for distribution, use the following Gradle commands. This process applies all necessary patches and then creates the Paperclip JAR.

    ./gradlew applyAllPatches && ./gradlew createPaperclipJar
  2. Leaf command permissions

    ver/26.2

    Access to the /leaf command and its subcommands is controlled via a hierarchical permission system.

    1. Base Permission: To use any part of the command, you must first have the base permission: leaf.leaf (derived from LeafCommands.COMMAND_BASE_PERM).
    2. Subcommand Permissions: Each subcommand has its own specific permission requirement. Even if you have the base permission, you cannot execute a subcommand unless you also possess that subcommand's specific permission.

    If you lack the necessary permissions, the server will return the standard permission message or a red usage error message.

  3. Use the /leaf command and subcommands

    ver/26.2

    The /leaf command is the primary entrypoint for Leaf-related operations. It uses a subcommand structure. To use a specific feature, you must provide the subcommand name after the base command.

    Available Subcommands

    SubcommandAliasDescription
    reloadN/AReloads the plugin configuration
    versionverDisplays the current version of Leaf
    msptN/ADisplays Milliseconds Per Tick (MSPT) statistics

    Usage Syntax

    /[base_command] [subcommand] [arguments]

    Example: /leaf version or /leaf ver

    /leaf reload
    /leaf version
    /leaf ver
    /leaf mspt
  4. Add Leaf API to Maven project

    ver/26.2

    To use the Leaf API in your Maven-based plugin development, add the leafmc repository and the leaf-api dependency with a provided scope.

    <repository>
        <id>leafmc</id>
        <url>https://maven.leafmc.one/snapshots/</url>
    </repository>
    <dependency>
        <groupId>cn.dreeam.leaf</groupId>
        <artifactId>leaf-api</artifactId>
        <version>26.2.local-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
  5. Configure Leaf API for Gradle

    ver/26.2

    To use the Leaf API in your Gradle project, add the Leaf snapshot repository and the leaf-api dependency. Note that Leaf requires Java 25.

    repositories {
      maven {
        url = uri("https://maven.leafmc.one/snapshots/")
      }
    }
    
    dependencies {
        compileOnly("cn.dreeam.leaf:leaf-api:26.2.local-SNAPSHOT")
    }
    
    java {
      toolchain.languageVersion.set(JavaLanguageVersion.of(25))
    }
  6. Add Leaf API to Gradle project

    ver/26.2

    To use the Leaf API in your Gradle-based plugin development, add the Leaf snapshot repository and the leaf-api dependency. Note that Leaf requires Java 25 as per the current configuration example.

    repositories {
      maven {
        url = uri("https://maven.leafmc.one/snapshots/")
      }
    }
    
    dependencies {
        compileOnly("cn.dreeam.leaf:leaf-api:26.2.local-SNAPSHOT")
    }
    
    java {
      toolchain.languageVersion.set(JavaLanguageVersion.of(25))
    }
  7. Configure Leaf API for Maven

    ver/26.2

    To use the Leaf API in your Maven project, add the Leaf snapshot repository and the leaf-api dependency with provided scope.

    <repository>
        <id>leafmc</id>
        <url>https://maven.leafmc.one/snapshots/</url>
    </repository>
    <dependency>
        <groupId>cn.dreeam.leaf</groupId>
        <artifactId>leaf-api</artifactId>
        <version>26.2.local-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
  8. Implement a custom Leaf subcommand

    ver/26.2

    To extend the Leaf CLI with custom functionality, implement the LeafSubcommand interface. This interface allows you to define the execution logic, permission requirements, and tab-completion behavior for a new subcommand.

    When implementing this interface, you must provide implementations for:

    • execute: The core logic triggered when the subcommand is called.
    • getPermission: The Permission object required to run the command.
    • testPermission: A check to verify if the CommandSender has the necessary permissions.

    Optional:

    • tabComplete: Provides suggestions for command arguments during tab-completion.
    public interface LeafSubcommand {
        boolean execute(CommandSender sender, String subCommand, String[] args);
    
        default List<String> tabComplete(final CommandSender sender, final String subCommand, final String[] args) {
            return Collections.emptyList();
        }
    
        boolean testPermission(CommandSender sender);
    
        Permission getPermission();
    }
  9. Permissions for the version command

    ver/26.2

    The version command requires two specific permissions to be executed:

    1. leaf.<version> (where <version> is the literal version): The base Leaf permission for this subcommand.
    2. bukkit.command.version: The standard Bukkit permission for the version command.

    By default, the command is set to PermissionDefault.TRUE, meaning it is typically available to players who meet the permission requirements.