Solved Convert UUID back to playername

Discussion in 'Spigot Plugin Development' started by Xurvold, Mar 31, 2020.

  1. How would I convert a UUID back into the name of a player?
    I have their UUID stored in this hashmap.

    Code (Java):

    Map<UUID, UUID> linked = new HashMap<UUID, UUID>();
    #1 Xurvold, Mar 31, 2020
    Last edited: Mar 31, 2020
  2. Bukkit#getPlayer(UUID) and then use Player#getName()
  3. Trying to implement it, gives an error.

    Code (Java):

    sender.sendMessage(ChatColor.RED + argsName + " is linked to " + Bukkit.getPlayer(linked.get(argsName.getUniqueId())).getName());
  4. Choco


    because if the player is offline, this will return null. You would have to call Bukkit#getOfflinePlayer(). Note that if that player has never joined the server, it will make an API call to Mojang.
  5. Ah thank you very much!