-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
163 additions
and
91 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
7 changes: 7 additions & 0 deletions
7
src/main/java/me/byteful/plugin/leveltools/api/scheduler/Scheduler.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,7 @@ | ||
package me.byteful.plugin.leveltools.api.scheduler; | ||
|
||
public interface Scheduler { | ||
void asyncDelayed(Runnable runnable, long ticksDelay); | ||
|
||
void syncTimer(Runnable runnable, long ticksDelay, long ticksPeriod); | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/me/byteful/plugin/leveltools/api/scheduler/impl/BukkitScheduler.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,23 @@ | ||
package me.byteful.plugin.leveltools.api.scheduler.impl; | ||
|
||
import me.byteful.plugin.leveltools.LevelToolsPlugin; | ||
import me.byteful.plugin.leveltools.api.scheduler.Scheduler; | ||
import org.bukkit.Bukkit; | ||
|
||
public class BukkitScheduler implements Scheduler { | ||
private final LevelToolsPlugin plugin; | ||
|
||
public BukkitScheduler(LevelToolsPlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public void asyncDelayed(Runnable runnable, long ticksDelay) { | ||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, runnable, ticksDelay); | ||
} | ||
|
||
@Override | ||
public void syncTimer(Runnable runnable, long ticksDelay, long ticksPeriod) { | ||
Bukkit.getScheduler().runTaskTimer(plugin, runnable, ticksDelay, ticksPeriod); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/me/byteful/plugin/leveltools/api/scheduler/impl/FoliaScheduler.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,25 @@ | ||
package me.byteful.plugin.leveltools.api.scheduler.impl; | ||
|
||
import me.byteful.plugin.leveltools.LevelToolsPlugin; | ||
import me.byteful.plugin.leveltools.api.scheduler.Scheduler; | ||
import org.bukkit.Bukkit; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
public class FoliaScheduler implements Scheduler { | ||
private final LevelToolsPlugin plugin; | ||
|
||
public FoliaScheduler(LevelToolsPlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public void asyncDelayed(Runnable runnable, long ticksDelay) { | ||
Bukkit.getAsyncScheduler().runDelayed(plugin, x -> runnable.run(), ticksDelay * 50, TimeUnit.MILLISECONDS); | ||
} | ||
|
||
@Override | ||
public void syncTimer(Runnable runnable, long ticksDelay, long ticksPeriod) { | ||
Bukkit.getGlobalRegionScheduler().runAtFixedRate(plugin, x -> runnable.run(), ticksDelay, ticksPeriod); | ||
} | ||
} |
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
Oops, something went wrong.