Sending a message AFTER a chat message

Discussion in 'Plugin Development' started by lego6245, Feb 4, 2011.

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

    lego6245

    Hello.
    Quick question.
    If I wanted to respond to a chat message, I know about the hook/event I should use. However, I want to display my response AFTER I display the actual message. So, it goes like this:

    Player chats, "Hello server!"
    Plugin wants to respond with "Hello Player!"


    Currently, the player sees:
    "Hello Player!"
    "Hello server!"

    But I want them to see:
    "Hello server!"
    "Hello Player!"

    The only way that I can think of thus far is to manually send the player's chat to everyone in the server, then manually send the plugin's message.

    Is there a simpler method?
     
  2. Offline

    feverdream

    Yes.

    Take the text, process the response, and then have the player told the response later.

    You need a Timer, a queue of strings, and a beer to drink while you code it. Should be easy enough that your done by the time your half done with the beer. use the Timer.run method to process the queue.

    In fact, this is giving me all sorts of ideas...
     
  3. Offline

    Afforess

    Create a new thread, let it sleep for like 50 ms or so, then fire it off. PumpkinDiver is basically me playing with thread's.
     
  4. Offline

    lego6245

    Don't you dare do what I'm thinking!
    But this is truly a conundrum. So I generate the string I want to send, create a new event thread and sleep it for a short while, then fire it through? Does bukkit manage this for me, or will I need to do the management myself?
     
  5. Offline

    Afforess

    Need to manage it yourself, sadly.
     
  6. Offline

    lego6245

    Well, that sucks. I might as well do what I did with hMod and send the users message to all active players, then send my plugins. It's so bad, but perhaps they'll be some way to generate events and add them to the queue *hint hint bukkit suggestion hint hint*
     
  7. Offline

    feverdream

    When I did MUD work we had usually had a event queue to work with, and a way to add a given event to it t happen at some point in the last based on what we wanted. A day later, a hour later, a few seconds later, etc. Events were canceled if they no longer mattered by the time they needed to fire.

    Hypothetically, if you are coding what I think you are such a mechanic would be needed anyway.
     
Thread Status:
Not open for further replies.

Share This Page