Get UUID without freezing main thread?

Discussion in 'Plugin Development' started by Bammerbom, Apr 3, 2014.

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


    How to get an UUID without freezing the main Bukkit thread?
  2. Jhtzb If you're "feezing the main Bukkit thread" then you're not just getting a UUID, you're doing something else as well because you can get the UUID of an online player really easily. Either way, run it on another thread? What is it exactly that you're trying to do?
  3. Offline


    AdamQpzm Sorry Im not explaining it right. I am getting the UUID of an offline player using an API (Connecting to the Mojang servers), but it takes some seconds to connect.
  4. Offline


    Then use a separate thread.
  5. Offline


  6. Offline


    google + java + separate thread
    Garris0n likes this.
  7. Offline


    Bukkit has a scheduler which allows for threading. Call an asynchronous task.
  8. Offline


    just do something along the lines of:

    public class MojangLookup implements Callable<String> {
     private String name;
     private String uuid;
     public MojangLookup(String name) { = name;
      try {
       this.uuid = call();
      } catch (Exception e) {
       System.out.print("no connection with mojang site");
     public String getUniqueId() {
      return uuid;
     public String getName() {
      return name;
     public String call() throws Exception {
      //do your parse things from the authclient
      String exampleUUID = "blah";
      return exampleUUID;
    I never heard about Callable but this thing actually rocks, a runnable is not good at all because you can't depend on slow IOExceptions so you actually want something smilliar as Runnable but which returns the String instead of a void and else throw faster a exception an Callable can do this while a Runnable cannot unless the thread is frozen to long.

    note ive wrote this code myself but about the Callable ive found here: most of this I got from here since I runned myself into multiple issues using a Runnable so credits to evilmidget38 i've learned something new:)
Thread Status:
Not open for further replies.

Share This Page