Ok, So in my Plugin There is a countdown method: Code:java public void MinuteCountDown(){ cd = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ GameMode gm = null;String Mapname = null; @Overridepublic void run() {if(counter == 0){Bukkit.broadcastMessage(cc.prefix + cc.maincolor + "The Game Has Begun!");Bukkit.getScheduler().cancelTask(cd);GameManager.getManager().getArena().startGame(gm, Mapname);}if(counter == Ranks.getInstance().getConfig().getInt("seconds-inbetween-games")){Random gametypechooser = new Random();int mode = gametypechooser.nextInt(3);if(mode == 0){gm = GameMode.OITC;}else if(mode == 1){gm = GameMode.FFA;}else{gm = GameMode.TDM;}int maps = Map.getInstance().getMap().getInt("mapid");int mapid = gametypechooser.nextInt(maps);for(String mn : Map.getInstance().getMap().getStringList("mapnames")){if(Map.getInstance().getMap().getInt("maps." + mn + ".id") == mapid){Mapname = mn;}}}if(SayNumber.contains(counter)){int x = counter / 60;int y = counter % 60;Bukkit.broadcastMessage(cc.prefix + cc.maincolor + " The Game Will Begin In " + cc.secondcolor + cc.bold + x + cc.maincolor + " Minutes and " + cc.secondcolor + cc.bold + y + cc.maincolor + " Seconds!");Bukkit.broadcastMessage(cc.prefix + cc.maincolor + " GameMode: " + cc.secondcolor + cc.bold + gm + cc.maincolor + " Map: " + cc.secondcolor + cc.bold + Mapname);}counter--;} }, 0, 20); } and then the game starts. When the game ends I call a method I made called endGame and when I call the minute countdown method inside of it it doesn't work. It says its on line 140 of GameArena.java so this line: Code:java plugin.MinuteCountDown(); How can I fix this? Tag Me if you need more info Thanks For the Help. Umm 1 view? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
I don't know if it's any help or anything, but something I'm doing involves a recursive count-down. Code:java public class CountDownTask extends BukkitRunnable{ public CountDownTask(int count) { currentcount = count; } int currentcount; @Override public void run() { if(currentcount <= 0) { // Thing to do when countdown finishes. } else { for(Player player : Bukkit.getOnlinePlayers()) player.setLevel(currentcount); // Or any other way of displaying a count-down. new CountDownTask(currentcount - 1).runTaskLater(SM.getPlugin(), 20); // Calls the next instance with a decremented counter. } }} This can be run by calling new CountDownTask(<number of seconds>).run() (no assignment needed).
Hanii Puppy I'll see if I can implement it tomorrow. Could / Should work Thanks Hanii Puppy What does SM stand for in SM.getPlugin() I did public static main plugin; then put plugin there but it didn't work. B U M P EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Sorry, every time I start a new bukkit plugin, one of the first thing I do is create a class for miscellaneous static methods and fill it with the below code. It gives me a central repository for static methods that don't really go anywhere, and saves me having to do some things like pass references to the plugin around everywhere. SM.getPlugin() is just a reference to your plugin, which you can either pass in from wherever you're starting the countdown from, or access from a static class. Code:java public class SM{ public static void initialise(JavaPlugin plugin) { SM.plugin = plugin; logger = plugin.getLogger(); } static JavaPlugin plugin; static Logger logger; public static JavaPlugin getPlugin() { return plugin; } public static void registerListener(Listener listenertoregister) { Bukkit.getPluginManager().registerEvents(listenertoregister, plugin); } public static void print(String message) { logger.info(message); }}