Run functions when the player is completely joined in?

MrCrackle36

New Member
Hey there,

I'm working on a core plugin for my Nukkit / Cloudburst powered server, and I have set up a PlayerJoinEvent which runs things such as initializing a boss bar, teleporting the player to the spawn, etc. The issue with this is, for players who take a while to load in, it won't make those calls. Is there something I should use other than a PlayerJoinEvent? Maybe something that is called after the player is completely joined? All help is appreciated, thanks.
 

Joshua CC

Member
A packet is called when the player is fully initialized, it's "SetLocalPlayerAsInitializedPacket" on DataPacketReceiveEvent, here's a snippet


@EventHandler
public void onDataPk(DataPacketReceiveEvent event) {
if (event.getPacket() instanceof SetLocalPlayerAsInitializedPacket) {
Player player = event.getPlayer();
 

MrCrackle36

New Member
A packet is called when the player is fully initialized, it's "SetLocalPlayerAsInitializedPacket" on DataPacketReceiveEvent, here's a snippet


@EventHandler
public void onDataPk(DataPacketReceiveEvent event) {
if (event.getPacket() instanceof SetLocalPlayerAsInitializedPacket) {
Player player = event.getPlayer();
Thank you so much!
 

CreeperFace

🇨🇿🇺🇦 Слава Україні!
Staff member
Hey there,

I'm working on a core plugin for my Nukkit / Cloudburst powered server, and I have set up a PlayerJoinEvent which runs things such as initializing a boss bar, teleporting the player to the spawn, etc. The issue with this is, for players who take a while to load in, it won't make those calls. Is there something I should use other than a PlayerJoinEvent? Maybe something that is called after the player is completely joined? All help is appreciated, thanks.
Or you can use PlayerLocallyInitializedEvent https://github.com/CloudburstMC/Nukkit/blob/master/src/main/java/cn/nukkit/event/player/PlayerLocallyInitializedEvent.java
 
Top