-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Implement waiting login sequence #6015
Implement waiting login sequence #6015
Conversation
I'd be happier if there was a way to do this without adding new events. I don't really see an obvious reason why a new event is needed here. |
This can be done via callbacks, in the same way as inventory listener or craftmanager. |
Well, I don't see why e.g. |
The idea was that this would allow things to be executed before the event login. But the more I think about it, the more I realize that it could be done in the PlayerCreationEvent or during the login event. |
I moove the logic to The event's documentation needs to be reviewed, because it is no longer dedicated to changing the player's class, but also contains access to the |
I'm getting the impression that this "wait group" is essentially just a The documentation is perhaps too much. People are going to get scared off by seeing that much text. |
I've completely rewritten the system by simply adding From now on, plugins will be able to add promises that must be completed before the player is created. |
Now requires a new translation: the message that will be displayed when the player disconnects because the promise has been rejected. |
Whether or not the client functions correctly shouldn't be relevant. Also, doing this before PlayerPreLogin could be problematic for loading playerdata from remote databases, which is the primary use case for a feature like this. |
Would you suggest putting it between the prelogin and the login? |
I'm undecided, but I don't think prelogin is the right call. |
Ideally this should be ran after PlayerLoginEvent as to not waste resources on gathering data for players that will never connect or to not overload the database whenever people are spamming fake accounts. |
I would also agree |
I'm leaning towards doing it directly after PlayerCreationEvent, to permit the player to be properly constructed with the appropriate data. It would be nice if Player::__construct() could receive all of its data and then be able to proceed directly to the spawn sequence IMO. |
code came from #6015 and will be subject to probable changes
I don't think that passing values to the constructor is relevant for this PR, but I wouldn't agree with that too much. |
I'm thinking of stuff like the |
I think it would be better to rename the event into Afterwards, I also agree with @dries-c's opinion in the sense that applying it after login would avoid doing things on a potentially invalid player, a bot. Potentially to be done in another PR to allow some flexibility to plugins and thus have the choice? There may be cases where I see the need for these two events. |
This was a suggestion, not a request. Your point about removing custom player classes changed my mind.
I don't see a need for two events. Invalid players won't get any further than PlayerPreLoginEvent anyway. |
I know, but I thought the comment was pertinent and would perhaps allow more flexibility in the future to have this event fired before the player is built and not after. |
We now use the |
What about merging this ? Is there need some modification or is it clear for the moment ? |
I think we need a general way of making events asynchronous before we change the logic of these events. Closing |
Introduction
This PR introduces a new system for deferred the player creation, allowing plugins to add tasks to be done at that time. This ensures that plugins load player data correctly before the player is created and the login sequence launched.
Plugins can also cancel the player's connection by rejecting their promise.
Changes
API changes
Promise::all()
Behavioural changes
Tests
With promise resolve:
With promise rejection: