### Compile PaperLib with Gradle Source: https://github.com/papermc/paperlib/blob/master/README.md Use this command to build the PaperLib project. Ensure you have Gradle installed and configured. ```bash ./gradlew build ``` -------------------------------- ### Example Plugin with PaperLib Usage Source: https://github.com/papermc/paperlib/blob/master/README.md Demonstrates how to use PaperLib's suggestPaper and teleportAsync methods within a Java plugin. Ensure PaperLib is properly included as a dependency. ```java public class MyPlugin extends JavaPlugin { public void onEnable() { PaperLib.suggestPaper(this); } public void doSomething(Entity entity, Location location) { PaperLib.teleportAsync(entity, location).thenAccept(result -> { if (result) { player.sendMessage("Teleported!"); } else { player.sendMessage("Something went wrong!"); } }); } } ``` -------------------------------- ### Get Block State with Optional Snapshotting Source: https://github.com/papermc/paperlib/blob/master/README.md Retrieves the state of a block, with an option to avoid taking a TileEntity snapshot. Snapshot behavior varies by server version and type. ```java public class PaperLib { public static BlockStateSnapshotResult getBlockState(Block block, boolean useSnapshot); } ``` -------------------------------- ### Inform Users to Use Paper Server Source: https://github.com/papermc/paperlib/blob/master/README.md A utility method to notify users running a plugin on Spigot that it performs better on Paper. This helps promote Paper and informs users of potential performance improvements. ```java public class PaperLib { public static void suggestPaper(Plugin plugin); } ``` -------------------------------- ### Asynchronous Chunk Loading with PaperLib Source: https://github.com/papermc/paperlib/blob/master/README.md Provides methods to asynchronously load or generate chunks. On Paper, these operations are asynchronous; on Spigot, they are synchronous. ```java public class PaperLib { public static CompletableFuture getChunkAtAsync(Location loc); public static CompletableFuture getChunkAtAsync(Location loc, boolean gen); public static CompletableFuture getChunkAtAsync(World world, int x, int z); public static CompletableFuture getChunkAtAsync(World world, int x, int z, boolean gen); } ``` -------------------------------- ### suggestPaper Source: https://github.com/papermc/paperlib/blob/master/README.md Informs users running the plugin on Spigot about the benefits of using Paper. ```APIDOC ## suggestPaper ### Description This method helps inform users who are running your plugin on Spigot that your plugin will perform better on Paper. Calling this method will print an informational message to the logs, encouraging users to switch to Paper. This is an optional method that helps promote the use of Paper. ### Method `static void suggestPaper(Plugin plugin)` ### Parameters * **plugin** (Plugin) - The plugin instance for which to suggest Paper. ``` -------------------------------- ### Maven Shade Plugin for Relocation Source: https://github.com/papermc/paperlib/blob/master/README.md Configures the Maven Shade plugin to relocate PaperLib's package. This is crucial for avoiding dependency conflicts in environments with multiple plugins using PaperLib. ```xml org.apache.maven.plugins maven-shade-plugin 3.2.4 ${project.build.directory}/dependency-reduced-pom.xml io.papermc.lib [YOUR PLUGIN PACKAGE].paperlib package shade ``` -------------------------------- ### Asynchronous Teleportation with PaperLib Source: https://github.com/papermc/paperlib/blob/master/README.md Enables asynchronous teleportation by leveraging the Async Chunk Load API. This method can also load neighbor chunks to prevent collisions. Synchronous teleportation occurs on Spigot. ```java public class PaperLib { public static CompletableFuture teleportAsync(Entity entity, Location location); public static CompletableFuture teleportAsync(Entity entity, Location location, TeleportCause cause); } ``` -------------------------------- ### Maven Repository Configuration for PaperLib Source: https://github.com/papermc/paperlib/blob/master/README.md Declares the PaperMC Maven repository in your Maven pom.xml. This allows Maven to find and download the PaperLib artifact. ```xml papermc https://papermc.io/repo/repository/maven-public/ ``` -------------------------------- ### teleportAsync Source: https://github.com/papermc/paperlib/blob/master/README.md Asynchronously teleports an entity to a new location, attempting to load necessary chunks asynchronously. ```APIDOC ## teleportAsync ### Description Asynchronously teleports an entity to a new location. This method leverages the Async Chunk Load API to load or generate chunks before teleporting, improving performance and preventing issues. On Spigot, the teleportation will occur synchronously. On versions 1.15+, this method also loads neighboring chunks to prevent collision checks from loading them. ### Method `static CompletableFuture teleportAsync(Entity entity, Location location)` `static CompletableFuture teleportAsync(Entity entity, Location location, TeleportCause cause)` ### Parameters * **entity** (Entity) - The entity to teleport. * **location** (Location) - The destination location. * **cause** (TeleportCause) - The cause of the teleportation (optional). ``` -------------------------------- ### Gradle Repository Configuration for PaperLib Source: https://github.com/papermc/paperlib/blob/master/README.md Specifies the PaperMC Maven repository in your Gradle build file. This is required to download PaperLib and other Paper artifacts. ```groovy repositories { maven { name "papermc" url "https://papermc.io/repo/repository/maven-public/" } } ``` -------------------------------- ### getBlockState Source: https://github.com/papermc/paperlib/blob/master/README.md Retrieves the block state, with an option to bypass snapshotting TileEntities. ```APIDOC ## getBlockState ### Description Allows retrieval of a block's state. You can optionally avoid taking a snapshot of a TileEntity within the BlockState. For versions prior to 1.12, the snapshot will always be false. In versions 1.12+ on Spigot, the snapshot will always be true. In Paper 1.12+, the snapshot behavior depends on the value passed to the `useSnapshot` parameter. ### Method `static BlockStateSnapshotResult getBlockState(Block block, boolean useSnapshot)` ### Parameters * **block** (Block) - The block for which to get the state. * **useSnapshot** (boolean) - Whether to use a snapshot for the TileEntity. Behavior varies by version and Paper/Spigot. ``` -------------------------------- ### Gradle Shadow Jar Plugin for Relocation Source: https://github.com/papermc/paperlib/blob/master/README.md Configures the Shadow Jar plugin to relocate PaperLib's package. This prevents version conflicts with other plugins that might use different versions of PaperLib. ```groovy plugins { id "com.github.johnrengelman.shadow" version "7.1.0" // Make sure to always use the latest version (https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow) } shadowJar { relocate "io.papermc.lib", "[YOUR PLUGIN PACKAGE].paperlib" } ``` -------------------------------- ### getChunkAtAsync Source: https://github.com/papermc/paperlib/blob/master/README.md Asynchronously loads or generates a chunk at the specified location. Falls back to synchronous loading on Spigot. ```APIDOC ## getChunkAtAsync ### Description Asynchronously loads or generates a chunk at the specified location. On Paper, this operation is asynchronous. On Spigot, the chunk will load synchronously. ### Method `static CompletableFuture getChunkAtAsync(Location loc)` `static CompletableFuture getChunkAtAsync(Location loc, boolean gen)` `static CompletableFuture getChunkAtAsync(World world, int x, int z)` `static CompletableFuture getChunkAtAsync(World world, int x, int z, boolean gen)` ### Parameters * **loc** (Location) - The location for which to load the chunk. * **gen** (boolean) - Whether to generate the chunk if it does not exist (supported on Paper 1.13.1+). * **world** (World) - The world in which the chunk resides. * **x** (int) - The x-coordinate of the chunk. * **z** (int) - The z-coordinate of the chunk. ``` -------------------------------- ### Maven Dependency Declaration for PaperLib Source: https://github.com/papermc/paperlib/blob/master/README.md Includes PaperLib as a compile dependency in your Maven project. Specify the version and scope. ```xml io.papermc paperlib 1.0.7 compile ``` -------------------------------- ### Gradle Dependency Declaration for PaperLib Source: https://github.com/papermc/paperlib/blob/master/README.md Adds PaperLib as a compile-time dependency in your Gradle project. Use the latest version available. ```groovy dependencies { implementation "io.papermc:paperlib:1.0.7" } ``` -------------------------------- ### isChunkGenerated Source: https://github.com/papermc/paperlib/blob/master/README.md Checks if a chunk at the specified coordinates has been generated. ```APIDOC ## isChunkGenerated ### Description Returns whether or not the chunk at the given location or coordinates has been generated. This functionality is supported on Paper 1.12+ and Spigot 1.13.1+. ### Method `static boolean isChunkGenerated(Location loc)` `static boolean isChunkGenerated(World world, int x, int z)` ### Parameters * **loc** (Location) - The location of the chunk to check. * **world** (World) - The world in which the chunk resides. * **x** (int) - The x-coordinate of the chunk. * **z** (int) - The z-coordinate of the chunk. ``` -------------------------------- ### Check if Chunk is Generated with PaperLib Source: https://github.com/papermc/paperlib/blob/master/README.md Determines if a chunk has been generated. This functionality is supported on Paper 1.12+ and Spigot 1.13.1+. ```java public class PaperLib { public static boolean isChunkGenerated(Location loc); public static boolean isChunkGenerated(World world, int x, int z); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.