Task Cancel problem

Discussion in 'Plugin Development' started by tschagg, Feb 1, 2013.

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

    tschagg

    hey guys, i made a little command that execute a command 50 times every tick.
    if you run it till the end, its workin fine.
    but when you type the command in the loop, like when the command is running already, it never stops till the server restart, any ideas why? or ideas how to make a stop b4 executing the command?

    Code:JAVA
    1.  
    2. if (cmd.getName().equalsIgnoreCase("COMMAND")) {
    3. if (sender.hasPermission("PERMISSION")) {
    4. miautimer = 50;
    5. new BukkitRunnable() {
    6. @Override
    7. public void run() {
    8. if(miautimer == 0) {
    9. this.cancel();
    10. }
    11. // THINGS TO DO
    12. miautimer--;
    13. }
    14. }.runTaskTimer(this, 0L, 1L);
    15. }
    16. }
    17.  


    thank you!
     
  2. Code:java
    1. if(miautimer == 0){
    2. this.cancel();
    3. }

    Try changing the miautimer to 1 instead of 0
     
  3. Offline

    tschagg

    ok i'll try :)
     
  4. Offline

    ferrybig

    if you run 2 loops at the server, miautime may be get below zero and not trigger if(miautimer == 0) {, chance it to if(miautimer <= 0) {
     
Thread Status:
Not open for further replies.

Share This Page