Skip to content
Gravity edited this page Aug 29, 2014 · 2 revisions

As of version 2.3 a new Callback functionality was added.

There's a few things to note for these callbacks:

  1. The callback will always be run on the main thread, so you may use any Bukkit API calls you wish.
  2. The callback will always be run after the updater has finished, no matter what. Be sure to check the result!

Thanks to these features, you can do nearly anything you want with the callback without worry and in the main thread. How does one use this Callback you ask? Simply by creating an UpdateCallback instance/class and passing it to the Updater when constructing it.

Example:

Updater updater = new Updater(plugin, plugin_id, plugin.getFile(), update_type, update_callback);

The update callback could look something like this:

final class Callback implements Updater.UpdateCallback {
    public void onFinish(Updater updater) {
        if (updater.getResult() == Updater.UpdateResult.SUCCESS) {
            System.out.println("Yay~ It downloaded.");
        }
    }
}
Clone this wiki locally