Java Reference
In-Depth Information
Here is the Java source code for our HelloWorld plugin, which is already typed
in for you in the file ~/Desktop/code/HelloWorld/src/helloworld/HelloWorld.java . There's a
lot of weird stuff in here. (If you haven't downloaded the code for this topic to
your Desktop yet, grab it now from http://media.pragprog.com/titles/ahmine2/code/
ahmine2-code.zip . You can use unzip from the command line to unpack the archive
and create all the files.)
HelloWorld/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;
public class HelloWorld extends Plugin implements CommandListener {
public static Logman logger;
public HelloWorld() {
logger = getLogman();
}
@Override
public boolean enable() {
logger.info( "Starting up" );
try {
Canary.commands().registerCommands(this, this, false);
} catch (CommandDependencyException e) {
logger.error( "Duplicate command name" );
}
return true;
}
@Override
public void disable() {
}
@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);
}
}
 
 
Search WWH ::




Custom Search