Issues with blockListener

Discussion in 'Plugin Development' started by Zaros, Jun 12, 2011.

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

    Zaros

    I just started this plugin not to long ago and I've already come across an error I can't seem to figure out. Please tell me its just something simple I've overlooked. It says that NetherOPBlockListener is undefined, but it is define right there in the same line...

    Code:
    package me.Zaros.NetherOP;
        import java.util.logging.Logger;
        import org.bukkit.ChatColor;
        import org.bukkit.entity.Player;
        import org.bukkit.event.Event;
        import org.bukkit.event.world.PortalCreateEvent;
        import org.bukkit.plugin.PluginManager;
        import org.bukkit.plugin.java.JavaPlugin;
    
    public class NetherOP extends JavaPlugin {
    Logger log = Logger.getLogger("Minecraft");
    private final NetherOPBlockListener blockListener = new NetherOPBlockListener(this);
    double version = 0.1;
    
        public void onEnable(){
            PluginManager pm = this.getServer().getPluginManager();
            pm.registerEvent(Event.Type.PORTAL_CREATE, blockListener, Event.Priority.Normal, this);
            System.out.println("NetherOP v " + version + " - Enabled");
        }
    
        public void onDisable(){
            System.out.println("NetherOP v " + version + " - Disabled");
        }
    }
     
  2. Offline

    Sethcran

    Have you actually created the class in another java file? If so, is it in the same package as your plugin class, or is it in a different one and you forgot to import it?
     
  3. Offline

    Zaros

    Yes, NetherOPBlockListener exists in the same package. That's why I don't understand what is wrong.
     
  4. What exactly is the exception? Or what's the error shown in your IDE (e.g. Eclipse, there should be one!)?

    Maybe you just didn't define the correct constructor that takes a NetherOP-parameter?
     
  5. Offline

    Zaros

    'The constructor NetherOPBlockListener(NetherOP) is undefined"

    Edit: Interesting. after playing with lines in both folders the error eventually went away. I still have no clue what I did to fix it.
     
  6. Then you should just take what it means: In your NetherOPBlockListener-class, you need to define a constructor that takes you plugin as a parameter
    public NetherOPBlockListener(NetherOp plugin){
    // ...
    }
     
  7. Offline

    Zaros

    But it was already specified. I got everything to work, thanks for the help.
     
Thread Status:
Not open for further replies.

Share This Page