All Projects → PaperMC → Paperlib

PaperMC / Paperlib

Licence: mit
Plugin Library for interfacing with Paper Specific API's with graceful fallback that maintains Spigot Compatibility, such as Async Chunk Loading.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Paperlib

Item Nbt Api
Add custom NBT tags to Items/Tiles/Entities without NMS!
Stars: ✭ 163 (+50.93%)
Mutual labels:  minecraft, spigot, paper, library
Plotsquared
PlotSquared - Reinventing the plotworld
Stars: ✭ 284 (+162.96%)
Mutual labels:  minecraft, spigot, paper
Timings
Source to the Aikar's Minecraft Timings Viewer
Stars: ✭ 132 (+22.22%)
Mutual labels:  minecraft, spigot, paper
Guilds
Adding RPG to your server has never been more fun and action-packed!
Stars: ✭ 66 (-38.89%)
Mutual labels:  minecraft, spigot, paper
Commandapi
An API for the command UI introduced in Minecraft 1.13
Stars: ✭ 116 (+7.41%)
Mutual labels:  minecraft, spigot, paper
Betonquest
An advanced and powerful quest scripting plugin for Minecraft. Features built-in RPG style conversations and integration for over 25 other plugins.
Stars: ✭ 121 (+12.04%)
Mutual labels:  minecraft, spigot, paper
Akarin
Akarin is a powerful (not yet) server software from the 'new dimension'
Stars: ✭ 332 (+207.41%)
Mutual labels:  minecraft, spigot, paper
Mohist
Minecraft Forge Hybrid server implementing the Paper/Spigot/Bukkit API, formerly known as Thermos/Cauldron/MCPC+
Stars: ✭ 489 (+352.78%)
Mutual labels:  minecraft, spigot, paper
Npclib
(Minecraft) NPCLib – Basic non-player character library.
Stars: ✭ 98 (-9.26%)
Mutual labels:  minecraft, spigot, library
Yatopia
The Most Powerful and Feature Rich Minecraft Server Software!
Stars: ✭ 408 (+277.78%)
Mutual labels:  minecraft, spigot, paper
Xseries
Library for cross-version Minecraft Bukkit support and various efficient API methods.
Stars: ✭ 109 (+0.93%)
Mutual labels:  minecraft, spigot, library
Essentials
The essential plugin suite for Minecraft servers.
Stars: ✭ 957 (+786.11%)
Mutual labels:  minecraft, spigot, paper
Bedwarsrel
Bedwars Reloaded - The Minecraft Bedwars Plugin!
Stars: ✭ 108 (+0%)
Mutual labels:  minecraft, spigot, paper
Purpur
Purpur is a fork of Paper, Tuinity, and Airplane with the goal of providing new and interesting configuration options, which allow for creating a unique gameplay experience not seen anywhere else
Stars: ✭ 286 (+164.81%)
Mutual labels:  minecraft, spigot, paper
Slimefun4
Slimefun 4 - A unique Spigot/Paper plugin that looks and feels like a modpack. We've been giving you backpacks, jetpacks, reactors and much more since 2013.
Stars: ✭ 369 (+241.67%)
Mutual labels:  minecraft, spigot, paper
Minecraftdev
Plugin for IntelliJ IDEA that gives special support for Minecraft modding projects.
Stars: ✭ 645 (+497.22%)
Mutual labels:  minecraft, spigot, paper
Gate
A high performant & paralleled Minecraft proxy server with scalability, flexibility & excellent server version support - ready for the cloud!
Stars: ✭ 102 (-5.56%)
Mutual labels:  minecraft, spigot, paper
Redprotect
RedProtect Easy and Light Weight Antigrief plugin.
Stars: ✭ 51 (-52.78%)
Mutual labels:  minecraft, spigot
Skinsrestorer
Spigot plugin that provides player skin management. Supports offline mode servers.
Stars: ✭ 45 (-58.33%)
Mutual labels:  minecraft, spigot
Luckperms
A permissions plugin for Minecraft servers.
Stars: ✭ 1,100 (+918.52%)
Mutual labels:  minecraft, spigot

