UUID to Player method?

Discussion in 'Plugin Development' started by Kaelinator, Jun 24, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    Kaelinator

    So, I'm fairly new to the Bukkit API, and to be honest, the Java class I took last year didn't help me as much as it should have.
    I'm going to refer to a post from StackExchangehttp://stackoverflow.com/q/37871036/5563110 throughout this post.
    The nice user who answered my question told me to use a HashMap, with the UUID of each pair of players for the keys and values. He said to not use Player variables, instead use their UUIDs.
    My question is, how can I use methods on players by specifying their UUID? Is there some sort of UUID.toPlayer(UUID) method I could use?

    Thanks in advance :D

    So, I'm fairly new to the Bukkit API, and to be honest, the Java class I took last year didn't help me as much as it should have.
    I'm going to refer to a post from StackExchange http://stackoverflow.com/q/37871036/5563110 throughout this post.
    The nice user who answered my question told me to use a HashMap, with the UUID of each pair of players for the keys and values. He said to not use Player variables, instead use their UUIDs.
    My question is, how can I use methods on players by specifying their UUID? Is there some sort of UUID.toPlayer(UUID) method I could use?

    Thanks in advance :D

    Sent from my SAMSUNG-SM-G935A using Tapatalk
     
    Last edited by a moderator: Jun 24, 2016
  2. Offline

    MisterErwin

    @Kaelinator Bukkit#getPlayer(UUID) is the method you are searching for :)
     
  3. Offline

    Airbornz

    Well there is a method to get a player via UUID, but only works if the player is online, else if will just return null. You would use Bukkit.getPlayer(UUID), there is a method Bukkit.getOfflinePlayer(UUID), but it returns an OfflinePlayer, which to be honest I have no idea what it is, since I've personally never used it.
     
  4. Offline

    MCMastery

    @MisterErwin is correct if you know the player is online. If you want access to an offline player, use Bukkit.getOfflinePlayer
     
  5. Offline

    teej107

    No one here mentioned the JavaDocs. Such a shame.
     
    MisterErwin likes this.
  6. Offline

    timtower Administrator Administrator Moderator

    Merged threads.
    Don't double post them.
     
Thread Status:
Not open for further replies.

Share This Page