Java Reference
In-Depth Information
import net.canarymod.plugin.PluginListener;
import java.util.ArrayList;
import com.pragprog.ahmine.ez.EZPlugin;
public class CreeperCow extends EZPlugin implements PluginListener {
private static ArrayList <Cow> cowList = new ArrayList <Cow>();
public void spawnCows() {
We made the main plugin a PluginListener and added a cowList variable and the
start of the spawnCows() function. Before we go any further, let's test just that
much —see if it builds without errors, and run the (empty) spawnCows function.
Small steps, remember. We don't have an event listener yet (in fact, we don't
even know what event we're going to listen for), so we'll use a trick.
We're going to add a command to @Command that's just for us—it's not for
users. But we can use it to test what we're doing as we go along.
So let's wire that up first, even before we've added any code to spawnCows :
@Command(aliases = { "testspawncows" },
description = "Test cow spawning" ,
permissions = { "" },
toolTip = "/testspawncows" )
public void testSpawnCommand(MessageReceiver caller, String[] args) {
if (caller instanceof Player) {
Player me = (Player)caller;
Location loc = me.getLocation();
(We'll need to; too.)
Now we have the ability to log in to the game and run the /testSpawnCows com-
mand to watch our cows spawn and make sure that works.
We don't actually spawn any cows yet, but let's just try it now and make sure
everything compiles, using , before we add any more code.
Compiling with javac...
Creating jar file...
Deploying jar to /Users/andy/Desktop/server/plugins...
Completed Successfully.
Search WWH ::

Custom Search