lNockl

ObjectRunnable.java

Jun 28th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. package me.filipenock.tags;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.scheduler.BukkitTask;
  5.  
  6. public class ObjetoRunnable {
  7.    
  8.    
  9.     private int segundos;
  10.     private int ticks;
  11.     private BukkitTask task;
  12.    
  13.     public ObjetoRunnable(int delay, int segundos) {
  14.         this.segundos = segundos;
  15.         this.ticks = delay;
  16.         this.task = Bukkit.getScheduler().runTaskTimer(Main.main, new Runnable() {
  17.            
  18.             @Override
  19.             public void run() {
  20.                
  21.                 if (getSegundos() > 0) {
  22.                     System.out.println("Segundos restantes " + getSegundos());
  23.                     setSegundos(getSegundos() - 1);
  24.                    
  25.                 } else if (getSegundos() <= 0) {
  26.                     System.out.println("A Contagem acabou");
  27.                     task.cancel();
  28.                 }
  29.                
  30.             }
  31.         }, 0, delay);
  32.     }
  33.  
  34.     public BukkitTask getTask() {
  35.         return task;
  36.     }
  37.  
  38.     public void setTask(BukkitTask task) {
  39.         this.task = task;
  40.     }
  41.  
  42.     public int getSegundos() {
  43.         return segundos;
  44.     }
  45.  
  46.     public void setSegundos(int segundos) {
  47.         this.segundos = segundos;
  48.     }
  49.  
  50.     public int getTicks() {
  51.         return ticks;
  52.     }
  53.  
  54.     public void setTicks(int ticks) {
  55.         this.ticks = ticks;
  56.     }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment