Can't get my plugin to start

Discussion in 'Plugin Development' started by hawksprite, Apr 11, 2011.

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

    hawksprite

    I'm new to developing plugins for Bukkit and I can't seem to get it to start. I'll include the error i get in the server output, and the Main class source.

    Server error
    [​IMG]

    MainServer.java source :
    Code:
    package com.bukkit.hawksprite.MainServer;
    
    import java.io.*;
    import java.util.HashMap;
    
    import org.bukkit.Server;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginLoader;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class MainServer extends JavaPlugin {
        public MainServer(PluginLoader pluginLoader, Server instance,
                PluginDescriptionFile desc, File folder, File plugin,
                ClassLoader cLoader) {
            super(pluginLoader, instance, desc, folder, plugin, cLoader);
            // TODO Auto-generated constructor stub
        }
    
        private final MainServerPlayerListener playerListener = new MainServerPlayerListener(this);
        private final MainServerBlockListener blockListener = new MainServerBlockListener(this);
        private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
    
        public void onEnable() {
            // TODO: Place any custom enable code here including the registration of any events
    
            // Register our events
            PluginManager pm = getServer().getPluginManager();
    
            pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
    
            // EXAMPLE: Custom code, here we just output some info so we can check all is well
            PluginDescriptionFile pdfFile = this.getDescription();
            System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
        }
        public void onDisable() {
            // TODO: Place any custom disable code here
    
            // NOTE: All registered events are automatically unregistered when a plugin is disabled
    
            // EXAMPLE: Custom code, here we just output some info so we can check all is well
            System.out.println("Goodbye world!");
        }
        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);
        }
    }
    
     
  2. Offline

    ssell

    Don't use a constructor.

    Also, make sure your plugin.yml is formatted correctly. If you are unsure, post it here.
     
  3. Offline

    MrChick

  4. Offline

    hawksprite

    I'm not 100% sure what you mean by constructure (I do must of my codeing in C#). I'll post my plugin.yml.

    Thanks for the links i'll make a note to watch the tutorial.

    Code:
    name: MainServer
    main: com.bukkit.hawksprite.MainServer.MainServer
    version: 1
     
  5. Offline

    ssell

    C# (like C++) has constructors as well. Its what is called when you create an instance of a class or struct.

    In your above code it is this:

    Code:
        public MainServer(PluginLoader pluginLoader, Server instance,
                PluginDescriptionFile desc, File folder, File plugin,
                ClassLoader cLoader) {
            super(pluginLoader, instance, desc, folder, plugin, cLoader);
            // TODO Auto-generated constructor stub
        }
    
    take this out.
     
  6. Offline

    hawksprite

    I had never refereed to them as constructors before, but i know what your talking about now. I got it running after taking that snippet out and watching that you tube video.
     
  7. Offline

    mindless728

    ummm, he can still have a constructor, as they can be useful to initialize the plugin data variables to a known good state until enable is called, it just can't take any parameters
     
  8. Offline

    ssell

    I have always read they shouldn't be used. Never employed them myself since it wasn't needed.
     
Thread Status:
Not open for further replies.

Share This Page