Java Reference
In-Depth Information
Plugin: Simple
package
simple;
import
net.canarymod.plugin.Plugin;
import
net.canarymod.logger.Logman;
import
net.canarymod.Canary;
import
net.canarymod.commandsys.*;
import
net.canarymod.chat.MessageReceiver;
import
net.canarymod.api.entity.living.humanoid.Player;
import
com.pragprog.ahmine.ez.EZPlugin;
❶
public class
Simple
extends
EZPlugin {
@Command(aliases = {
"simple"
},
description =
"Displays simple variable assignments"
,
permissions = {
""
},
toolTip =
"/simple"
)
public void
simpleCommand(MessageReceiver caller,
String[]
parameters) {
if
(caller
instanceof
Player) {
Player me = (Player)caller;
// Put your code after this line:
❷
// ...and finish your code before this line.
}
}
}
Don't worry about all that extra program text yet. We'll talk about that more
as we go along. For now just put new code on the lines as shown, and it will
work fine. Here's what you're going to do:
First, add two import statements at the top of the file, after the other
import
lines at
❶
. Type in the following:
import
net.canarymod.api.world.effects.SoundEffect;
import
net.canarymod.api.world.position.Location;
Next, after where it says
//Putyourcodeafterthisline:
at
❷
, do this:
1.
Create an integer variable named
myAge
and set it to whatever your age is.
2.
Make another integer variable named
twiceMyAge
and set it equal to
myAge
multiplied by 2.
3.
Create a float variable named
volume
and set it equal to
0.1
.
4.
Create a float variable named
pitch
and set it equal to
1.0
.