Multiple Executions of the same Code

Discussion in 'Plugin Development' started by DocRedstone, Jun 4, 2012.

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

    DocRedstone

    I have the code bellow. For some reason (at the defined points) that code is executing 4 times.... Suggestions?

    Code:
    public void kill() {
            this.getServer().getScheduler().cancelTasks(this);
            if (yesvotec > novotec) { //4 Times
                Bukkit.broadcastMessage(ChatColor.RED + "[BanVote] " + toVote.getDisplayName() + "has been banned by vote for: " + reason);
                toVote.setBanned(true);
                toVote.kickPlayer(reason);
            }
            else if (yesvotec < novotec) { //4Times
                Bukkit.broadcastMessage(ChatColor.GREEN + "[BanVote] The people have spoken " + toVote.getDisplayName() + " has been sparred.");
            } else {
                Bukkit.broadcastMessage(ChatColor.GREEN + "[BanVote] The people have spoken " + toVote.getDisplayName() + " has been sparred.");
            }
        }
       
        public void iniateCountDown() {
            this.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {
                @Override
                public void run() {
                        for (String s : yesvotes) {
                            yesvotec++;
                        }
                        for (String sl : novotes) {
                            novotec++;
                        }
                        voteStarted = false;
                        kill();
                    }
            }, 20*60, 0L);
        }
     
  2. Offline

    xpansive

    What is calling the iniateCountDown method?
     
  3. Offline

    DocRedstone

    my onCommand(...args[0]) method.
     
  4. why do you use a repeating task if it'll only run once no matter what?
     
  5. Offline

    DocRedstone

    I want it to wait a defined amount of time before doing anything. And the Sleep event does not seem to work.

    Edit: Ah I get what you mean...I forgot about DelayedTasks
     
  6. use not aschy tasks, but schry, remove the A, bukkit is not build on thread safety
     
    DocRedstone likes this.
Thread Status:
Not open for further replies.

Share This Page