Java Reference
In-Depth Information
I'll do a gitadd on the new file so my changes can be tracked.
Great. Now we need some way of setting that private cow object. We'll hook
this up to the spawnCows function later, but right now we'll just pass in a cow
that's been spawned already. For that, we'll use the constructor function:
CreeperCowTimer(Cow aCow) {
cow = aCow;
Next we need to add a jump command to the plugin for our testing. Now we'll
go back into the spawnCows function and add the spawned cows to the ArrayList .
Then, in the jump command we can go through the list and get each of the
spawned cows to jump toward us.
So we'll start with this:
Cow cow = (Cow)spawnEntityLiving(loc, EntityType.COW);
Then we'll add a test command:
@Command(aliases = { "testjump" },
description = "Test cow jumping" ,
permissions = { "" },
min = 1, // Number of arguments
toolTip = "/testjump" )
public void testJumpCommand(MessageReceiver caller, String[] args) {
if (caller instanceof Player) {
Player me = (Player)caller;
for (Cow c : cowList) {
Oops, that's not going to work.
We shouldn't have kept a list of cows. We really need to keep track of Creeper-
CowTimer objects, as that will get us the jump() function and the other guts that
we need to write, as well as the Cow itself.
And if we do that, we should probably change the list to be a HashMap instead
of an ArrayList so we can look up the CreeperCowTimer objects by their Cow , as
that's what we'll get from events and spawning and such. We'll need to redo
a few things now.
Make a list of things we need to change for this, and come on back once you
have it.
Search WWH ::

Custom Search