question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

eventFlow causing listeners to be unregistered

See original GitHub issue

Hi, 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:closed
  • Created 3 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
DevSrSouzacommented, Sep 17, 2020

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.

1reaction
DevSrSouzacommented, Sep 16, 2020

Hi, I will try to reproduce it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

EventFlow - GitHub
Subscribers: Listeners that act on specific domain events. Useful if an specific action needs to be triggered after a domain event has been...
Read more >
Genesys Events and Models Reference
A collection of common call and other interaction models and flows. • Some specialized information on call and other interaction state. About ...
Read more >
Chapter 3. Events, Components, and Containers - Ext JS in ...
Methods that take actions on these events are listeners and are sometimes called ... two completely separate approaches with regard to event flow...
Read more >
PreloadJS v1.0.0 API Documentation : LoadQueue - CreateJS
When a file is finished downloading, a fileload event is dispatched. In an example above, there is an event listener snippet for fileload....
Read more >
Top 3 Tips For Effective Networking At An Event - EventTitans
All these tips will surely make a world of a difference in an effective networking strategy while connecting with people at virtual events....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found