-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [WIP] Add folia scheduler basics * Fix folia api. * Add entity, region, location. scheduelrs. * Implement bukkit scheduler. * Add MinecraftScheduler. * Fix imports * Remove getPlugin method --------- Co-authored-by: Rollczi <[email protected]>
- Loading branch information
Showing
12 changed files
with
407 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...ons-bukkit/src/main/java/com/eternalcode/commons/bukkit/scheduler/MinecraftScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.eternalcode.commons.bukkit.scheduler; | ||
|
||
import com.eternalcode.commons.scheduler.Scheduler; | ||
import com.eternalcode.commons.scheduler.Task; | ||
import java.time.Duration; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.function.Supplier; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Entity; | ||
|
||
public interface MinecraftScheduler extends Scheduler { | ||
|
||
boolean isGlobalTickThread(); | ||
|
||
boolean isPrimaryThread(); | ||
|
||
boolean isRegionThread(Entity entity); | ||
|
||
boolean isRegionThread(Location location); | ||
|
||
Task run(Runnable task); | ||
|
||
Task runAsync(Runnable task); | ||
|
||
default Task run(Location location, Runnable task) { | ||
return run(task); | ||
} | ||
|
||
default Task run(Entity entity, Runnable task) { | ||
return run(task); | ||
} | ||
|
||
Task runLater(Runnable task, Duration delay); | ||
|
||
Task runLaterAsync(Runnable task, Duration delay); | ||
|
||
default Task runLater(Location location, Runnable task, Duration delay) { | ||
return runLater(task, delay); | ||
} | ||
|
||
default Task runLater(Entity entity, Runnable task, Duration delay) { | ||
return runLater(task, delay); | ||
} | ||
|
||
Task timer(Runnable task, Duration delay, Duration period); | ||
|
||
Task timerAsync(Runnable task, Duration delay, Duration period); | ||
|
||
default Task timer(Location location, Runnable task, Duration delay, Duration period) { | ||
return timer(task, delay, period); | ||
} | ||
|
||
default Task timer(Entity entity, Runnable task, Duration delay, Duration period) { | ||
return timer(task, delay, period); | ||
} | ||
|
||
<T> CompletableFuture<T> complete(Supplier<T> task); | ||
|
||
<T> CompletableFuture<T> completeAsync(Supplier<T> task); | ||
|
||
default <T> CompletableFuture<T> complete(Location location, Supplier<T> task) { | ||
return complete(task); | ||
} | ||
|
||
default <T> CompletableFuture<T> complete(Entity entity, Supplier<T> task) { | ||
return complete(task); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
plugins { | ||
`commons-java-17` | ||
`commons-publish` | ||
`commons-repositories` | ||
`commons-java-unit-test` | ||
} | ||
|
||
|
||
dependencies { | ||
api(project(":eternalcode-commons-shared")) | ||
api(project(":eternalcode-commons-bukkit")) | ||
|
||
compileOnlyApi("dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT") | ||
|
||
api("org.jetbrains:annotations:24.1.0") | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} |
Oops, something went wrong.