forked from SteamWar/SteamWar
Add @LinkedTimer
A method of a linked class annotated with @LinkedTimer(delay, period) is run repeatedly by the linker, on Spigot and Velocity. The method must not have parameters, its return value is ignored. It is called through a MethodHandle bound once when linking instead of reflection; LambdaMetafactory cannot be used as the linker and the linked classes are in different class loaders. The unit defaults to ticks and can be set to milliseconds up to hours; the Unit enum converts it to ticks for Spigot and to a TimeUnit for Velocity. HullHiderCommand uses it for its tick task.
This commit is contained in:
@@ -61,6 +61,11 @@ public class SpigotLinker extends AbstractLinker<JavaPlugin> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scheduleTimer(Runnable runnable, long delay, long period, LinkedTimer.Unit unit) {
|
||||
Bukkit.getScheduler().runTaskTimer(plugin, runnable, unit.toTicks(delay), unit.toTicks(period));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void unlinkObject(Object any) {
|
||||
if (any instanceof Listener) {
|
||||
|
||||
Reference in New Issue
Block a user