Timers in a new Class executed by Command

Discussion in 'Plugin Development' started by LordVakar, Jun 14, 2013.

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

    LordVakar

    So say I have a command:

    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    2. if(cmd.getName().equalsIgnoreCase("command")){
    3. }
    4. }


    How would I execute a timer in another class?
    Like:
    Code:java
    1. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    2.  
    3. public void run() {
    4. }
    5.  
    6. }, (seconds*60L);
    7.  

    So I want the command to activate another class with:
    Code:java
    1. public void run() {
    2. }

    How do I achieve this?
     
  2. Offline

    caseif

    Put the scheduler inside a method and call that method.
     
  3. Offline

    finalblade1234

    Code:
        // you can call DoStuff(); in a different class
        public  void DoStuff(){
            Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
     
               
                public void run() {
                    // do some stuff
                   
                }
               
            }, 1);
    }
    Then call DoStuff(); in your oncommand/class
     
Thread Status:
Not open for further replies.

Share This Page