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

player.sendMessage() throws exception after calling player.disconnect() #847

Open
Packsolite opened this issue Mar 25, 2024 · 1 comment

Comments

@Packsolite
Copy link

Packsolite commented Mar 25, 2024

Problem

The following exception was thrown when calling the ProxiedPlayer#sendMessage() method:
https://pastebin.com/m7FeSwAM

Reason

It seems like after disconnecting a player using the ProxiedPlayer#disconnect() method, an invalid or broken reference to the player can still be obtained via the api using ProxyServer#getPlayers(). Using the sendMessage() function on such a reference results in an error.

How to reproduce

So as a basic example you want a custom kick command implemented as a plugin:
After disconnecting the player, you may want to send a message to other staff members.

The code could look something like this:

player.disconnect(text);
for (ProxiedPlayer staff: server.getPlayers()) {
    staff.sendMessage(player.getName() + " was kicked by " + sender.getName());
}

In this specific example sure i can move the disconnect after the staff broadcast, however in other situations that might not be as easy and the api should be safe in that regard.

@Packsolite Packsolite changed the title player.disconnect() does not immediatly remove the player from online list player.sendMessage() throws exception after calling player.disconnect() Mar 25, 2024
@RealSuperUser
Copy link

I weren't able to reproduce this issue on my setup. if it still persists (even with bungeecord) pls give me instructions so I can investigate further (if needed)

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

2 participants