How Does Minecraft Know About Your Plugin?

We’ve been using a bunch of objects in the Minecraft code. For example, you know that a player is represented as a Player object and the server is a Server object.

So it shouldn’t be too surprising to realize that our plugins are, in fact, Plugin objects. Canary has kindly defined a basic “recipe,” a basic Plugin class that it knows about. I’ve added an additional EZPlugin class to make things a little easier. Our job, as plugin writers, is to provide our own plugin code that fits into that framework.

As we’ve seen, the first line of a plugin declares the plugin’s name and then adds the magical phrase extends EZPlugin:

 
import​ net.canarymod.plugin.Plugin;
 
import​ com.pragprog.ahmine.ez.EZPlugin; ...

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.