- Баллы
- 76
Уничтожится ли экземпляр сам или его надо будет уничтожить?Если не уничтожается,то как уничтожить.
Вот класс таймера:
Вот так запускаю:
MyTime mytime = new MyTime(plugin,5);
mytime.runTaskTimer(plugin, 0, 20);
Вот класс таймера:
Код:
package ru.Novichock.HideAndSeek;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class MyTime extends BukkitRunnable {
private int counter;
private HideAndSeek plugin;
public MyTime(HideAndSeek plugin,int counter){
this.counter=counter;
this.plugin=plugin;
}
@Override
public void run() {
if(counter>0){
for(Player p : plugin.JoinInGame){
plugin.Messager("Игра начнётся через: "+counter, p);
counter--;
}
}
if(counter==0){
for(Player p : plugin.JoinInGame){
plugin.Messager("Игра началась!", p);
}
this.cancel();
}
}
}
Вот так запускаю:
MyTime mytime = new MyTime(plugin,5);
mytime.runTaskTimer(plugin, 0, 20);