DevSrSouza/KotlinBukkitAPI

All server listeners being unregistered.

Closed this issue · 1 comments

What happened

I've recently been testing my server systems using KotlinBukkitAPI. And I noticed that every time I logged into the server, the events worked.
But if I tried to do the exact same process I did for this event, it did not work.

I used this to test:

events {
    event<PlayerJoinEvent> {
        player.sendMessage("joined, KotlinBukkitAPI")
    }
}

Bukkit.getServer().pluginManager.registerEvents(object: Listener {
    @EventHandler
    fun on(e: PlayerJoinEvent) {
        e.player.sendMessage("joined, PluginManager")
    }
}, this)

I turned and they both worked, the two messages disappeared. But when I left the server and entered again, nothing happened.
And then I started looking for the problem, and I found it.

The problem

It is located in this class:

interface OnlinePlayerCollection : MutableCollection<Player>, KListener<Plugin> {

More specifically in this line:

The unregisterAll() method is called, correctly, but its reference is not correct.
The unregisterAll() that should be called is that of br.com.devsrsouza.kotlinbukkitapi.extensions, and what is being called is the org.bukkit.event.HandlerList#unregisterAll.

Solution

This is resolved by adding the correct import br.com.devsrsouza.kotlinbukkitapi.extensions.unregisterAll to the file.

Please resolve this as soon as possible because KotlinBukkitAPI, with this, is unusable.

I made a commit with this fix a days ago, but I was not pushing the project, I push now, and is fixed

Tkx.