LuckPerms

LuckPerms

41.4k Downloads

UserLoadEvent not being called on Player Join / Plugin Reload

StunterLetsPlay opened this issue ยท 1 comments

commented

Description
Whilst using UserLoadEvent does not trigger on Player Join or when the Plugin gets Reloaded.

Main Class:

public void onEnable(){
        new LuckPermsListener(this, LuckPermsProvider.get());
}

Listener Class:

public class LuckPermsListener {
    private final Main main;

    public LuckPermsListener(Main main, LuckPerms api){
        this.main = main;

        Bukkit.broadcastMessage("1");
        EventBus bus = api.getEventBus();
        bus.subscribe(UserLoadEvent.class, this::onPlayerDatabaseLoad);
        Bukkit.broadcastMessage("2");
    }

    public void onPlayerDatabaseLoad(UserLoadEvent e) {
        Bukkit.getScheduler().runTask(main, () -> {
            Bukkit.broadcastMessage("UUID: " + e.getUser().getUniqueId());
            for (Player all : Bukkit.getOnlinePlayers()){
                Bukkit.broadcastMessage("Player: " + all.getName() + " >> " + all.getUniqueId());
            }
        });
    }

Reproduction steps

  • Copy-Paste exact Code
  • Join the Server and see that nothing gets put in chat
  • Type /lp networksync and see it output something in chat

Environment details
Using MySQL

Server type/version: 1.16.4 Paper
LuckPerms version: v5.2.67

commented

I cannot reproduce, it's working fine for me.

I've added a simple demo to the cookbook plugin to confirm too: LuckPerms/api-cookbook@b1804a9

[18:52:16 INFO]: Done (4.211s)! For help, type "help"
[18:52:16 INFO]: Timings Reset
[18:52:33 INFO]: [LuckPermsCookbook] UserLoadEvent fired! - c1d60c50-70b5-4722-8057-87767557e50d
[18:52:33 INFO]: UUID of player Luck is c1d60c50-70b5-4722-8057-87767557e50d
[18:52:33 INFO]: Luck joined the game
[18:52:33 INFO]: Luck[/127.0.0.1:49636] logged in with entity id 333 at ([world]-147.2480725863457, 69.0, 98.71311692463259)

It is worth noting that the UserLoadEvent (like all events in LuckPerms) is called async. This means that it might be called and fully processed before the player actually "joins" the game.

In fact, you can see in the example above that the logging message from LuckPermsCookbook is printed before "Luck joined the game".

I'm not sure what your end goal is (you haven't given much context), but you're going to need to account for this if you want to continue using the UserLoadEvent for this purpose.