Put Code in a Class by Itself
First, let’s be a little more precise in what we name things. In Java source code, you declare a plugin to be a public class, which is Java’s way of saying, “This is a recipe. I can make objects of this class at runtime.” While I’ve been loosely talking about recipes and parent recipes, I’m going to start calling them by their proper Java name: classes. “Recipes” are classes.
So far we’ve sort of cheated—we’ve been putting all new code in our one plugin class, in one source-code file. When the Minecraft server runs, it makes one object from that class file and uses that.
But if you look at other plugins out on the Internet, you’ll notice that often a plugin (and larger programs) are made up of several different ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access