Solved Increasing Integer in scheduler

Discussion in 'Plugin Development' started by Hex_27, May 27, 2015.

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

    Hex_27

    Code:
                  
    int i = count;
    new BukkitRunnable(){
                       @Override
                       public void run(){
    
    i++;
                       }
                       
                       }.runTaskTimer(this, 0L, 40L);
    This doesn't seem to work. I basically need to count the times the repeating task has ran, and use it in the repeating task it self.
     
  2. Offline

    caderape

    @Hex_27 and count = ? You need to assigne an umber to i if you want increase the value
     
  3. Offline

    Hex_27

    @caderape what? What I'm trying to do now is to increase "i" everytime it repeats the task
     
  4. @Hex_27 I don't think you really know how anonymous classes work - it's just the same as any class, in that you can use fields. Don't picture the "BukkitRunnable" as being inside your method, program it as if it was completely separate.
     
  5. Offline

    Hex_27

    @AdamQpzm So I need a public variable in the surrounding class?
     
  6. @Hex_27 You need a private variable inside the BukkitRunnable - remember it's a normal class. No need for public, and no reason it shouldn't be a field.
     
  7. Offline

    Hex_27

  8. Offline

    nverdier

    So is this solved? Please mark it as so.
     
Thread Status:
Not open for further replies.

Share This Page