Solved Getting player UUID inside AsyncPlayerPreLoginEvent

Discussion in 'Plugin Development' started by ferrybig, Apr 19, 2014.

Thread Status:
Not open for further replies.
  1. Is there a way to get the UUID of a player inside the asyncplayerpreloginevent? I am storing entries inside a mysql database based on the player uuid, and it need to be loaded before the PlayerJoinEvent is called because it sets permissions on the player and may take a long time to ccomplete (database is hosted remote). There is a getName() inside this event, but because you can't relay on names, this isn't a solution for my.
     
  2. Offline

    TheMcScavenger

    I don't think you can, as it doesn't even give you access to the player yet. Just use PlayerLoginEvent.

    Code:
    @EventHandler
    public void onPlayerLogin(PlayerLoginEvent event){
        Player player = event.getPlayer();
        UUID playerUUID = player.getUniqueId();
    }
    or in short:

    Code:
    @EventHandler
    public void onPlayerLogin(PlayerLoginEvent event){
        UUID playerUUID = event.getPlayer().getUniqueId();
    }
     
  3. Offline

    Heirteir

    TheMcScavenger
    You can TheMcScavenger PlayerLoginEvent is deprecated here is the working method
    Code:java
    1.  
    2. @EventHandler
    3. public void onLogin(AsyncPlayerPreLoginEvent e){
    4. e.getUniqueId();
    5. }


    This will get the UUID of the player trying to connect.
    (Please let me know if this doesn't work as I will research further but I am pretty sure you won't have that problem)

    Hope I helped!

    --Heirteir
     
  4. Offline

    TheMcScavenger

  5. Offline

    Heirteir

  6. bennie3211 likes this.
Thread Status:
Not open for further replies.

Share This Page