Java Reference
In-Depth Information
In addition to the plugin code itself, Canary needs a configuration file for the
plugin, named Canary.inf . You saw a description of this back on page 35 , while
we were building plugins the first time. It tells the server some basic informa-
tion about your plugin, so that the server can load it.
With that configuration file and your code, the Minecraft server can run your
plugin just like any other part of the game.
Plugin: SkyCmd
We're going to create a brand-new plugin called SkyCmd . In it, we'll create a
command named sky that will teleport all creatures (not players) 50 blocks
up into the air. Very handy at night with skeletons and creepers about.
Here's the whole source file to the plugin:
package skycmd;
import net.canarymod.plugin.Plugin;
import net.canarymod.logger.Logman;
import net.canarymod.Canary;
import net.canarymod.commandsys.*;
import java.util.List;
import com.pragprog.ahmine.ez.EZPlugin;
public class SkyCmd extends EZPlugin {
@Command(aliases = { "sky" },
description = "Fling all creatures into the air" ,
permissions = { "" },
toolTip = "/sky" )
public void skyCommand(MessageReceiver caller, String[] parameters) {
if (caller instanceof Player) {
Player me = (Player)caller;
List <EntityLiving> list = me.getWorld().getEntityLivingList();
for (EntityLiving target : list) {
if (!(target instanceof Player)) {
Location loc = target.getLocation();
double y = loc.getY();
Search WWH ::

Custom Search