Solved Boolean troubles

Discussion in 'Plugin Development' started by HackintoshMan, May 12, 2013.

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

    HackintoshMan

    I have a method that runs when a player is on s point, it starts the timer. I need the timer to only run while the player is still on the point. So if the player is on the point, isBeingCaptured1 is true when he is off of the point, oisBeingCaptured1 is false.

    Code:
    public void timer(final Player player, final int p) {
            Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
                @Override
                public void run() {
                    if (plugin.captureTheFlagHandler.captureTime != -1) {
                        if (plugin.captureTheFlagHandler.captureTime != 0) {
                            if (plugin.captureTheFlagHandler.isBeingCaptured1 == true) {
                                plugin.getServer()
                                        .broadcastMessage(
                                                plugin.PREFIX
                                                        + plugin.captureTheFlagHandler.captureTime
                                                        + " seconds left at point "
                                                        + p + "!");
                                plugin.captureTheFlagHandler.captureTime--;
                                if (plugin.captureTheFlagHandler.captureTime == 0) {
     
                                    plugin.captureTheFlagHandler.setCaptureStatus(
                                            player, p);
                                }
                            }
     
                        }
                    }
                }
     
            }, 0L, 20L);
        }
    This keeps running even when isBeingCaptured1 is false. WHY?
     
Thread Status:
Not open for further replies.

Share This Page