Self-Cancelling Task?

Discussion in 'Plugin Development' started by RoboticPlayer, Sep 11, 2015.

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

    RoboticPlayer

    I am working on a plugin which has a clearchat command. This command will send each player who doesn't have a certain permission a message (which happens to be blank). I know there is a way to make a task that will cancel itself after a certain number of times of it being run, but I don't remember how to do so. I am currently using the very innefficent method of repeating p.sendMessage(""); over and over. Here is a snippet of my code. I cut out all of the other parts with p.sendMessage(""); just know that they are there.
    Code:
    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
                    if (!(p.hasPermission("chatmanager.clearchat.exempt"))) {
                        p.sendMessage("");
                    }
                }
    The code itself works fine, I just want to know how to do it more efficiently.
     
  2. Offline

    Gamesareme

  3. Offline

    RoboticPlayer

  4. Offline

    Gamesareme

  5. Offline

    mythbusterma

    @henderry2019

    The way you're doing it is fine, if pointless.
     
  6. Are you looking for a for(int i = 0; i <50; i++) loop?
     
    SyTeck likes this.
Thread Status:
Not open for further replies.

Share This Page