Scheduler problem [solved]

Discussion in 'Plugin Development' started by Assult, Sep 12, 2012.

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

    Assult

    Whats wrong with this scheduler?
    Code:
      public void timer() {
    Bukkit.getServer.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    @Override
    public void run() {
    Bukkit.broadcastmessage("test");
    }
    }, 0L, 100L);
    }
    
    it never broadcasts test

    Bump
    Sorry for bumping so fast but i really need to fix this

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  2. Offline

    IDragonfire

    You try to broadcast a message after 5 seconds every 0 seconds ....

    Try:

    Code:
      public void timer() {
    Bukkit.getServer.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    @Override
    public void run() {
    Bukkit.broadcastmessage("test");
    }
    }, 20L, 60L);
    }
    Ps.:
    http://wiki.bukkit.org/Scheduler_Programming

    Edit: First param is delay, second repeating time, sry ...
     
  3. Offline

    Firefly

    Do you ever call your timer() method? If so, could you show the code where you do?
     
    blackwolf12333 likes this.
  4. Offline

    Assult

    Oh, thats kinda Emberassing...

    But anyways ill try
     
  5. Offline

    Firefly

    IDragonfire I was under the impression that the first long was the delay and the second was the repetition long.

    Maybe I'm wrong.
     
  6. Are you sure timer() gets called anywhere in your code (in onEnable()) ?

    Bukkit.broadcastmessage("test");
    has to be
    Bukkit.broadcastMessage("test");
    I hope this is a copy&paste error cause this should give a compile-time error (which (most?) IDEs show even before you compile).

    //EDIT: Firefly is right (with the delay/repetition ordering).
     
  7. Offline

    Assult

    Im on an ipad its hard for me to type all the code

    Im typing on an ipad, it says broadcastMessage on my computer

    Anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  8. Offline

    IDragonfire

    Can you post more code?
     
  9. Offline

    Assult

    How do you call the method timer (i feel like a major noob at the moment (im new to schedulers))

    It would take me Forever to type my full class on an ipad (its really big....)

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  10. The method is a method your created, this has nothing to do with the scheduler. Calling methods is probably the most important think to know about Java programming and you do it all the time...
    hint:
    timer();
    this.timer();
    plugin.timer();
    ...
     
  11. Offline

    QuantumDev

    You forgot your parentheses on the getServer method:

    Bukkit.getServer.getScheduler()...

    should be

    Bukkit.getServer().getScheduler()...
     
  12. Offline

    Assult

    It is but it still dont work :(

    Nvm guys, fixed it

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  13. Offline

    IDragonfire

    What was the problem?
     
Thread Status:
Not open for further replies.

Share This Page