diff --git a/gradle.properties b/gradle.properties index 70745286..1bcddc5d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 4.1.1 b51 +version = 4.1.1 b52 description = The Ultimate RPG Mob Levelling Solution \ No newline at end of file diff --git a/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/LevelledMobs.kt b/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/LevelledMobs.kt index a1fe58dc..82d7583c 100644 --- a/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/LevelledMobs.kt +++ b/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/LevelledMobs.kt @@ -26,6 +26,7 @@ import io.github.arcaneplugins.levelledmobs.util.MessageUtils import io.github.arcaneplugins.levelledmobs.util.QuickTimer import io.github.arcaneplugins.levelledmobs.util.Utils import io.github.arcaneplugins.levelledmobs.wrappers.LivingEntityWrapper +import io.github.arcaneplugins.levelledmobs.wrappers.SchedulerWrapper import java.time.Instant import java.util.Random import java.util.Stack @@ -127,6 +128,8 @@ class LevelledMobs : JavaPlugin() { if (nametagQueueManager.hasNametagSupport) { levelManager.startNametagAutoUpdateTask() levelManager.startNametagTimer() + val scheduler = SchedulerWrapper { nametagQueueManager.taskChecker() } + scheduler.runTaskTimerAsynchronously(50000, 5000) } prepareToLoadCustomDrops() diff --git a/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/managers/NametagQueueManager.kt b/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/managers/NametagQueueManager.kt index c1fc016f..9b7a159e 100644 --- a/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/managers/NametagQueueManager.kt +++ b/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/managers/NametagQueueManager.kt @@ -75,6 +75,19 @@ class NametagQueueManager { doThread = false } + fun taskChecker(){ + val qt = queueTask ?: return + + if (!qt.isCancelled || Bukkit.getScheduler().isCurrentlyRunning(qt.taskId)) return + val status = if (qt.isCancelled) "cancelled" + else "not running" + + Log.war("Restarting Nametag Queue Manager task, status was $status") + qt.cancel() + isRunning = false + start() + } + fun addToQueue(item: QueueItem) { if (!item.lmEntity.shouldShowLMNametag) return if (Bukkit.getOnlinePlayers().isEmpty()) return