[SOLVED] How to act after an event ?

Discussion in 'Plugin Development' started by rominos2, Sep 3, 2011.

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

    rominos2

    Hi everyone,

    So all I need to know is in the title ?
    How can I act after an event and not before

    For example
    I use the onPlayerCommandPreprocess and I want to do something after a command

    Is there any method to do that ?
    Or have I to schedule the thing ?
     
  2. Well, first: Why do you use onCommandPreprocess?
    Second: if you use a listener it will react while the event is happening (in that tick, not before (impossible ;)) and not after. If you want you plugin to react after you have to use the sheduler (or show us the codes, maybe there's another solution...)

    //EDIT: I don't know what you want to do but there are priorities in the event system, too (if another plugin conflicts with the event you want to use). Also (if possible) check for isCancelled() before you do anything with the event, because if a plugin was priorized better than yours and still cancelled the event... ;)
     
  3. Offline

    rominos2

    @V10lator
    So I'll schedule
    But thanks for the iscancelled() test I'd not have thought about that

    I just want to print a message after a command

    @V10lator
    Another Question:
    How can I schedule a thing which need arguments

    Like for example player.sendMessage(settings.text);

    How can I schedule that ?
    Can you send a bit of code please ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 19, 2016
  4. You write that (player.sendMessage(settings.text);) int the run() statement of the task and give the player variable to it by initializing the runnable class (or use a shared variable)
     
  5. Offline

    rominos2

    @V10lator
    So I've to create a new class for the Runnable
    What lazy man I am ! ^^
     
  6. Yea, or make an embedded class (and use a shared variable). ;)

    //EDIT: BTW: May I ask why you want the message sended after the command?
     
  7. Offline

    rominos2

    @V10lator
    for my plugin Tuto
    to wait for a command and follow the tuto

    Thanks for all,
    it's done
    You will see that on my plugin post and on BukkitDev when I'd have add more contents
     
Thread Status:
Not open for further replies.

Share This Page