From 2d90f294c82e04a76d318186f5dcbc19d1f9376e Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Fri, 24 Mar 2023 22:31:41 -0700 Subject: [PATCH] Fix bugs in the usage of koin. --- .../foundation/core/features/gameplay/GameplayFeature.kt | 6 ++---- .../core/features/persist/PersistenceFeature.kt | 8 ++++---- .../pizza/foundation/core/features/stats/StatsFeature.kt | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/foundation-core/src/main/kotlin/gay/pizza/foundation/core/features/gameplay/GameplayFeature.kt b/foundation-core/src/main/kotlin/gay/pizza/foundation/core/features/gameplay/GameplayFeature.kt index f47bb9e..20fced9 100644 --- a/foundation-core/src/main/kotlin/gay/pizza/foundation/core/features/gameplay/GameplayFeature.kt +++ b/foundation-core/src/main/kotlin/gay/pizza/foundation/core/features/gameplay/GameplayFeature.kt @@ -52,12 +52,10 @@ class GameplayFeature : Feature() { private fun onPlayerInteractEntity(event: PlayerInteractEntityEvent) { val mainHandItem = event.player.inventory.itemInMainHand val hasLead = mainHandItem.type == Material.LEAD - val isLivingEntity = event.rightClicked is LivingEntity + val livingEntity = event.rightClicked as? LivingEntity // If leads are allowed on all mobs, then start leading the mob. - if (config.mobs.allowLeads && hasLead && isLivingEntity) { - val livingEntity = event.rightClicked as LivingEntity - + if (config.mobs.allowLeads && hasLead && livingEntity != null) { // Something to do with Bukkit, leashes must happen after the event. Bukkit.getScheduler().runTask(plugin) { -> // If the entity is already leashed, don't do anything. diff --git a/foundation-core/src/main/kotlin/gay/pizza/foundation/core/features/persist/PersistenceFeature.kt b/foundation-core/src/main/kotlin/gay/pizza/foundation/core/features/persist/PersistenceFeature.kt index 99eaccc..ffdc332 100644 --- a/foundation-core/src/main/kotlin/gay/pizza/foundation/core/features/persist/PersistenceFeature.kt +++ b/foundation-core/src/main/kotlin/gay/pizza/foundation/core/features/persist/PersistenceFeature.kt @@ -8,14 +8,14 @@ import org.koin.core.module.Module import org.koin.dsl.module class PersistenceFeature : Feature() { - private val persistence = inject() - private val core = inject() + private val persistence by inject() + private val core by inject() override fun disable() { - persistence.value.unload() + persistence.unload() } override fun module(): Module = module { - single { core.value.persistence } + single { core.persistence } } } diff --git a/foundation-core/src/main/kotlin/gay/pizza/foundation/core/features/stats/StatsFeature.kt b/foundation-core/src/main/kotlin/gay/pizza/foundation/core/features/stats/StatsFeature.kt index 9ca80a8..0646eff 100644 --- a/foundation-core/src/main/kotlin/gay/pizza/foundation/core/features/stats/StatsFeature.kt +++ b/foundation-core/src/main/kotlin/gay/pizza/foundation/core/features/stats/StatsFeature.kt @@ -13,11 +13,11 @@ import java.time.Instant @Suppress("IdentifierGrammar") class StatsFeature : Feature() { - internal val persistence = inject() + internal val persistence by inject() private lateinit var chatLogStore: PersistentStore override fun enable() { - chatLogStore = persistence.value.store("chat-logs") + chatLogStore = persistence.store("chat-logs") plugin.registerCommandExecutor(listOf("leaderboard", "lb"), LeaderboardCommand()) plugin.registerCommandExecutor("pstore", PersistentStoreCommand(this))