Hello I'am trying to make a plugin that fallingblocks 60 ticks gives a vector. But i don't know how I can stop the task after 60 ticks. Can someone help me? Thanks for any help!
Well you could try something like this, it should work. Code: /** * @author Javi */ public class MyClass { int task; public void doTask() { this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(getPluginInstance(), new Runnable() { public void run() { int i = 0; while (i<60) { //do the things you need i++; } endTask(); } }, x, y); } public void endTask() { Bukkit.getScheduler().cancelTask(this.task); } }
What do you mean? I'm just providing a method by which he could " how I can stop the task after 60 ticks.". You could then call it from anywhere or just create a MyClass instance with an empty constructor and call it from there. Yeah I suppose you can do it like that too EDIT by Moderator: merged posts, please use the edit button instead of double posting.