Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to server with synchronous event handling #163

Open
4 tasks done
fvoichick opened this issue Jun 23, 2019 · 0 comments
Open
4 tasks done

Unable to connect to server with synchronous event handling #163

fvoichick opened this issue Jun 23, 2019 · 0 comments

Comments

@fvoichick
Copy link

Follow this template except for feature requests. Use pastebin when providing /protocol dump and any relevant errors.

Make sure you've done the following:

  • You're using the latest build for your server version
  • This isn't an issue caused by another plugin
  • You've checked for duplicate issues
  • You didn't use /reload

Debug paste link:
https://pastebin.com/TPFuRzU9 (console error message)
https://pastebin.com/Ju8N1Xqs (protocol dump)

Description and relevant errors:
I created a plugin with the following (Kotlin) code:

package com.voichick.cyclic

import com.comphenix.protocol.PacketType
import com.comphenix.protocol.ProtocolLibrary
import com.comphenix.protocol.events.PacketAdapter
import com.comphenix.protocol.events.PacketEvent
import org.bukkit.plugin.java.JavaPlugin

@Suppress("unused")
class Cyclic : JavaPlugin() {
    override fun onEnable() {
        val listener = object : PacketAdapter(this, PacketType.Play.Server.POSITION) {
            override fun onPacketSending(event: PacketEvent?) {
                logger.info("Sending packet!")
            }
        }
        val manager = ProtocolLibrary.getProtocolManager()
        manager.asynchronousManager.registerAsyncHandler(listener).syncStart()
    }
}

Now, whenever I try to log into the server, there's an error and I'm unable to.

When I make the following replacement:

//      manager.asynchronousManager.registerAsyncHandler(listener).syncStart()
        manager.addPacketListener(listener)

...it works as expected.
My understanding is that the two lines above should be fairly equivalent, except that the first one is run synchronously and the second is run asynchronously, but I'm not sure if that's correct. Regardless, I don't think that the code above should prevent players from joining the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant