How can I add a countdown to this code below. I want it so it messages the player who types /refill saying 5.. 4.. 3.. 2.. 1.. THEN it gives the Item. How could I do this? package me.goo.Main.Listeners; import me.goo.Main.Main; import me.goo.Main.Utils.Utils; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; public class Refill extends JavaPlugin implements CommandExecutor { final Main p; public Refill(Main instance) { p = instance; } public boolean onCommand(CommandSender sender, Command cmd, String tag, String[] args) { Player player = (Player)sender; PlayerInventory pi = player.getInventory(); if(cmd.getName().equalsIgnoreCase("refill")) { PotionEffect p1 = new PotionEffect( PotionEffectType.BLINDNESS, 100, 3); p1.apply(player); PotionEffect p2 = new PotionEffect( PotionEffectType.CONFUSION, 100, 0); p2.apply(player); PotionEffect p3 = new PotionEffect( PotionEffectType.WEAKNESS, 100, 0); p3.apply(player); PotionEffect p4 = new PotionEffect( PotionEffectType.SLOW_DIGGING, 100, 3); p4.apply(player); PotionEffect p5 = new PotionEffect( PotionEffectType.SLOW, 100, 5); p5.apply(player); player.sendMessage(ChatColor.GREEN + "" + ChatColor.ITALIC + "9 MushroomSoups have been added to your inventory!"); player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "I..Am..Now..Weak!"); for(int i = 0; i < 9; i++) { pi.addItem(Utils.Soup()); } } return true; } } Thanks, Goo
Ok sorry, But Could u please code this out for me? I have no clue how to do CountDowns.. Thanks anyway
goomonster3 Im not here to write code for you, this section is for help not 'can you do it for me'. I will give you how as close as i can, but i cant write it for you. if you googled it you would find this as your top link: Link this link is a tutorial which shows you how to create one and use its functions, its your job to modify it to what you want. How To: create a scheduler and set it to repeat every 1 second. put a variable in which will count down. put in an if statement which sets the variable to 5 only when it equals 0. output the number to the player. when it reaches 0 (determined by if statement) give the player the item and then stop the scheduler.