repeating task

Discussion in 'Plugin Development' started by mastermustard, Feb 16, 2013.

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

    mastermustard

    so im working on a plugin right now and i want it to broadcast a message at random every 100 seconds. i wanted to know what i would use "task" for since it says its unused. when i try to remove that top portion eclipse gives an error. any help?

    Code:
            BukkitTask task = this.getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
                @Override 
                public void run() {
                    List<String> messages = new ArrayList<String>();
                   
                    messages.add(getConfig().getString("message-1"));
                    messages.add(getConfig().getString("message-2"));
                    messages.add(getConfig().getString("message-3"));
                   
                    getServer().broadcastMessage(messages.get(new Random().nextInt(messages.size())));
                }
            }, 40L, 2000L);
     
  2. Offline

    Sagacious_Zed Bukkit Docs

    mastermustard
    Your first mistake was scheduling this asynchronously.

    Also, the supported operations of a BukkitTask are listed here
     
  3. Offline

    mastermustard

    i was looking and one thing and copied the other :/
     
Thread Status:
Not open for further replies.

Share This Page