Skip to content

milkdrinkers/ThreadUtil

Repository files navigation

ThreadUtil

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

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
  • 🚫 Stage cancellation support
  • 🔒 Thread-safe error handling
  • 🧩 Custom thread pool integration

📦 Installation

The bukkit & velocity modules depend on common. Additionally you should shade the dependency into your plugin jar.

Gradle Kotlin DSL
repositories {
    mavenCentral()
}

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

Usage Example 🚀

import io.github.milkdrinkers.threadutil.Scheduler;

Scheduler.async(() -> {
    // Async database operation
    return fetchPlayerData(player.getUniqueId());
})
.delay(Duration.ofSeconds(1))
.delay(1) // Wait one game tick on supported platforms
.sync(data -> {
    // Sync UI update
    player.sendMessage("Loaded: " + data.toString());
    return data.process();
})
.async(processed -> {
    // Async file I/O
    saveToFile(processed);
    return processed;
})
.execute();

📚 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 MUCH MORE for any platform.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages