Solved Can't run task async

Discussion in 'Spigot Plugin Development' started by VivianMusic, Mar 2, 2020.

  1. Well an async event is called asynchronously, as the name suggests. You simply need to wrap your code with a sync scheduler task to get back on the main thread.
     
  2. Why was it working before..?
     
  3. Could it have something to do with using the main class instance in some classes and passing the main class to others?
     
  4. SteelPhoenix

    Moderator

    No..? How could that even affect it
    Older spigot versions do not enforce sync events etc having to be called from the main server thread.
     
  5. Aha! Gotcha...what would be the best way to wrap it?
     
  6. Did that change since 1.13.2?
     
  7. en5

    en5

    Code (Text):
    Bukkit.getScheduler().runTask(Plugin,
        () -> {
            Code to execute here
        });
    or like this
    Code (Text):
    Bukkit.getScheduler().runTask(Plugin, () -> Code to execute here);
     
    • Friendly Friendly x 1
  8. Oooh lambda. Thanks! Can I add you on discord..?