eventFlow causing listeners to be unregistered
See original GitHub issueHi, I am new to Kotlin and the KotlinBukkitAPI, so it’s entirely possible this issue is being caused by a misunderstanding of Kotlin or this API. I am not new to Java or Spigot plugins, and have been working with them for a few years now.
I have a plugin that registers listeners during the LifecycleEvent.ENABLE
phase, namely:
events {
event<EntityPortalEnterEvent> {
logger.info("Hello from EntityPortalEnterEvent!")
}
event<PlayerPortalEvent> {
// [... some code...]
pluginCoroutineScope.launch {
val changedWorldEvent = withTimeoutOrNull(5000) {
eventFlow<PlayerChangedWorldEvent>(priority = EventPriority.HIGHEST)
.filter { it.player == player }
.onEach { delay(1000) }
.first()
} ?: return@launch
// [... do some stuff with changedWorldEvent...]
// [ !!! ]
}
}
}
Here’s my problem: every time the eventFlow finishes and the code reaches the [ !!! ]
, every listener in my plugin is unregistered, and I don’t know why. If I comment out the eventFlow code, the listeners are NOT unregistered.
I confirmed this by creating a command:
command("spl") {
executor {
EntityPortalEnterEvent.getHandlerList().registeredListeners.forEach { sender.sendMessage("L: $it") }
}
}
Executing this command before going through a portal correctly returns 1 registered listener for the EntityPortalEnterEvent. Then after I go through a portal and trigger the PlayerPortalEvent
and eventFlow, the command returns nothing, meaning the listener was unregistered.
Any help would be appreciated.
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (8 by maintainers)
Top GitHub Comments
Yes, Architecture is not needed anymore in 0.2.0 and in the latest builds from 0.1.0, now is build in inside the Core, and it extensions like Config is leveraged by the other modules, in the case for Config, the Serialization module.
Hi, I will try to reproduce it.