1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Best way to send message to player from AsyncTask?

Discussion in 'Facepalm' started by HittmanA, Jul 11, 2017.

  1. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    I have an AsyncTask and I want to send messages to the player that ran the command that started the AsyncTask. I have tried everything I can think of and for some reason I can't send a message to the player that ran the command to start the AsyncTask. How could I send a message to the player that started the AsyncTask (through a command)?
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    You CANNOT send message to player, unless you have a way that dosent involve storing Player/CommandSender instance
    You should probably read a thing or two about threading, as when you pass something into thread AFAIK it clones it then using the same object

    If you really want to, it would be possible using notify main thread i think? but that would need more knowledge of async to be accomplished
     
  3. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    Thanks I will have to figure out another way.
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    a cheap way will be to just store it in a log array which get printed out once the thread joins
     
  5. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    That would actually probably be best since I only need to say it succeded or failed. Thanks!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.