PaperLib

PaperLib is a plugin library for interfacing with Paper specific APIs (such as async chunk loading), with graceful fallbacks maintaining compatibility with both the Bukkit and Spigot API's.

API

All API calls can be found as static util methods in the PaperLib class.

getChunkAtAsync

public class PaperLib {
  public static CompletableFuture<Chunk> getChunkAtAsync(Location loc);
  public static CompletableFuture<Chunk> getChunkAtAsync(Location loc, boolean gen);
  public static CompletableFuture<Chunk> getChunkAtAsync(World world, int x, int z);
  public static CompletableFuture<Chunk> getChunkAtAsync(World world, int x, int z, boolean gen); 
}

On Paper, loads (or generates on 1.13.1+) the chunk asynchronously if it is not loaded yet, then completes the returned future. Chunk will load synchronous on Spigot.

teleportAsync

public class PaperLib {
  public static CompletableFuture<Boolean> teleportAsync(Entity entity, Location location);
  public static CompletableFuture<Boolean> teleportAsync(Entity entity, Location location, TeleportCause cause);
}

Uses the Async Chunk Load API, and if possible, loads/generates the chunk asynchronously before teleporting. Will load synchronous on Spigot.

On 1.15+, this has an added improvement of also loading neighbor chunks to avoid collision checks loading chunks too.

isChunkGenerated

public class PaperLib {
  public static boolean isChunkGenerated(Location loc);
  public static boolean isChunkGenerated(World world, int x, int z);
}

Returns whether or not the chunk is generated. Only Supported in Paper 1.12+ and Spigot 1.13.1+

getBlockState

public class PaperLib {
  public static BlockStateSnapshotResult getBlockState(Block block, boolean useSnapshot);
}

Allows you to optionally avoid taking a snapshot of a TileEntity in a BlockState. Versions prior to 1.12 will always be false for the snapshot. In versions 1.12+ on Spigot, the snapshot will always be true. In Paper 1.12+, the snapshot will be whether or not you requested one in the API call.

suggestPaper

public class PaperLib {
  public static void suggestPaper(Plugin plugin);
}

Helps inform users who run your plugin on Spigot that your plugin will behave better on Paper! Calling this method will print out an informational message in the logs that they should switch to Paper, and will help users discover our software. We would appreciate it if you call this method, but it is optional.

Example Plugin

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!");
            }
        });
    }
}

Build Script Setup

Add the Paper repository and the PaperLib dependency, then shade and relocate it to your own package. Relocation helps avoid version conflicts with other plugins using PaperLib.

Gradle

Repo:

repositories {
    maven {
        name 'papermc'
        url 'https://papermc.io/repo/repository/maven-public/'
    }
}

Dependency:

dependencies {
    compile "io.papermc:paperlib:1.0.6"
}

Shadow Jar and Relocate:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
    }
}
apply plugin: "com.github.johnrengelman.shadow"
shadowJar {
   relocate 'io.papermc.lib', '[YOUR PLUGIN PACKAGE].paperlib'
}

Maven

Repo:

<repositories>
    <repository>
        <id>papermc</id>
        <url>https://papermc.io/repo/repository/maven-public/</url>
    </repository>
</repositories>

Dependency:

<dependencies>
    <dependency>
        <groupId>io.papermc</groupId>
        <artifactId>paperlib</artifactId>
        <version>1.0.6</version>
        <scope>compile</scope>
     </dependency>
 </dependencies>

Shade & Relocate:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.1.1</version>
            <configuration>
                <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
                <relocations>
                    <relocation>
                        <pattern>io.papermc.lib</pattern>
                        <shadedPattern>[YOUR PLUGIN PACKAGE].paperlib</shadedPattern> <!-- Replace this -->
                    </relocation>
                </relocations>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

License

PaperLib is licensed under the MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].