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

NullPointerException When Cancelling PlayerBedEnterEvent #2129

Closed
ItsAZZA opened this issue Jan 23, 2020 · 4 comments
Closed

NullPointerException When Cancelling PlayerBedEnterEvent #2129

ItsAZZA opened this issue Jan 23, 2020 · 4 comments

Comments

@ItsAZZA
Copy link

ItsAZZA commented Jan 23, 2020

The output of /version on my server is:
This server is running Paper version git-Paper-70 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)

The output of /version denizen on my server is:
Denizen version 1.1.2-SNAPSHOT (build 1701-REL)

The issue is:
When cancelling PlayerBedEnterEvent you get the following error: https://one.denizenscript.com/haste/64468

This was tested on a server with two plugins: Denizen and my plugin NoSleep. NoSleep does nothing but cancels the event (shown below).

public class SleepEventListener implements Listener {
    @EventHandler
    public void onSleep(PlayerBedEnterEvent event){
        event.setUseBed(Event.Result.DENY);
    }
}

To reproduce, install the NoSleep plugin provided at https://bcsn.us/downloads/NoSleep.jar (or create a plugin that cancels the event) and install Denizen. Attempt to sleep in a bed.

@Ph4i1ur3
Copy link
Contributor

Have you considered actually cancelling the event?
Your error seems to be related to bungee, as well.

@ItsAZZA
Copy link
Author

ItsAZZA commented Jan 23, 2020

Have you considered actually cancelling the event?
Your error seems to be related to bungee, as well.

Cancelling the event gives the same error. Using event.setUseBed(Event.Result.DENY); is same as cancelling the event (https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerBedEnterEvent.html#setUseBed-org.bukkit.event.Event.Result-)

Also, error isn't related to Bungee, really (on my part). Denizen uses BungeeCord API's ChatComponent to create chat messages (https://github.com/SpigotMC/BungeeCord/blob/master/chat/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java).

@mcmonkey4eva
Copy link
Member

That error message implies that a chat packet was sent with a null message.
This appears to actually a mistake of Spigot, which interprets DENY as EnumBedResult.OTHER_PROBLEM which does not initialize any message (and thus the message is null).
It's likely this would produce an error even without Denizen, albeit potentially an error on the client or one that doesn't show in any console and just breaks some lower logic.

@mcmonkey4eva
Copy link
Member

I've added a catch that will prevent the Denizen-specific error from showing. This does not, however, correct the underlying issue in Spigot, which will need to be separately addressed by them.

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

3 participants