Get player UUID given player name

Discussion in 'Plugin Development' started by 16davidjm6, Jun 3, 2014.

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


    So I have a hash map of player UUID's and Slime entities. If a player's UUID is mapped to a slime, I want an admin to be able do a remove command on the player and kill the slime.

    The command would look something like this: /remove <name>.

    Normally to get the player given in the command's UUID, get the associated slime, and kill it, we could do:
    1. Player p = Bukkit.getPlayerExact(name);
    2. UUID playerID = p.getUniqueId();
    3. Slime slime = map.get(playerID);
    4. slime.setHealth(0.0D);

    However, the function Bukkit.getPlayer(name) and Bukkit.getPlayerExact(name) are deprecated.

    Is there any other way to get a user's UUID given the user's name?
  2. Offline


  3. Offline


    Yes, if the player is offline. If the player is online, you should use the getPlayerExact() and getPlayer() methods.

    @OP If you're worried about the deprecation, you obviously haven't read the announcement.
Thread Status:
Not open for further replies.

Share This Page