Need plugin help.

Discussion in 'Plugin Development' started by Gonzo0193, Feb 27, 2011.

Thread Status:
Not open for further replies.
  1. Offline


    So i have been looking in the java docs due to lack of an in-date tutorial, and i have my as this:
    package me.carbzo.gonzo.basic;
    import java.util.HashMap;
    import org.bukkit.Server;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.event.Event;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginLoader;
    import org.bukkit.plugin.PluginManager;
     * <pluginname> for Bukkit
     * @author <yourname>
    public class basic extends JavaPlugin {
        private final basicPlayerListener playerListener = new basicPlayerListener(this);
        private final basicBlockListener blockListener = new basicBlockListener(this);
        private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
        public basic(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {
            super(pluginLoader, instance, desc, plugin, cLoader);
            // TODO: Place any custom initialisation code here
            // NOTE: Event registration should be done in onEnable not here as all events are unregistered when a plugin is disabled
        public void onEnable(){}
        public void onPlayerJoin() {
        	//Create the pluginmanage pm.
    		PluginManager pm = getServer().getPluginManager();
    		//Create PlayerCommand listener
    	    pm.registerEvent(Event.Type.PLAYER_COMMAND, this.playerListener, Event.Priority.Normal, this);
    	    //Create BlockPlaced listener
            pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Event.Priority.Normal, this);
           //Get the infomation from the yml file.
            PluginDescriptionFile pdfFile = this.getDescription();
            //Print that the plugin has been enabled!
            System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
        public void onDisable() {}
        public boolean isDebugging(final Player player) {
            if (debugees.containsKey(player)) {
                return debugees.get(player);
            } else {
                return false;
        public void setDebugging(final Player player, final boolean value) {
            debugees.put(player, value);
    I know that onCommand() replace onPlayerCommand() but what replaces PLAYER_COMMAND?

    Also is using on player join a valid way to enable a plugin?
  2. Offline

    Edward Hand

    You don't need to register an event. You put the onCommand() function in your main plugin class (where onEnable are and such) making sure to register the commands in your plugin.yml.
Thread Status:
Not open for further replies.

Share This Page