Repeating Tasks

Discussion in 'Plugin Development' started by MasterNiitro, Jan 16, 2017.

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

    MasterNiitro

    Here I am again trying to figure out how to do a "combat tag" plugin using repeating tasks............
    Can you please tell me what i did wrong i tried debugging and all i can think of.

    Code:
    Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
                     
                      public void run() {
                          combat--;
                          if (combat == 0)
                              plugin.cooldown.remove(plugin.attacker);
                                plugin.cooldown.remove(plugin.defender);
                                plugin.attacker.sendMessage("§aYou left ct");
                                plugin.defender.sendMessage("§aYou left ct");
                     }       
                   }, 0L, 20L);
     
  2. Offline

    JanTuck

    Why are you using a repeating task?

    Sendt fra min ALE-L21 med Tapatalk
     
  3. Offline

    MasterNiitro

    @JanTuck I am using it because i need a timer to say when the player is in combat or not and send them a message to let them know when they are not in combat anymore
     
  4. Offline

    DoggyCode™

    Just save a timestamp (being System.currentTimeMillis()) of when the player last was in combat.
     
  5. Offline

    MasterNiitro

  6. Offline

    DoggyCode™

    And then just create a custom event which will fire when the player exits out of combat.
     
  7. Offline

    MasterNiitro

    @DoggyCode I was wondering if that could be done using the runnable repeatingtask, can it?
    Because im used to do things with runnables but this is my first problem with them. Is the code i gave you in the previous post wrong? ("create a custom event which will fire when the player exits out of combat" I really dont know how to do that lmao)

    Can anyone tell me what i did wrong? Why its not working?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 16, 2017
  8. Online

    timtower Administrator Administrator Moderator

Thread Status:
Not open for further replies.

Share This Page