Get CommandEvent for CommandPreProcess

Discussion in 'Plugin Development' started by Kostronor, Jun 20, 2013.

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

    Kostronor

    Hey guys,

    i am working on Command-IConomy and i catch my command events with CommandPreProcess to have them charged every time and to cancel them bevore the plugin associated with them kicks in.
    Everything works nice, but now i want to check if the command was cancelled by the plugin, indicating, that the charge should be refunded.
    Is there any chance to get the resulting commandEvent from the preProcess?
    It is important to have exact this event, simply checking for the command string would be very faulty on repeatet commands...
     
  2. Offline

    Nitnelave

    Well, seeing as Bukkit is one-threaded, I think it's pretty safe to assume that the next commandEvent being fired is the one resulting from this CommandPreProcessEvent. Try this: have a global boolean flag to say "listen to the next event". Then, in the preprocess, you set the flag to true and you display the text of the command. And in the commandEvent, if the flag is set, you display the command. That way, you can compare the results. Of course, you would need to test it on a busy server to make sure, but I think it'd work.
     
Thread Status:
Not open for further replies.

Share This Page