Wait till an event finishes before running code?

Discussion in 'Plugin Development' started by Hatsonboats58, Sep 20, 2020.

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

    Hatsonboats58

    I was wondering if there was a way to make it so that a code only executes after an event finishes. I need this for multiple things but one example: I am making an enchant for your armor and I use inventory click event to detect when a player puts armor on BUT since the code runs first it is one click behind meaning I cannot detect what a player is whering. Even if there is another way to do this I still need to know how to do this. Thank you!
     
  2. Offline

    Kars

    Delayed bukkit runnable, 1 tick in the future, scheduled in the event handler.
     
  3. Offline

    KarimAKL

    @Hatsonboats58 There's no need to use a Runnable for that. The event has methods for getting the items, click type, slot, inventory, etc.
     
  4. Offline

    Hatsonboats58

    Yes, but its one click behind since the code runs before you click. Its weird
     
  5. Offline

    KarimAKL

    @Hatsonboats58 What do you mean? What do you want to achieve? There shouldn't be a problem with the event.
     
  6. Offline

    Kars

    Event handler code runs before an event takes place, that's how it works. If you want to check something after the event completes you need to schedule a task.
     
Thread Status:
Not open for further replies.

Share This Page