Solved Repeating task outside of main class

Discussion in 'Plugin Help/Development/Requests' started by yankeesblocks, Apr 23, 2015.

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

    yankeesblocks

    Hi, I cannot seem to get the bukkit scheduler to work outside of the main class. Any help would be good.

    Current Non-Working code:
    Code:
    Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(main, new Runnable() {
        public void run() {
            Location zl = z.getLocation();
            if (!(z.isDead())) {
                z.getLocation().getWorld().playEffect(zl, Effect.ENDER_SIGNAL, 1);
            }
        }
    }, 0, 1);
    Fixed it, changed it to:
    Code:
    MainClass mainp = MainClass.getPlugin(MainClass.class);
    new BukkitRunnable() {
        public void run() {
            Location zl = z.getLocation();
            if (!(z.isDead())) {
                z.getLocation().getWorld().playEffect(zl, Effect.ENDER_SIGNAL, 1);
            }
        }
    }.runTaskTimer(mainp, 0, 1);
    For context, MainClass is my main class.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
Thread Status:
Not open for further replies.

Share This Page