Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.hugozar.tools.managers;
- import java.util.Map.Entry;
- import org.bukkit.Bukkit;
- import org.bukkit.World;
- import org.bukkit.scheduler.BukkitRunnable;
- import org.bukkit.scheduler.BukkitTask;
- import pl.hugozar.tools.Tools;
- public class TimerManager{
- static BukkitTask saveTimer;
- static BukkitTask slowChatTimer;
- static BukkitTask autoMsgTimer;
- public static void startSaveTimer(){
- saveTimer = new BukkitRunnable(){
- @Override
- public void run(){
- Bukkit.broadcastMessage(Utils.fixColors(" &8> &9Zapisywanie servera."));
- Bukkit.savePlayers();
- for(World w : Bukkit.getWorlds()){
- w.save();
- }
- Bukkit.broadcastMessage(Utils.fixColors(" &8> &9Zapisywanie servera zakonczone."));
- }
- }.runTaskTimer(Tools.getInst(), 6000, 6000);
- }
- public static void stopSaveTimer(){
- saveTimer.cancel();
- }
- public static void startSlowChatTimer(){
- slowChatTimer = new BukkitRunnable(){
- @Override
- public void run(){
- for(Entry<String, Integer> line : Data.slowChat.entrySet()){
- Data.slowChat.put(line.getKey(), line.getValue() - 1);
- if(Data.slowChat.get(line.getKey()) <= 0){
- Data.slowChat.remove(line.getKey());
- }
- }
- }
- }.runTaskTimer(Tools.getInst(), 20, 20);
- }
- public static void stopSlowChatTimer(){
- slowChatTimer.cancel();
- }
- public static void startAutoMsgTimer(){
- autoMsgTimer = new BukkitRunnable(){
- @Override
- public void run(){
- Bukkit.broadcastMessage(Utils.fixColors(Data.getAutoMsgMessages().get(Utils.getRandInt(0, Data.getAutoMsgMessages().size() - 1))));
- }
- }.runTaskTimer(Tools.getInst(), 1200, 1200);
- }
- public static void stopAutoMsgTimer(){
- autoMsgTimer.cancel();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement