@@ -3,6 +3,7 @@ package com.y54895.matrixlib.api.update
33import com.google.gson.JsonObject
44import com.google.gson.JsonParser
55import com.y54895.matrixlib.api.brand.MatrixBranding
6+ import com.y54895.matrixlib.api.compat.FoliaUtil
67import com.y54895.matrixlib.api.resource.MatrixResourceFiles
78import com.y54895.matrixlib.api.text.MatrixText
89import org.bukkit.Bukkit
@@ -442,16 +443,20 @@ object MatrixPluginUpdates {
442443 return
443444 }
444445 val periodTicks = settings.checkIntervalMinutes * 60L * 20L
445- repeatingTaskId = Bukkit .getScheduler().runTaskTimerAsynchronously (
446+ repeatingTaskId = FoliaUtil .runRepeating (
446447 BukkitPlugin .getInstance(),
447- Runnable { checkAllAsync() },
448448 periodTicks,
449- periodTicks
450- ).taskId
449+ periodTicks,
450+ Runnable { checkAllAsync() }
451+ ).hashCode()
451452 }
452453
453454 private fun runAsync (block : () -> Unit ) {
454- Bukkit .getScheduler().runTaskAsynchronously(BukkitPlugin .getInstance(), Runnable (block))
455+ if (FoliaUtil .isFolia) {
456+ FoliaUtil .runLater(BukkitPlugin .getInstance(), 1L , Runnable (block))
457+ } else {
458+ Bukkit .getScheduler().runTaskAsynchronously(BukkitPlugin .getInstance(), Runnable (block))
459+ }
455460 }
456461
457462 private fun loadSettings (): MatrixUpdateSettings {
@@ -544,4 +549,4 @@ private fun CommandSender.sendUpdaterMessage(text: String) {
544549
545550fun CommandSender.sendMatrixUpdaterMessage (text : String ) {
546551 sendUpdaterMessage(text)
547- }
552+ }
0 commit comments