Hi, i need to use a repeating task in another class: This class is "my own API" so i need to get it from other classes to.... Here´s the code im using right now: Code:java public static void BarOfficial(final Player player){plugin.getServer().getScheduler().scheduleSyncRepeatingTask(//HERE, new Runnable(){ @Overridepublic void run() {Random random = new Random();List<String> list = new ArrayList<>();list.add(ChatColor.GREEN + "Enjoy the fight");list.add(ChatColor.YELLOW + "Just another random Message!");String message = (String) list.get(random.nextInt(list.size()));BarAPI.setMessage(player, message);} }, 0, 1 * 20);} It said i cant use "this".... and what can I use instead?.....
Can you explain little more? You mean this: Code:java Main main; public <the class>(Main plugin) { this.main = plugin; } EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Code:java private Plugin p; //Methodpublic Plugin getPlugin(){ return p;} You mean like this because a scheduler takes a plugin.
what should I put here? Code:java plugin.getServer().getScheduler().scheduleSyncRepeatingTask(HERE, new Runnable(){
Well is this; Code:java plugin.getServer().getScheduler().scheduleSyncRepeatingTask(HERE, new Runnable(){ Inside the class that extends JavaPlugin?
If it's the main class (the JavaPlugin extending one) you should insert 'this' otherwise you should insert an instance of the main class.