Solved BukkitRunnable

Discussion in 'Spigot Plugin Development' started by FlameHero, Jun 15, 2016.

  1. So,it's been a long time since i played with bukkitrunnables,and my old plugin (the one i need now) fell apart because of the spigot/bukkit updates.
    let's get to the point.
    my old plugin used to schedule commands using commands examples:
    /ptcmd 5s fly flamehero
    ^ the following will execute that command after 5 seconds.
    apperantly the code fell appart and i would like to know how to do it again.
    in general,can someone tell me how to make a bukkitrunnable run from console using a command.
    steps as i know:
    create the command
    create the eventhandler for the bukkitrunnable
    run the command using Bukkit.getServer().dispatchCommand()
    please no bullshit in replies like 'oh dude you need to apply a bukkitrunnable into a string bla bla bla'
    if you have the answer,send me code examples and bla bla is not appreciated.
     
  2. Choco

    Moderator

    This just made me want to help you less :p

    To initialize a BukkitRunnable, you have to call a new instance of it.
    Code (Java):
    new BukkitRunnable(){
        public void run(){
            // This is your runnable stuffs :P
        }
    }.runTaskLater(plugin_instance, delay (in ticks));
     
    • Informative Informative x 2
    • Winner Winner x 1
  3. You must be really stupid to think that the spigot would spoonfeed you.

    This is simple, no need for event handlers. In the on command, make a bukkit runnable that use runtasklater. Set the delay to 100, and inside the runnable, put the dispatchCommand line.
     
    #3 avighnash, Jun 15, 2016
    Last edited: Jun 15, 2016
  4. Its plugin first then delay next :p


    y u alweys snipin
     
  5. Choco

    Moderator

    Oh is it? Lol I haven't used a BukkitRunnable in a while. (I'll edit my post ;P)
     
  6. Bro,this is exactly what i didn't ask for ,what i want isn't an bukkitrunnable to run all day all night each <delay>.
    what i want is how to set up a command to generate runnables....
     
  7. Choco

    Moderator

    Yes... I know. When your command is executed, you want to make a new runnable. Notice how the method after the BukkitRunnable specified "runTaskLater()". The delay parameter runs the task after a specified delay in ticks, then it cancels. It will only run once. That is what you asked for. You're thinking of the .runTaskTimer() method
     
  8. Please,if you don't know how to set up commands to generate runnables aka what i'm asking for don't just jump in with conclusions,i haven't built any bukkitrunnable plugins for a huge long time...
     
    • Funny Funny x 2
    • Optimistic Optimistic x 1
  9. Choco

    Moderator

    Alright... fine... ._. Feel free to look for the answer you're looking for from someone else I guess? You're just wasting your own time. Lol. That's the exact answer you're looking for
     
  10. No! you're actually the one that's near my point,i just don't get what the other guy is on about..thanks for your help attempts!
     
  11. bump.
    still searching for some answers.
     
  12. I know the type of people that run around talking bullshit,look,i'm here for answers and code examples,something the old bukkit community used to offer,lookup ALL spigot threads similar to this,nobody understands anything unless there's an example code offered.
    please,don't jump to conclusions,'spoonfeeding',no.
     
  13. This is what i'm asking for.
    I even underlined the demand. :(
     
  14. Demand? Shouldn't it be question? Because you are asking for some help/guidance.
     
    • Agree Agree x 1
  15. I think you mean unless they're spoonfed.
    Also that isn't true at all lmao here's what you can do.

    1. Create a bukkit runnable (Google Bukkit Runnable Delayed Task Example)
    2. Make a string that = args[0]
    3. Remove the s from args[0]
    4. The result should be an int
    5. For the time in the bukkit runnable put the int specified times 20.
    6. Use bukkit.dispatchCommand to dispatch the command. It will be sent after the specified time. It won't run 24/7 or whatever nonsense you were on about.
    7. Next time you ask for help don't ask to be spoonfed and don't be rude to the people who try to help you.
    8. Don't bump within 24 hours
     
    • Like Like x 1
    • Useful Useful x 1
  16. Demand = Error or something like that,the stuff i need people to think about before answering me.
    again,what i'm asking for:
    somebody to tell me how to make a bukkit runnable using a command,not asking for much.
     
  17. THANK YOU ....
     
  18. Thanks all,sorry if i was a bit rude i was in a hurry and i'm a bit mad bukkit updates without sharing update resources,i'm literraly sitting while watching all my plugins fall apart because i don't understand these new features bukkit remove/added and reworked.
     
  19. BukkitRunnables haven't changed at all :p
     
    • Agree Agree x 2