How to use getScheduler in other classes

Discussion in 'Plugin Development' started by Boof's Coding, Jan 2, 2021.

Thread Status:
Not open for further replies.
  1. Offline

    Boof's Coding

    I've tried to get this small Scheduler in a secondary class but It gives me an expression expected error at where the word "Main Class is".
    What is the class or word, when the file is not in the main, I've tried all prominent classes in my file?

    Bukkit.getScheduler().scheduleSyncDelayedTask(MainClass, () ->
    }, 200L);
  2. Offline

    timtower Administrator Administrator Moderator

    @Boof's Coding It needs to be an instance of the main class, not the class name.
  3. Offline


    If you are calling this code from the main class, replace "MainClass" with "this".
    If you are calling it from another class, you can pass an instance of MainClass into the second class through its constructor (google it).
  4. Offline

    Mathias Eklund

Thread Status:
Not open for further replies.

Share This Page