I am trying to make a plugin that uses a scheduleSyncRepeatingTask
and the task is created by calling a method. The problem is trying to call it from a different class.
When I try to call the method, it will say that the method needs to be static
. So, I make the method static
and then the first parameter in the scheduleSyncRepeatingTask
says it cannot be used in a static
context.
My Method
public static void newCountdown() {
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
player.sendMessage("Hey");
}
}
}, 0, 20);
}
I'm kind of new to Java at the minute and static
variables are still something I'm trying to understand so if anyone can link me to somewhere I can read up on it, or even a video then that would be great.
As for the problem, if anyone has the solution then any help would be greatly appreciated.