Make a Runnable Task

Here’s the simplest code for a task that just sends a broadcast message. It may not do much, but you can use this piece of code as a starting template when making your own tasks.

Just add the code you want down in the body of the run function, change the package name, and add any imports you may need. (Remember, the common ones are listed in Appendix 7, Common Imports , and you can find others in the Canary or Java docs.)

​ 
package​ examplepackage;
 
import​ net.canarymod.Canary;
 
import​ net.canarymod.tasks.ServerTask;
 
import​ com.pragprog.ahmine.ez.EZPlugin;
 
​ 
public​ ​class​ ExampleTask ​extends​ ServerTask {
 
 
private​ ​final​ EZPlugin plugin;
 
​ 
public​ ExampleTask(EZPlugin plugin) {
 
super(Canary.getServer(), ...

Get Learn to Program with Minecraft Plugins, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.