Skip to content

Fluent java library for Minecraft, providing elegant async/sync runnable chaining with Bukkit, Spigot, Paper, Velocity integration.

License

Notifications You must be signed in to change notification settings

milkdrinkers/ThreadUtil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

88 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

ThreadUtil

GitHub License Maven Central Version Documentation Javadoc GitHub Actions Workflow Status GitHub Issues GitHub last commit Discord Server

A fluent scheduling utility for Minecraft plugins, providing elegant async/sync runnable chaining with Bukkit/Spigot/Paper/Velocity integration.


🌟 Features

  • Fluent API for async/sync task chaining
  • Built-in delay support with tick/Duration precision
  • Task cancellation support
  • Thread-safe error handling
  • Custom thread pool integration

πŸ“¦ Installation

The bukkit, velocity & sponge modules transitively include common. Additionally you should shade the library into your plugin jar.

Gradle Kotlin DSL
repositories {
    mavenCentral()
}

dependencies {
    implementation("io.github.milkdrinkers:threadutil-common:VERSION")
    implementation("io.github.milkdrinkers:threadutil-bukkit:VERSION")
    implementation("io.github.milkdrinkers:threadutil-sponge:VERSION")
    implementation("io.github.milkdrinkers:threadutil-velocity:VERSION")
}
Maven
<project>
    <dependencies>
        <dependency>
            <groupId>io.github.milkdrinkers</groupId>
            <artifactId>threadutil-common</artifactId>
            <version>VERSION</version>
        </dependency>
        <dependency>
            <groupId>io.github.milkdrinkers</groupId>
            <artifactId>threadutil-bukkit</artifactId>
            <version>VERSION</version>
        </dependency>
        <dependency>
            <groupId>io.github.milkdrinkers</groupId>
            <artifactId>threadutil-sponge</artifactId>
            <version>VERSION</version>
        </dependency>
        <dependency>
            <groupId>io.github.milkdrinkers</groupId>
            <artifactId>threadutil-velocity</artifactId>
            <version>VERSION</version>
        </dependency>
    </dependencies>
</project>

Usage Example πŸš€

import io.github.milkdrinkers.threadutil.queue.RunningTaskQueue;
import io.github.milkdrinkers.threadutil.PlatformBukkit;
import io.github.milkdrinkers.threadutil.Scheduler;

// Initialize ThreadUtil when your software is starting!
Scheduler.init(new PlatformBukkit(plugin));

// Start executing the queue and store the running task queue
RunningTaskQueue taskQueue = Scheduler
    .async(() -> {
        return fetchPlayerData(player.getUniqueId());
    })
    .delay(Duration.ofSeconds(10))
    .async(playerData -> {
        saveToFile(playerData);
    })
    .execute();

// Wait 5 seconds then cancel the other task queue
Scheduler
    .delay(Duration.ofSeconds(5))
    .sync(() -> {
        taskQueue.cancel();
    })
    .execute();

// Make sure to shut down your scheduler when your software is stopping!
Scheduler.shutdown();

πŸ“š Documentation


πŸ”¨ Building from Source

git clone https://github.com/milkdrinkers/ThreadUtil.git
cd threadutil
./gradlew publishToMavenLocal

πŸ”§ Contributing

Contributions are always welcome! Please make sure to read our Contributor's Guide for standards and our Contributor License Agreement (CLA) before submitting any pull requests.

We also ask that you adhere to our Contributor Code of Conduct to ensure this community remains a place where all feel welcome to participate.


πŸ“ Licensing

You can find the license the source code and all assets are under here. Additionally, contributors agree to the Contributor License Agreement (CLA) found here.


❀️ Acknowledgments

  • Aikar: For their excellent utility TaskChain, which this was inspired by. I highly recommend their library, providing the same features and more for any platform!

πŸ”₯ Consuming Projects

Here is a list of known projects using ThreadUtil:

  • Minecraft-Plugin-Template - Provided by default in a Minecraft Plugin Template.
  • Maquillage - Maquillage a Minecraft cosmetics plugin.
  • Stewards - Stewards a Minecraft Towny NPC extension plugin.
  • CharacterCards - CharacterCards is a Minecraft plugin allowing players to create cards describing their character.
  • (Add your project here!)

About

Fluent java library for Minecraft, providing elegant async/sync runnable chaining with Bukkit, Spigot, Paper, Velocity integration.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

Contributors 2

  •  
  •  

Languages