DevSrSouza / KotlinBukkitAPI

KotlinBukkitAPI is an API for Bukkit/SpigotAPI using the cool and nifty features Kotlin has to make your life more easier.
MIT License
156 stars 20 forks source link

All server listeners being unregistered. #4

Closed DevNatan closed 5 years ago

DevNatan commented 5 years ago

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: https://github.com/DevSrSouza/KotlinBukkitAPI/blob/f702c0ed23f73d538fc8964ac8af5ee454813852/core/src/main/kotlin/br/com/devsrsouza/kotlinbukkitapi/collections/OnlinePlayerCollections.kt#L185

More specifically in this line: https://github.com/DevSrSouza/KotlinBukkitAPI/blob/f702c0ed23f73d538fc8964ac8af5ee454813852/core/src/main/kotlin/br/com/devsrsouza/kotlinbukkitapi/collections/OnlinePlayerCollections.kt#L199

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.

DevSrSouza commented 5 years ago

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

Tkx.