From c84a2a10f65db2e17d89aa97f06e0a0fba5d70fe Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sat, 18 Jun 2022 11:54:08 +0100 Subject: [PATCH] Revert "Improved pet tick performance" This reverts commit 6dcfd4ccaa0a408dc11f69701ea932058020023b. --- .../kotlin/com/willfp/ecopets/EcoPetsPlugin.kt | 5 +---- .../com/willfp/ecopets/pets/PetDisplay.kt | 17 ++++++----------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsPlugin.kt index 4ac9ba6..e163b3f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsPlugin.kt @@ -40,10 +40,7 @@ class EcoPetsPlugin : LibReforgePlugin() { override fun handleReloadAdditional() { this.scheduler.runTimer(1, 1) { - petDisplay.tickSync() - } - this.scheduler.runAsyncTimer(1, 1) { - petDisplay.tickAsync() + petDisplay.tickAll() } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetDisplay.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetDisplay.kt index cc8fe84..fa9a5ec 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetDisplay.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetDisplay.kt @@ -15,30 +15,25 @@ import org.bukkit.inventory.EquipmentSlot import java.util.* import kotlin.math.PI import kotlin.math.abs +import kotlin.math.sin -internal class PetDisplay( +class PetDisplay( private val plugin: EcoPlugin ) : Listener { private var tick = 0 - private val trackedEntities = Collections.synchronizedMap(mutableMapOf()) + private val trackedEntities = mutableMapOf() - fun tickSync() { + fun tickAll() { for (player in Bukkit.getOnlinePlayers()) { - getOrNew(player) + tickPlayer(player) } tick++ } - fun tickAsync() { - for (player in Bukkit.getOnlinePlayers()) { - tickPlayer(player) - } - } - private fun tickPlayer(player: Player) { - val stand = trackedEntities[player.uniqueId] ?: return + val stand = getOrNew(player) ?: return val pet = player.activePet if (pet != null) {