mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Start refactor work
This commit is contained in:
1 parent
6a8851a446
commit
3e1ec09487
51 files changed
+2397
-2474
No files matched your search
@@ -0,0 +1,30 @@
|
||||
package net.william278.huskhomes.util;
|
||||
|
||||
import net.william278.huskhomes.BukkitHuskHomes;
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface BukkitTaskRunner extends TaskRunner {
|
||||
@Override
|
||||
default void runAsync(@NotNull Runnable runnable) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously((BukkitHuskHomes) getPlugin(), runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
default <T> CompletableFuture<T> supplyAsync(@NotNull Supplier<T> supplier) {
|
||||
final CompletableFuture<T> future = new CompletableFuture<>();
|
||||
Bukkit.getScheduler().runTaskAsynchronously((BukkitHuskHomes) getPlugin(),
|
||||
() -> future.complete(supplier.get()));
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
default void runSync(@NotNull Runnable runnable) {
|
||||
Bukkit.getScheduler().runTask((BukkitHuskHomes) getPlugin(), runnable);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user