[Closed] Getting UUID of player from sign

Discussion in 'Plugin Development' started by gvlfm78, Apr 15, 2014.

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

    Asgernohns

    gvlfm78 remember to add the @EventHandler above playeronsign
     
  2. Offline

    gvlfm78

    Wait, I don't need to do that, do I? That method gets called from another method
     
  3. gvlfm78 There's a reason we don't support unofficial builds. ;) And no you don't. If it's not the event method, it doesn't need the annotation.
     
  4. Offline

    gvlfm78

    Unofficial builds of what?
     
  5. gvlfm78 Of bukkit. i.e. we don't provide support for things like spigot.
     
  6. Offline

    McMhz

    gvlfm78
    To get his UUID to a string:
    Code:
    String playerUUID = getServer().getOfflinePlayer("Username").getUniqueId().toString();
    
    Note that I haven't tested this with an editor, but the getOfflinePlayer part is because he might not be online, Again, I haven't tested this, so you can try changing it to getPlayer or something else.
     
  7. Offline

    Tolbin


    Something like this might work.
    Code:java
    1. @SuppressWarnings("deprecation")
    2. @EventHandler
    3. public void weee(PlayerInteractEvent e) {
    4. if (e.getClickedBlock() != null && (e.getClickedBlock().getType() == Material.SIGN_POST || e.getClickedBlock().getType() == Material.WALL_SIGN )) {
    5. Player player = (Player) e.getPlayer();
    6. Sign sign = (Sign) e.getClickedBlock().getState();
    7. OfflinePlayer player2 = getServer().getOfflinePlayer(sign.getLine(1));
    8. if (player2.getUniqueId().toString() != null) {
    9. player.sendMessage(player2.getUniqueId().toString());
    10. }
    11. }


    Please note from the apidocs: getOfflinePlayer "This method may involve a blocking web request to get the UUID for the given name." ie probably should'nt be run in the main thread.

    I tested with my own and one other username and that got the correct UUID. Tested with some random characters that isn't likely a username and still got some UUIDs returned. *shrug*
     
  8. Offline

    gvlfm78

    I am closing this thread because my plugin, InactiveLockette, is dependant on Lockette, which won't be able to update to the UUID system because it stores the usernames on signs allowed for name changing people to steal stuff and/or not be able/gain acces to containers around the place.

    So I will update my plugin to 1.7.2 and stop the developing there, without requiring a switch to the UUID system.
     
Thread Status:
Not open for further replies.

Share This Page