GithubHelp home page GithubHelp logo

loving11ish / folialib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from technicallycoded/folialib

0.0 0.0 0.0 30 KB

This is a wrapper library for aiding in supporting the Folia Paper Fork. This library adds multiple scheduler options to use instead of the Bukkit or Folia native schedulers.

License: MIT License

Java 100.00%

folialib's Introduction

FoliaLib

GitHub Release

Disclaimer:
This project is not directly affiliated with Paper team or the Folia project.

Description

This is a wrapper library for aiding in supporting the Folia Paper Fork. This library adds multiple scheduler options to use instead of the Bukkit or Folia native schedulers. Developers are expected to depend on this library and relocate the package to their own to prevent conflicts with other plugins.

Note: This project is still in its early stages and may make frequent breaking changes to the API. Additionally, I won't claim that this library is perfect; If you find any issues, please report them on the issues page

As a dependency

Maven

<repositories>
    <repository>
        <id>devmart-other</id>
        <url>https://nexuslite.gcnt.net/repos/other/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.tcoded</groupId>
        <artifactId>FoliaLib</artifactId>
        <version>[VERSION]</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

!! You are expected to relocate the package "com.tcoded.folialib" to your own (ex: "me.steve.lib.folialib") to prevent conflicts with other plugins !!


Gradle

repositories {
    maven {
        name = "devmart-other"
        url = "https://nexuslite.gcnt.net/repos/other/"
    }
}

dependencies {
    implementation "com.tcoded:FoliaLib:[VERSION]"
}

!! You are expected to relocate the package "com.tcoded.folialib" to your own (ex: "me.steve.lib.folialib") to prevent conflicts with other plugins !!

How to use

Create a new instance of the FoliaLib class:

// Assuming "this" is your plugin instance
FoliaLib foliaLib = new FoliaLib(this);

Here are some examples of how to use the library:

// Remember that 20 ticks = 1000 milliseconds, and 20 * 50L = 1000L

// On a folia server, runNextTick() will run using the GlobalRegionScheduler
//   !! This does not make it safe to use for players or block changes !!
//   Use other methods below for handling those
//   This should only be used for updating the following (see GlobalRegionScheduler.java for more info)
//     - world day time, world game time, weather cycle, sleep night skipping, executing commands for console, and other misc
// On a Spigot server, runNextTick() will run on the main thread
foliaLib.getImpl().runNextTick(() -> {/* Code */});

// In both cases, this method will run asynchronously
foliaLib.getImpl().runAsync(() -> {/* Code */});

// On a Folia server, this method will run using the GlobalRegionScheduler
// On a Spigot server, this method will run on the main thread
foliaLib.getImpl().runTimer(() -> {/* Code */}, 0L, 20 * 50L, TimeUnit.MILLISECONDS);

// In both cases, this method will run asynchronously
foliaLib.getImpl().runTimerAsync(() -> {/* Code */}, 0L, 20 * 50L, TimeUnit.MILLISECONDS);

// On a folia server, this will run the code using the RegionScheduler that is appropriate for the location
// On a spigot server, this will run the code on the main thread
foliaLib.getImpl().runAtLocation(location, () -> {/* Code */});

// On a folia server, this will run the code using the EntityScheduler that is appropriate for the entity
// On a spigot server, this will just run the code on the main thread
foliaLib.getImpl().runAtEntity(entity, () -> {/* Code */});

License

This project is licensed under the MIT License - see the LICENSE file for details

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.