Adding countdown

Discussion in 'Plugin Development' started by thatdubstepgamer, Sep 15, 2013.

Thread Status:
Not open for further replies.
  1. I want to add a countdown from 15 sec and when it hits 0 it runs a piece of code heres my code so far.
    Code:java
    1. @EventHandler
    2. public void onPlayerInteract11(PlayerInteractEvent event) {
    3.  
    4. Player player = event.getPlayer();
    5. if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
    6. if (event.getClickedBlock().getType() == Material.GOLD_BLOCK) {
    7. event.setCancelled(true);
    8. Bukkit.broadcastMessage(player.getName()+ " Has just armed the Red teams bomb!");
    9. event.getClickedBlock().setType(Material.REDSTONE_BLOCK);
    10.  
    11.  
    12.  
    13.  
    14.  
    15.  
    16.  
    17.  
    18.  
    19. }}}
     
  2. Offline

    chasechocolate

    Code:java
    1. new BukkitRunnable(){
    2. @Override
    3. public void run(){
    4. //Do code
    5. }
    6. }.runTaskLater(plugin, 300L); //20 ticks/second * 15 seconds = 300 ticks
     
  3. Offline

    JPG2000

    thatdubstepgamer Use chasechocolate codes, and run it every second. Then, you can use a switch() statement, or do a in if, and check if the counter int variable is at a certain number, if so, do code.
     
Thread Status:
Not open for further replies.

Share This Page