Repeating a code on a specific amount

Discussion in 'Plugin Development' started by Henriksen1000, Sep 26, 2015.

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

    Henriksen1000

    So... I started coding and I want to make a clearchat command, something like that.

    Well, how do I repeat a code on a specific amount of times?
     
  2. Offline

    SuperSniper

  3. Offline

    Henriksen1000

    Something like this:
    Code:
                Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                    public void run() {
                        Bukkit.broadcastMessage("");
                    }
                }, 20, 200);
    EDIT:
    Full code:
    Code:
            if(cmd.getName().equalsIgnoreCase("clearchat"))  {
                if (!sender.hasPermission("crazyplugin.admin.clearchat")) {
                    sender.sendMessage( ChatColor.RED + "No Access.");
                    return true;
                }
                Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                    public void run() {
                        Bukkit.broadcastMessage("");
                    }
                }, 20, 200);
            }
     
  4. Offline

    SuperSniper

  5. Offline

    Henriksen1000

    It makes an infinity loop of sending empty chat messages...
    help me...
     
  6. Offline

    Tudedude

Thread Status:
Not open for further replies.

Share This Page