Calling tasks via libraries/other plugins.

Discussion in 'Plugin Development' started by Warreo, Jul 10, 2013.

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

    Warreo

    Out of curiosity I was wondering if bukkit tasks could be called out of an API, because obviously without the help of another plugin you can't call events. So I had assumed the same applied to tasks. If they can't one could still go about calling tasks in a different plugins source, correct? Like this for example:

    Code:
    public class ExampleClass {
       
        private int number = 0;
        private Plugin plugin;
       
        public ExampleClass(int i, Plugin plugin){
            this.number = i;
            this.plugin = plugin;
        }
       
        public void addOne(){
            final ExampleClass exm = this;
            plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                    @Override
                    public void run() {
                        exm.number++;
                    }
                }, 20L);     
        }
    }
    In this case ExampleClass would be a object used in a said API. Could a different plugin still run this as long as you registered that the plugin originally containing ExampleClass?

    Thanks,
    -Warreo :D
     
Thread Status:
Not open for further replies.

Share This Page