From 54217b1131b6cdfaa2a9f93c951b7e66068165b1 Mon Sep 17 00:00:00 2001 From: Penal Buffalo Date: Sat, 10 Aug 2024 10:51:21 -0500 Subject: [PATCH] v4.1.1 b52 * potential fix for nametags not working after a while --- gradle.properties | 2 +- .../arcaneplugins/levelledmobs/LevelledMobs.kt | 3 +++ .../levelledmobs/managers/NametagQueueManager.kt | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 70745286b..1bcddc5dc 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 a1fe58dc7..82d7583c5 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 c1fc016fc..9b7a159e3 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