Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to make plugin wait?

Comments in 'Plugin Development' started by SpiderPig, Jan 25, 2015.

  1. SpiderPig
    Offline

    SpiderPig Active Member

    Joined:
    Sep 21, 2013
    Posts:
    128
    Minecraft User:
    SpiderPig
    Hi,

    I need to pause a plugin but I'm not sure how?

    I know you can't use Sleep();
    So how would I do it?
  2. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    No, if you use "Sleep" the whole server will sleep, instead, use some "Schedules Tasks"
    Last edited by a moderator: Jan 26, 2015
    PEMapModder and EvolSoft like this.
  3. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Make the counter in a Task. Don't use sleep because it will pause all the server.
  4. SpiderPig
    Offline

    SpiderPig Active Member

    Joined:
    Sep 21, 2013
    Posts:
    128
    Minecraft User:
    SpiderPig
    Example?
  5. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,201
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    a simple way to do it is to make a scheduledelayedtask and an if and else statement.
  6. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,201
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    if the the number of tick is equal to the target, then your script would run. i cant explain more further. i suggest you look at my ASR script that would probably help you as it uses the same logic.
  7. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Plugins are ran from the main server thread (I think). Use a Task to "sleep".
  8. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    Also, remember:

    1 second = 20 ticks
    20 ticks = 1 second

    ;)
  9. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,201
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    I know :p
  10. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    981
    Plugins:
    9
    Skills! XD
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Glad that you're aware of race condition. Don't let that happen in BlockServer >_<
  12. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Deciding weather to load and enable plugins in a separate thread.
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No. Even though Java doesn't have the pthreads PHP bugs, we still want to get rid of race conditions. Different plugins enabling at the same time? Or players start joining before plugins are enabled? No, not!
  14. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    I mean that ALL the plugins are loaded/enabled in a separate thread. But you are probably right. We should load the plugins before the server starts, correct?

Share This Page

Advertisement