Java Reference
In-Depth Information
$
cd ../plugins
$
ls
HelloWorld.jar
$
rm HelloWorld.jar
$
ls
$
Now have a look at a much simpler version of
HelloWorld
, which uses
EZPlugin
,
and is located in
code/HelloWorldEZ/src/helloworld/HelloWorld.java
:
package
helloworld;
import
net.canarymod.plugin.Plugin;
import
net.canarymod.logger.Logman;
import
net.canarymod.Canary;
import
net.canarymod.commandsys.*;
import
net.canarymod.chat.MessageReceiver;
import
com.pragprog.ahmine.ez.EZPlugin;
public class
HelloWorld
extends
EZPlugin {
@Command(aliases = {
"hello"
},
description =
"Displays the hello world message."
,
permissions = {
""
},
toolTip =
"/hello"
)
public void
helloCommand(MessageReceiver caller,
String[]
parameters) {
String
msg =
"That'sss a very niccce EVERYTHING you have there..."
;
Canary.instance().getServer().broadcastMessage(msg);
}
}
Notice that this just has a bunch of
import
s at the top, and then the command
business—the part we're actually interested in—down at the bottom. This
will be the skeleton for all our upcoming plugins.
Go ahead and make sure you can build it, and that it can find the
EZPlugin
library:
$
cd Desktop
$
cd code/HelloWorldEZ
$
./build.sh
You should see the usual successful output:
Compiling with javac...
Creating jar file...
Deploying jar to /Users/andy/Desktop/server/plugins...
Completed Successfully.
If not, double-check that
EZPlugin.jar
is in
Desktop/server/lib
, and go back into
EZPlugin.jar
and rebuild it if needed.