-
-
Notifications
You must be signed in to change notification settings - Fork 0
GH-30 Add folia scheduler #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f785f79
[WIP] Add folia scheduler basics
vLuckyyy 06f9d55
Fix folia api.
vLuckyyy 041f930
Add entity, region, location. scheduelrs.
vLuckyyy 3f7f81f
Implement bukkit scheduler.
vLuckyyy de86a4d
Add MinecraftScheduler.
Rollczi ba89a83
Fix imports
Rollczi d0a3b24
Remove getPlugin method
Rollczi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.