Delay in eventlistener

Discussion in 'Plugin Development' started by josha28, Jan 4, 2018.

Thread Status:
Not open for further replies.
  1. How can i add delay in my eventhandeler.
    1. PlayerToggleSneakEvent
    2. check if the player start sneaking
    3. do some stuff until 4.
    4. check if the player stops sneaking
    5. wait 1 sec
    6. do same stuff for 2 sec.
    7. do stuff for 1 sec.
    8. stop code.
  2. Offline


    Pretty complex description. I feel like this would involve an enum of states that they player is in. Kinda like a flow diagram. START_SNEAKING, START_SNEAK_COMPLETE, WAITING, EXECUTING_SAME_STUFF, STUFF, NOTHING. Kinda feels like I'm trying to solve an XY problem here to be honest.
  3. u need to know how to do step 5, the wait x seconds
  4. Offline


    Well, this is all a series of tasks... but the tasks shouldn't continue to execute if the user isn't at the required state for the step they're at.
  5. how can i make it work??
    how can i make a task that is always running??
  6. Offline


    BukkitScheduler#runTaskTimer(pluginInstance, delayInTicks, intervalInTicks).
    You'll have it check every interval if the player has a certain state (which will likely require a map to store for how long the player has been doing a certain action to tell when you should change their state).
  7. Offline

    timtower Administrator Administrator Moderator

    Update for what?
  8. you have events and commands but is there a event for update, for a partical effect
  9. Offline


    No, not really. If anything, you'd be the one creating/calling such an event... which is probably too complex for you.
    You're wanting complicated behavior, so this is a complicated problem to solve.
  10. but how can i make a delay??
Thread Status:
Not open for further replies.

Share This Page