### Leaf Server Commands Source: https://context7.com/winds-studio/leaf/llms.txt Provides examples of common Leaf server management commands, including checking the version, viewing server performance (MSPT), and reloading the configuration. Each command is associated with its required permission node. ```bash # Check Leaf version /leaf version # Permission: leaf.command.leaf.version # View server tick performance /leaf mspt # Permission: leaf.command.leaf.mspt # Reload Leaf configuration /leaf reload # Permission: leaf.command.leaf.reload ``` -------------------------------- ### Example Patch Header and Diff Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/CONTRIBUTING.md Demonstrates the structure of a patch header and a code diff for a server-side change in Leaf. It includes metadata about the commit and the specific file modifications. ```patch From 02abc033533f70ef3165a97bfda3f5c2fa58633a Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sun, 15 Oct 2017 00:29:07 +0100 Subject: [PATCH] revert serverside behavior of keepalives This patch intends to bump up the time that a client has to reply to the server back to 30 seconds as per pre 1.12.2, which allowed clients more than enough time to reply potentially allowing them to be less temperamental due to lag spikes on the network thread, e.g. that caused by plugins that are interacting with netty. We also add a system property to allow people to tweak how long the server will wait for a reply. There is a compromise here between lower and higher values, lower values will mean that dead connections can be closed sooner, whereas higher values will make this less sensitive to issues such as spikes from networking or during connections flood of chunk packets on slower clients, at the cost of dead connections being kept open for longer. diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java index a92bf8967..d0ab87d0f 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java ``` -------------------------------- ### Publish Leaf API to Maven Local Source: https://context7.com/winds-studio/leaf/llms.txt Instructions for building and installing the Leaf API to your local Maven repository, enabling its use in plugin development. Includes the Gradle command and how to configure your plugin's build script. ```bash # Install to local Maven repository ./gradlew publishToMavenLocal # In your plugin's build.gradle.kts, add mavenLocal() BEFORE other repos repositories { mavenLocal() // Must be first for local builds maven("https://maven.leafmc.one/snapshots/") } ``` -------------------------------- ### BlockExplosionHitEvent API Source: https://context7.com/winds-studio/leaf/llms.txt Example of how to use the BlockExplosionHitEvent to customize block behavior during explosions. ```APIDOC ## BlockExplosionHitEvent API Custom event fired when a block is affected by an explosion. Allows plugins to cancel explosion effects on specific blocks. ```java import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.dreeam.leaf.event.BlockExplosionHitEvent; import org.bukkit.ExplosionResult; import org.bukkit.block.Block; import org.bukkit.entity.Entity; public class ExplosionProtectionListener implements Listener { @EventHandler public void onBlockExplosionHit(BlockExplosionHitEvent event) { Block block = event.getBlock(); Entity source = event.getSource(); ExplosionResult result = event.getResult(); // Protect bedrock layer blocks from explosions if (block.getY() < 5) { event.setCancelled(true); return; } // Protect blocks in spawn area if (block.getLocation().distance(block.getWorld().getSpawnLocation()) < 100) { event.setCancelled(true); } } } ``` ``` -------------------------------- ### Handle BlockExplosionHitEvent in Java Source: https://context7.com/winds-studio/leaf/llms.txt Implement a listener for the BlockExplosionHitEvent to customize explosion behavior. This example prevents explosions from affecting bedrock layers and blocks within 100 blocks of the spawn location. ```java import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.dreeam.leaf.event.BlockExplosionHitEvent; import org.bukkit.ExplosionResult; import org.bukkit.block.Block; import org.bukkit.entity.Entity; public class ExplosionProtectionListener implements Listener { @EventHandler public void onBlockExplosionHit(BlockExplosionHitEvent event) { Block block = event.getBlock(); Entity source = event.getSource(); ExplosionResult result = event.getResult(); // Protect bedrock layer blocks from explosions if (block.getY() < 5) { event.setCancelled(true); return; } // Protect blocks in spawn area if (block.getLocation().distance(block.getWorld().getSpawnLocation()) < 100) { event.setCancelled(true); } } } ``` -------------------------------- ### Access Transformer Commit Message Format Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/CONTRIBUTING.md Example of how to include access transformer definitions within a git commit message for patches that require visibility changes. ```text From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 8 Jun 2022 22:20:16 -0700 Subject: [PATCH] Paper config files This patch adds Paper configuration files. Access transformers for this patch are below, but before the co-authors. == AT == public org.spigotmc.SpigotWorldConfig getBoolean(Ljava/lang/String;Z)Z public net.minecraft.world.level.NaturalSpawner SPAWNING_CATEGORIES Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com> diff --git a/build.gradle.kts b/build.gradle.kts ... ``` -------------------------------- ### Configure Dynamic Activation of Brain (DAB) (YAML) Source: https://context7.com/winds-studio/leaf/llms.txt Optimize entity AI by configuring Dynamic Activation of Brain (DAB). This feature reduces brain tick frequency for entities far from players, saving resources. Customizable parameters include start distance, max tick frequency, and activation distance modifier. ```yaml # config/leaf-global.yml performance: dab: enabled: false start-distance: 12 # Distance at which DAB begins affecting entities max-tick-freq: 20 # Maximum ticks between brain updates (20 = 1 second) activation-dist-mod: 8 # Distance impact modifier on tick frequency dont-enable-if-in-water: false # Protect aquatic entities from drowning blacklisted-entities: - villager - axolotl - hoglin - zombified_piglin - goat ``` -------------------------------- ### Edit Git Commit with Rebase - Interactive Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/CONTRIBUTING.md This method involves using `git rebase -i` to modify a specific commit. It requires temporarily resetting the HEAD, editing the commit, and then continuing the rebase. Ensure to stash any uncommitted changes before starting. This process might require resetting related modules to compatible commits to maintain compilation. ```bash git stash git rebase -i base # In editor: replace 'pick' with 'edit' for the target commit # Make changes git add . git commit --amend git rebase --continue ./gradlew rebuildPatches ``` -------------------------------- ### Building Leaf from Source Source: https://context7.com/winds-studio/leaf/llms.txt Steps to clone the Leaf repository and build the server JAR using Gradle. ```APIDOC ## Building from Source Build Leaf server JAR for distribution using Gradle. ```bash # Clone the repository git clone https://github.com/Winds-Studio/Leaf.git cd Leaf # Apply patches and build ./gradlew applyPatches && ./gradlew createMojmapPaperclipJar # The output JAR will be in build/libs/ ``` ``` -------------------------------- ### Build Leaf Server JAR from Source Source: https://context7.com/winds-studio/leaf/llms.txt Instructions to build the Leaf server JAR distribution from its source code using Gradle. This involves cloning the repository, applying patches, and executing the build command. ```bash # Clone the repository git clone https://github.com/Winds-Studio/Leaf.git cd Leaf # Apply patches and build ./gradlew applyPatches && ./gradlew createMojmapPaperclipJar # The output JAR will be in build/libs/ ``` -------------------------------- ### Async Pathfinding Configuration Source: https://context7.com/winds-studio/leaf/llms.txt Configuration options for enabling and tuning asynchronous pathfinding to improve server performance. ```APIDOC ## Async Pathfinding Configuration Enable asynchronous pathfinding to offload mob pathfinding calculations to separate threads, improving server tick performance. ```yaml # config/leaf-global.yml async: async-pathfinding: enabled: true max-threads: 0 # 0 = auto (CPU cores / 4, minimum 1) keepalive: 60 # Thread keepalive in seconds queue-size: 0 # 0 = auto (max-threads * 256) reject-policy: FLUSH_ALL # FLUSH_ALL or CALLER_RUNS when queue is full ``` ``` -------------------------------- ### Configure Async Pathfinding (YAML) Source: https://context7.com/winds-studio/leaf/llms.txt Enable and configure asynchronous pathfinding in Leaf. This YAML configuration allows offloading mob pathfinding calculations to separate threads for improved server performance. Options include thread count, keepalive, queue size, and rejection policy. ```yaml # config/leaf-global.yml async: async-pathfinding: enabled: true max-threads: 0 # 0 = auto (CPU cores / 4, minimum 1) keepalive: 60 # Thread keepalive in seconds queue-size: 0 # 0 = auto (max-threads * 256) reject-policy: FLUSH_ALL # FLUSH_ALL or CALLER_RUNS when queue is full ``` -------------------------------- ### Build Leaf JAR with Gradle Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/README.md This command uses Gradle to apply all necessary patches and then create a Paperclip JAR file for distribution. It's a crucial step for building the project. ```bash ./gradlew applyAllPatches && ./gradlew createMojmapPaperclipJar ``` -------------------------------- ### Configure Async Entity Tracker (YAML) Source: https://context7.com/winds-studio/leaf/llms.txt Enable and configure the experimental asynchronous entity tracker. This feature aims to improve performance with many entities in close proximity by utilizing multithreading. Use with caution. ```yaml # config/leaf-global.yml async: async-entity-tracker: enabled: false # Experimental - enable with caution threads: 0 # 0 = auto (min of CPU cores or 4) ``` -------------------------------- ### Accessing Configuration Values Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/CONTRIBUTING.md Demonstrates how to retrieve global and world-specific configuration values within the Leaf project. ```java int maxPlayers = GlobalConfiguration.get().misc.maxNumOfPlayers; ``` ```java int maxPlayers = level.paperConfig().misc.maxNumOfPlayers; ``` -------------------------------- ### Configure Server Branding Source: https://context7.com/winds-studio/leaf/llms.txt Customize the server's brand name that is displayed to clients, both in the F3 debug screen and the server GUI window title. ```yaml misc: server-mod-name: "Leaf" server-gui-name: "Leaf" ``` -------------------------------- ### Configure Async Mob Spawning (YAML) Source: https://context7.com/winds-studio/leaf/llms.txt Enable asynchronous mob spawning to improve server performance, especially on servers with many players. This configuration option offloads mob spawning calculations to a separate thread. ```yaml # config/leaf-global.yml async: async-mob-spawning: enabled: false ``` -------------------------------- ### Adding Configuration Setting in GlobalConfiguration Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/CONTRIBUTING.md Shows how to add a new configuration setting to the GlobalConfiguration class in Java. This involves defining a new field within an inner class that extends ConfigurationPart. ```java public class GlobalConfiguration { // other sections public class Misc extends ConfigurationPart { // other settings public boolean lagCompensateBlockBreaking = true; public boolean useDimensionTypeForCustomSpawners = false; public int maxNumOfPlayers = 20; // This is the new setting } } ``` -------------------------------- ### Async Mob Spawning Configuration Source: https://context7.com/winds-studio/leaf/llms.txt Configuration options for enabling asynchronous mob spawning to reduce main thread load. ```APIDOC ## Async Mob Spawning Configuration Offload mob spawning calculations to a separate thread for better performance on servers with many players. ```yaml # config/leaf-global.yml async: async-mob-spawning: enabled: false ``` ``` -------------------------------- ### Configure Async Chunk Sending (YAML) Source: https://context7.com/winds-studio/leaf/llms.txt Enable asynchronous chunk sending to reduce the overhead on the main server thread. This configuration option allows chunks to be sent to players without blocking the primary game loop. ```yaml # config/leaf-global.yml async: async-chunk-send: enabled: false ``` -------------------------------- ### Using Fully Qualified Names for Imports Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/CONTRIBUTING.md Shows how to use fully qualified class names instead of adding new imports to prevent patch conflicts in existing files. ```java import org.bukkit.event.Event; // don't add import here, use FQN like below public class SomeEvent extends Event { public final org.bukkit.Location newLocation; // Leaf - add location } ``` -------------------------------- ### Async Entity Tracker Configuration Source: https://context7.com/winds-studio/leaf/llms.txt Configuration options for enabling multithreaded entity tracking to enhance performance with many entities. ```APIDOC ## Async Entity Tracker Configuration Enable multithreaded entity tracking to improve performance with large numbers of entities in close proximity. ```yaml # config/leaf-global.yml async: async-entity-tracker: enabled: false # Experimental - enable with caution threads: 0 # 0 = auto (min of CPU cores or 4) ``` ``` -------------------------------- ### API Dependency Configuration (Maven & Gradle) Source: https://context7.com/winds-studio/leaf/llms.txt Instructions on how to add the Leaf API to your plugin project using Maven or Gradle. ```APIDOC ## API Dependency Configuration Add Leaf API to your plugin project to access Leaf-specific features and events. ### Maven ```xml leafmc https://maven.leafmc.one/snapshots/ cn.dreeam.leaf leaf-api 1.21.11-R0.1-SNAPSHOT provided ``` ### Gradle (Kotlin DSL) ```kotlin repositories { maven { url = uri("https://maven.leafmc.one/snapshots/") } } dependencies { compileOnly("cn.dreeam.leaf:leaf-api:1.21.11-R0.1-SNAPSHOT") } java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) } ``` ``` -------------------------------- ### Marking Code Modifications in Java Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/CONTRIBUTING.md Demonstrates the required comment syntax for marking single-line and multi-line code changes in Leaf project files to ensure traceability. ```java entity.getWorld().dontBeStupid(); // Leaf - Was beStupid(), which is bad entity.getFriends().forEach(Entity::explode); entity.updateFriends(); // Leaf start - Use plugin-set spawn // entity.getWorld().explode(entity.getWorld().getSpawn()); Location spawnLocation = ((CraftWorld)entity.getWorld()).getSpawnLocation(); entity.getWorld().explode(new BlockPosition(spawnLocation.getX(), spawnLocation.getY(), spawnLocation.getZ())); // Leaf end - Use plugin-set spawn ``` -------------------------------- ### Configure Mod Protocol Support Source: https://context7.com/winds-studio/leaf/llms.txt Enable server-side support for various client mods to enhance compatibility without requiring server plugins. This includes mods like Jade, AppleSkin, and Xaero's Minimap. ```yaml network: protocol-support: jade-protocol: false appleskin-protocol: false appleskin-protocol-sync-tick-interval: 20 asteorbar-protocol: false chatimage-protocol: false xaero-map-protocol: false xaero-map-server-id: 0 syncmatica-protocol: false do-a-barrel-roll-protocol: false ``` -------------------------------- ### Async Chunk Sending Configuration Source: https://context7.com/winds-studio/leaf/llms.txt Configuration options for enabling asynchronous chunk sending to minimize main thread overhead. ```APIDOC ## Async Chunk Sending Configuration Send chunks to players asynchronously to reduce main thread overhead. ```yaml # config/leaf-global.yml async: async-chunk-send: enabled: false ``` ``` -------------------------------- ### Obfuscation Helper for Local Variable Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/CONTRIBUTING.md Illustrates the use of an obfuscation helper for a local variable in Java. This pattern aims to improve code readability and maintainability by providing clearer names for variables. ```java double d0 = entity.getX(); final double fromX = d0; // Leaf - OBFHELPER // ... this.someMethod(fromX); // Leaf ``` -------------------------------- ### Add Leaf API Dependency (Gradle) Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/README.md This snippet demonstrates how to add the Leaf API as a dependency in a Gradle project. It includes configuring the Maven repository and declaring the compileOnly dependency. ```kotlin repositories { maven { url = uri("https://maven.leafmc.one/snapshots/") } } dependencies { compileOnly("cn.dreeam.leaf:leaf-api:1.21.11-R0.1-SNAPSHOT") } java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) } ``` -------------------------------- ### Dynamic Activation of Brain (DAB) Configuration Source: https://context7.com/winds-studio/leaf/llms.txt Configuration for Dynamic Activation of Brain (DAB) to optimize entity AI by adjusting brain tick frequency based on distance. ```APIDOC ## Dynamic Activation of Brain (DAB) Configuration Optimize entity AI by reducing brain tick frequency for entities far from players. ```yaml # config/leaf-global.yml performance: dab: enabled: false start-distance: 12 # Distance at which DAB begins affecting entities max-tick-freq: 20 # Maximum ticks between brain updates (20 = 1 second) activation-dist-mod: 8 # Distance impact modifier on tick frequency dont-enable-if-in-water: false # Protect aquatic entities from drowning blacklisted-entities: - villager - axolotl - hoglin - zombified_piglin - goat ``` ``` -------------------------------- ### Configure Parallel World Ticking Source: https://context7.com/winds-studio/leaf/llms.txt Enable experimental parallel world ticking for multi-world servers. This feature aims to improve performance by processing world ticks in parallel. ```yaml async: sparkly-paper-parallel-world-ticking: enabled: false ``` -------------------------------- ### Configure Leaf API Dependency (Gradle Kotlin) Source: https://context7.com/winds-studio/leaf/llms.txt Add the Leaf API to your plugin project using Gradle with Kotlin DSL. This enables the use of Leaf-specific functionalities. Note the Java toolchain version requirement. ```kotlin repositories { maven { url = uri("https://maven.leafmc.one/snapshots/") } } dependencies { compileOnly("cn.dreeam.leaf:leaf-api:1.21.11-R0.1-SNAPSHOT") } java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) } ``` -------------------------------- ### Edit Git Commit with Rebase - Fixup Commits Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/CONTRIBUTING.md This approach uses 'fixup' or 'squash' commits to modify recent changes. It allows for compilation during the process. The manual method involves interactive rebase to move a temporary commit, while the automatic method uses `git commit --fixup` or `--squash` followed by `git rebase -i --autosquash`. ```bash # Manual method git rebase -i base # In editor: move temporary commit and change 'pick' to 'f' or 's' ./gradlew rebuildPatches ``` ```bash # Automatic method git commit -a --fixup git rebase -i --autosquash base ./gradlew rebuildPatches ``` -------------------------------- ### Configure Sentry Logging Source: https://context7.com/winds-studio/leaf/llms.txt Configure Sentry integration for error logging. This can be done via the config file or environment variables. It allows setting the DSN and log level, with an option to only log entries with exceptions. ```yaml misc: sentry: dsn: "" log-level: WARN only-log-thrown: true ``` ```bash # Or set via environment variable # export SENTRY_DSN="https://your-dsn@sentry.io/project" ``` -------------------------------- ### Add Leaf API Dependency (Maven) Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/README.md This snippet shows how to configure your Maven project to include the Leaf API as a dependency. It specifies the repository and the dependency coordinates. ```xml leafmc https://maven.leafmc.one/snapshots/ ``` ```xml cn.dreeam.leaf leaf-api 1.21.11-R0.1-SNAPSHOT provided ``` -------------------------------- ### Configure Knockback Mechanics Source: https://context7.com/winds-studio/leaf/llms.txt Customize knockback behavior for various gameplay elements like snowballs, eggs, and player-zombie interactions. This section allows enabling or disabling specific knockback effects. ```yaml gameplay-mechanisms: knockback: snowball-knockback-players: false egg-knockback-players: false can-player-knockback-zombie: true old-blast-protection-explosion-knockback: false ``` -------------------------------- ### Configure Username Validation Source: https://context7.com/winds-studio/leaf/llms.txt Control username validation to allow non-standard characters, which is useful for international servers. Setting 'vanilla-username-check' to false enables support for characters beyond the standard set. ```yaml misc: vanilla-username-check: enabled: true ``` -------------------------------- ### Rebase PR to Include Latest Master Changes Source: https://github.com/winds-studio/leaf/blob/ver/1.21.11/CONTRIBUTING.md Steps to update a feature or fix branch with the latest changes from the `master` branch. This involves pulling from `upstream`, rebasing the feature branch onto `master`, and reapplying patches. Conflicts may need manual resolution. ```bash git checkout master && git pull upstream master git checkout patch-branch && git rebase master ./gradlew applyPatches # Resolve conflicts if any # Ensure new patches are last commits or reorder with interactive rebase ./gradlew rebuildPatches git push --force ``` -------------------------------- ### Sentry Error Tracking Configuration Source: https://context7.com/winds-studio/leaf/llms.txt Configuration details for integrating Sentry for automatic error reporting and monitoring. ```APIDOC ## Sentry Error Tracking Configuration Integrate Sentry for automatic error reporting and monitoring. ```yaml # config/leaf-global.yml sentry: enabled: false dsn: "" environment: "" release: "" ``` ``` -------------------------------- ### Check if Running on Leaf Server (Java) Source: https://context7.com/winds-studio/leaf/llms.txt A Java method to determine if the current server environment is running Leaf. It checks for the existence of a core Leaf class. ```java public boolean isLeafServer() { try { Class.forName("org.dreeam.leaf.config.LeafConfig"); return true; } catch (ClassNotFoundException e) { return false; } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.