Guest User

Countdownklasse

a guest
Jan 26th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. package de.mittelego.lernen.commands;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.command.Command;
  5. import org.bukkit.command.CommandExecutor;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.entity.Player;
  8.  
  9.  
  10. import de.mittelego.lernen.main.Main;
  11.  
  12. public class CountdownCommand implements CommandExecutor{
  13.  
  14. private int taskID;
  15. @Override
  16. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  17.  
  18.  
  19. if(sender instanceof Player) {
  20.  
  21.  
  22. taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(null), new Runnable() {
  23.  
  24. int cd = 10;
  25.  
  26.  
  27. @Override
  28. public void run() {
  29. if(cd <= 0) {
  30. Bukkit.broadcastMessage("§c§lDER KRIEG HAT BEGONNEN!");
  31. Bukkit.getScheduler().cancelTask(taskID);
  32. return;
  33. }
  34. Bukkit.broadcastMessage("§c§oDer Krieg bricht in §6" + cd + " Sekunden§c§o.");
  35. cd--;
  36.  
  37.  
  38.  
  39.  
  40. }
  41. }, 20, 20);
  42.  
  43. }
  44.  
  45. return false;
  46. }
  47.  
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment