[OfflinePlayer] Can't get real UUID! (Online Mode)

Discussion in 'Plugin Development' started by OHQCraft, May 13, 2014.

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

    OHQCraft

    I can't get the real UUID of the OfflinePlayer using:

    Code:java
    1. UUID uuid = OfflinePlayer.getUniqueID();


    Isn't it supposed to return the real UUID? Currently it returns random ones. The server is in Online Mode. Is this supposed to work, or do I need an external API (Fishbans)?
     
  2. Offline

    TGRHavoc

    OHQCraft
    Off-line players don't have a real UUID...
     
  3. Offline

    OHQCraft

    I don't think you understand OfflinePlayer. It refers to a Player, that is currently not online, not a Player in Offline Mode. According to this tutorial, it is possible to get the UUID of an OfflinePlayer.
     
  4. Offline

    TGRHavoc

    OHQCraft
    Have they joined the server before? If not then you can't get their UUID.
     
  5. Offline

    OHQCraft

    Yes they have.
     
  6. Offline

    Cro007

    I have same issue. My plugin broke just for this offlinePlayer code,
    example:
    Code:java
    1. scores.put(p, o.getScore(Bukkit.getServer().getOfflinePlayer(ChatColor.GREEN + "Hits Left:")));
     
  7. Offline

    OHQCraft

    Looks like a bug then.
     
  8. Offline

    TGRHavoc

    OHQCraft
    Did you do "Player offlinePlayer = Bukkit.getOfflinePlayer("name");" and try and get the UUID that way. (Yes I know the "bukkit.getOfflinePlayer()" method is deprecated)
     
  9. Offline

    CraigParton

    Code:java
    1. Bukkit.getServer().getOfflinePlayer(ChatColor.GREEN + "Hits Left:");

    That's definitely not going to work, unless the player's name is "Hits Left:". I think what you're looking for is:
    Code:java
    1. Bukkit.getOfflinePlayer("PlayerName")

    As for deprecation, only the Bukkit.getOfflinePlayer(string) method is deprecated. Bukkit.getOfflinePlayer(UUID) isn't deprecated and is the recommended way of getting offline players in 1.7.9.
     
  10. Offline

    Cro007

    That is for scoreboard, I need to have "Hits left" to show it on scoreboard. This UUID completely broke it and I have no idea how to use it. Example of if player has perm, then he can see repair cost:
    Code:java
    1. if(p.hasPermission("ecorep.repair")){
    2. repair.put(p, o.getScore(Bukkit.getServer().getOfflinePlayer(ChatColor.GREEN + "Repair cost:")));
    3. }

    Code worked fine untill I added new development build
     
  11. Offline

    OHQCraft

    Yes.
     
  12. Offline

    JoeyDevs

    Sorry, I use to get a UUID ( From online player ) is the following:
    Code:java
    1. String uuid = p.getUniqueId().toString(); // p = Player but what you have there depends on your Event ( Command,JoinEvent,... )
     
  13. Offline

    OHQCraft

    JoeyDevs Does OfflinePlayer.getUniqueID() work for you? The confusing thing about the bug is, is that they are both the same functions. Both Player and OfflinePlayer get the .getUniqueId() function as they extend AnimalTamer.
     
  14. Offline

    JoeyDevs

    I will check tomorrow here it's time to sleep for me. So i will check tomorrow but i don't know because how can the server get a UUID from a player that don't exist in the server. I think that shouldn't work by UUID!
     
  15. Offline

    Drkmaster83

    What about this?
    Code:
    UUID uu = java.util.UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(Charsets.UTF_8));
    
    This prints off my UUID just fine.
    'Charsets' is com.google.base
     
  16. Offline

    OHQCraft

    I'm talking about getting the UUID from the actual Mojang Servers. OfflinePlayer.getUniqueId() is supposed to work, but doesn't.
     
  17. Offline

    ZodiacTheories

    OHQCraft

    Can't OfflinePlayer be for online players aswell?
     
  18. Offline

    Necrodoom

    Your player name is still not "repair cost:" so I don't see how it would ever work.
     
  19. Offline

    MadusU

    I made this code for getting UUID from playername. That will work even when player is online and offline. But if the play haven't played before it might throw a HUUGE error.
    Code:
    @SuppressWarnings("deprecation")
        public static UUID getID(String name)
        {
            Player player;
            OfflinePlayer oplayer;
            UUID ID;
            if((Bukkit.getPlayer(name)) != null){
                player = Bukkit.getPlayer(name);
                ID = player.getUniqueId();
            }
            else {
                oplayer = Bukkit.getOfflinePlayer(name);
                ID = oplayer.getUniqueId();
            }
            return ID;
        }
     
  20. Offline

    OHQCraft

    Yes, but I only want to get the UUID.

    I used that method but it returns random UUIDs.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  21. Offline

    Azubuso

    OHQCraft Well. Most safe way of doing this would be to use @evilmidget 's UUIDFetcher, which you can find here.
     
  22. Offline

    MadusU

    It World for me. It probably doesn't if your local server runs in offline mode. (I made that failure earlier)
     
  23. Offline

    FerusGrim

    That's, actually, an older version. Newest, and most efficient, version is here
     
  24. Offline

    Azubuso

    FerusGrim Ah yeah, you're right, still had the link to the old version, thanks for telling me. :)
     
  25. Offline

    xize

    if I'm right Bukkit.getOfflinePlayer(name) would work though however you may get troubles with UpperCase and LowerCase casing plus if the player has never played before it will do probably a lookup request to the site of mojang which may or not freezes the server.

    but ive to admit I'm not updated what in the latest commits is changed so I can be mistated also I'm not 100% sure the latest part is true.

    but I know that it could be very hard adding offlineplayers to scoreboards again atleast ive seen increasing messages about that.
     
    OHQCraft likes this.
  26. Offline

    OHQCraft

    Yeah, it's just a bug.
     
Thread Status:
Not open for further replies.

Share This Page