Fix bugs in the usage of koin.

This commit is contained in:
2023-03-24 22:31:41 -07:00
parent c036aaf61a
commit 2d90f294c8
3 changed files with 8 additions and 10 deletions

View File

@ -52,12 +52,10 @@ class GameplayFeature : Feature() {
private fun onPlayerInteractEntity(event: PlayerInteractEntityEvent) { private fun onPlayerInteractEntity(event: PlayerInteractEntityEvent) {
val mainHandItem = event.player.inventory.itemInMainHand val mainHandItem = event.player.inventory.itemInMainHand
val hasLead = mainHandItem.type == Material.LEAD 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 leads are allowed on all mobs, then start leading the mob.
if (config.mobs.allowLeads && hasLead && isLivingEntity) { if (config.mobs.allowLeads && hasLead && livingEntity != null) {
val livingEntity = event.rightClicked as LivingEntity
// Something to do with Bukkit, leashes must happen after the event. // Something to do with Bukkit, leashes must happen after the event.
Bukkit.getScheduler().runTask(plugin) { -> Bukkit.getScheduler().runTask(plugin) { ->
// If the entity is already leashed, don't do anything. // If the entity is already leashed, don't do anything.

View File

@ -8,14 +8,14 @@ import org.koin.core.module.Module
import org.koin.dsl.module import org.koin.dsl.module
class PersistenceFeature : Feature() { class PersistenceFeature : Feature() {
private val persistence = inject<PluginPersistence>() private val persistence by inject<PluginPersistence>()
private val core = inject<FoundationCorePlugin>() private val core by inject<FoundationCorePlugin>()
override fun disable() { override fun disable() {
persistence.value.unload() persistence.unload()
} }
override fun module(): Module = module { override fun module(): Module = module {
single { core.value.persistence } single { core.persistence }
} }
} }

View File

@ -13,11 +13,11 @@ import java.time.Instant
@Suppress("IdentifierGrammar") @Suppress("IdentifierGrammar")
class StatsFeature : Feature() { class StatsFeature : Feature() {
internal val persistence = inject<PluginPersistence>() internal val persistence by inject<PluginPersistence>()
private lateinit var chatLogStore: PersistentStore private lateinit var chatLogStore: PersistentStore
override fun enable() { override fun enable() {
chatLogStore = persistence.value.store("chat-logs") chatLogStore = persistence.store("chat-logs")
plugin.registerCommandExecutor(listOf("leaderboard", "lb"), LeaderboardCommand()) plugin.registerCommandExecutor(listOf("leaderboard", "lb"), LeaderboardCommand())
plugin.registerCommandExecutor("pstore", PersistentStoreCommand(this)) plugin.registerCommandExecutor("pstore", PersistentStoreCommand(this))