Skip to content

Universal scheduling lib for Folia/Spigot/Bukkit/etc. plugins

License

Notifications You must be signed in to change notification settings

Anon8281/UniversalScheduler

Repository files navigation

Universal Scheduler

Is a lib for java minecraft plugins to simplify Folia support implementation

Just for your information: Folia doesn't support any of Bukkit.getScheduler().* and Bukkit.getServer().getScheduler().* scheduling methods

Java version: 8 or above

Supported:

  • Folia
  • Paper
  • Spigot

Plugins using UniversalScheduler

Name Link
Brewery (Fork) GitHub
InventoryRollbackPlus (Fork) GitHub
CraftBook (Fork) GitHub
PlaceholderAPI (Fork) GitHub
ImageOnMap (Fork) GitHub
BigDoors (Fork) GitHub
WorldGuardExtraFlags (Fork) GitHub
HorseTpWithMe (Fork) GitHub
BetterTridents (Fork) GitHub
HolographicDisplays (Fork) GitHub
Lucko helper (Fork) GitHub
HexNicks GitHub
WorldEdit (Unstable Fork) GitHub
SuperVanish (Fork) GitHub
TownyWaypoints (Fork) GitHub

How to use scheduler?

  1. To your plugin Main add:
private static TaskScheduler scheduler;
@Override
public void onEnable() {
        //if your already have onEnable() just add next line to it
        scheduler = UniversalScheduler.getScheduler(this);
}
public static TaskScheduler getScheduler() {
        return scheduler;
}
  1. Call it just like
Main.getScheduler().runTaskLater(() -> { //Main there is your plugin Main
        Bukkit.broadcastMessage("Wow, it was scheduled");
});
  1. If you need to get the scheduled task for some reason
MyScheduledTask task = Main.getScheduler().runTaskLater(() -> { //Main there is your plugin Main
        Bukkit.broadcastMessage("Wow, it was scheduled");
}, 10L);

Maven information

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>
<dependency>
    <groupId>com.github.Anon8281</groupId>
    <artifactId>UniversalScheduler</artifactId>
    <version>[VERSION]</version>
    <scope>compile</scope>
</dependency>

Shading:

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.5.0</version>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>shade</goal>
                </goals>
                <configuration>
                    <artifactSet>
                        <includes>
                            <include>com.github.Anon8281:UniversalScheduler</include>
                        </includes>
                    </artifactSet>
                    <relocations>
                        <relocation>
                            <pattern>com.github.Anon8281.universalScheduler</pattern>
                            <!-- Don't forget to replace -->
                            <shadedPattern>[YOUR_PLUGIN_PACKAGE].universalScheduler</shadedPattern>
                        </relocation>
                    </relocations>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

Gradle information

repositories {
    //...
    maven { url 'https://jitpack.io' }
}
dependencies {
    //...
    implementation 'com.github.Anon8281:UniversalScheduler:[VERSION]'
}

Shading:

shadowJar {
    //Don't forget to replace
    relocate 'com.github.Anon8281.universalScheduler', '[YOUR_PLUGIN_PACKAGE].universalScheduler' 
}