O'Reilly logo

Learn to Program with Minecraft Plugins, 2nd Edition by Andy Hunt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Plugin: Stuck

Let’s look at a plugin that will encase a player in solid rock (the full plugin is in code/Stuck). When you issue the command stuck with a player’s name, that player will suddenly be encased in a pile of blocks. (If you’re alone on the server, your player name might be the wonderfully descriptive name “player.”)

We’ll start by looking at pieces of this plugin, and then put it all together.

All the interesting parts are in a separate helper function named stuck. The main part of the plugin should look pretty familiar by now:

Stuck/src/stuck/Stuck.java
 
package​ stuck;
 
 
import​ net.canarymod.plugin.Plugin;
 
import​ net.canarymod.logger.Logman;
 
import​ net.canarymod.Canary;
 
import​ net.canarymod.commandsys.*;
 
import ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required