Player UUID UUIDFetcher taking adding lag.

Discussion in 'Plugin Development' started by Neilnet, Jun 23, 2014.

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

    Neilnet

    So,

    when I use the UUIDFetcher.call to get some data, it takes like 2 seconds n' within those 2 seconds, any commands executed will be delayed until those 2 seconds are over.
     
  2. Offline

    RawCode

    have you read documentation of fetcher?
    if not - you have exellent chance to read it now.
     
    Neilnet likes this.
  3. Offline

    Neilnet

    Documentation? I don't see any documentation on https://forums.bukkit.org/threads/player-name-uuid-fetcher.250926/.

    Also, could you tell me the way of fixing this instead of telling me to read the entire documentation? I will read up on the documentation, but my plugin badly needs this fix and I'm going to go soon.

    Thanks
    Neil
     
  4. Neilnet You say that you don't see any documentation, yet you use the phrase "entire documentation". If you haven't seen any documentation, then you cannot possibly know its length meaning "entire" is slightly misleading.

    As for your problem, it mentions what you're doing wrong on the post you linked. Read it. And sure we could tell you exactly what's wrong, but that's not the point. Using a library without reading the resources about it is just irresponsible :)
     
    Neilnet and Comphenix like this.
  5. Offline

    RawCode

    Neilnet

    not a spoonfeeding section, you must read documentation self and then if you failed to fix issue - provide code, explain steps you take to fix it and what is wrong.
     
    L33m4n123 and Neilnet like this.
  6. Offline

    Neilnet


    Where is the documentation? The github is just code. I can't see any documentation link on the bukkit page :/
     
  7. Offline

    Gater12

    Neilnet
    Read the post word for word. The solution will come up.
     
    AdamQpzm and Neilnet like this.
  8. Offline

    Neilnet


    Thanks!!! :)
     
  9. Offline

    DevRosemberg

    Neilnet Run it on a different thread.
     
    Neilnet likes this.
  10. Offline

    RawCode

  11. Offline

    Neilnet

    Someone help, this is my UUIDThreadFetcher, it uses a thread to fetch UUIDS.

    Code:java
    1.  
    2.  
    3. import java.util.Arrays;
    4. import java.util.Map;
    5. import java.util.UUID;
    6.  
    7.  
    8. public class UUIDThreadFetcher extends Thread{
    9.  
    10. private String username;
    11. private String UUIDString;
    12.  
    13. public UUIDThreadFetcher(String username) {
    14. this.username = username;
    15. this.start();
    16. }
    17.  
    18. public void run() {
    19. Map<String, UUID> playerMap = null;
    20. try {
    21. playerMap = new UUIDFetcher(Arrays.asList(username)).call();
    22. } catch (Exception e) {
    23. e.printStackTrace();
    24. }
    25.  
    26. UUIDString = playerMap.toString().replace("{", "").replace("}","").replace(username+"=", "");
    27. }
    28.  
    29. public String getUUID(){
    30. return UUIDString;
    31. }
    32.  
    33.  
    34. }
    35.  


    new UUIDThreadFetcher(username).getUUID() returns a null. How do I make a thread return an exact value?


    90% of Bukkit things related to events, nulls and everything involves people spoon fed answers.

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

    CakePvP

    If you're running in online mode and the player has been on the server before, you could get the UUID from an OfflinePlayer.
     
  13. Neilnet Even if it happens, it doesn't mean people should spoon-feed. Debug your code to see the results of methods and such.
     
  14. Offline

    PreFiXAUT

    Neilnet
    You should might do it with HashMaps which are loading onEnable and onJoin. So you only listen for one Player once when he joins.

    And the thing with the Thread > Isn't it better to use a BukkitRunnable so you are sync?
     
  15. PreFiXAUT You completely missed the point, didn't you? You don't want to do it on the main thread, that was the problem.
     
  16. Offline

    PreFiXAUT

    I know? I never said he should do it in the Main-Thread or did I say it somewhere?
    I just said he can also save the UUID's with the Playernames so he doesn't need to lookup the name EVERYTIME.
     
  17. PreFiXAUT
     
  18. Offline

    PreFiXAUT

    AdamQpzm
     
  19. Offline

    xize

    the Callabe is a thread on its self which returns something back in return else it throws a exception it generally throws it a bit faster to.

    PreFiXAUT
    the link from EvilMidgets class is the best you can get imo, from what ive googled there is nothing more faster than using a Callable, in fact using a Runnable only slowdowns it more.

    however the problem what may is the cause for lag is multicraft or lets say shared hosting, some hosters just don't allow multithreading and then a Callable just act as a other thread but is still running on the main thread causing to slow your server down ive solved it myself to move to a dedicated server, however it also made me super afraid all threads of the server can be used by plugins such like PermissionsEx and what not, it made me sort of against looking up accounts just because storing is better.

    if you check craftbukkit in VisualVM you already see craftbukkit has some threads to which makes it super hard to have 2 - 3 extra more threads to fetch uuids honestly I doubt mojang thought out about these issues very well.
     
  20. Offline

    mythbusterma

    xize Or you could have one thread that is responsible for the look-ups, as long as you're not doing them too frequently and use the ...runOnThread() (or something like that, I know one exists) method to do it every time, saving yourself the extra threads, although the calls would have to stack up.
     
  21. Offline

    DevRosemberg

    RawCode Telling how to solve != Spoon Feeding
     
    mazentheamazin, xize and 97WaterPolo like this.
  22. Offline

    RawCode

    DevRosemberg
    read thread carefully, everyone asked TS to read documentation and you just spoonfeeded solution.
    your action caused TS to ignore documentation further, now he wont read it.
     
  23. Offline

    DevRosemberg

    RawCode How do you know he didnt read it :eek:
     
  24. DevRosemberg Because it told him how to solve the problem - if he'd read & followed it, he wouldn't have posted here :)
     
Thread Status:
Not open for further replies.

Share This Page