Once you have your list together, it's time to start writing some code—but
not all at once, as we'll see in the next section.
Try Each Part
We're going to start coding now, but as exciting as that is, we want to go
slowly. Whether you're following along with me here or working on your own
plugin, remember to take one small step at a time—don't rush it.
Let's begin by creating a new directory and the usual files that every plugin
needs. Once again we'll use the mkplugin.sh script to get started. Don't forget,
you'll be making your own plugin under desktop; my version is under Desk-
~/Desktop$ ./mkplugin.sh CreeperCow
~/Desktop$ cd CreeperCow
~/Desktop/CreeperCow$ ls -a
And we'll start right away by using Git to track our work (check back with
Chapter 12, Keep Your Code Safe , on page 169 , for a refresher if you need to).
The mkplugin.sh script thoughtfully made us a .gitignore that will ignore the bin/
and dist/ directories. So we'll add our first couple of files and commit them as
~/Desktop/CreeperCow$ git init
Initialized empty Git repository in /Users/andy/Desktop/CreeperCow/.git/
~/Desktop/CreeperCow$ git add .gitignore build.sh Canary.inf Manifest.txt src
~/Desktop/CreeperCow$ git commit -a -m First
[master (root-commit) 2e483f1] First
5 files changed, 95 insertions(+)
create mode 100644 .gitignore
create mode 100755 build.sh
create mode 100644 Canary.inf
create mode 100644 Manifest.txt
create mode 100644 src/creepercow/CreeperCow.java
(If you are hooked up to a remote repository, you can do a gitpush now as well.)
Now on to the code.
We know that we need to create a static cowList and a spawnCows() method, and
we'll need to listen for some events, so let's start with that in CreeperCow.java .
Here's the interesting part (omitting other imports and the usual other stuff):