Plugin not working right?

Discussion in 'Plugin Development' started by scarabcoder, Jan 3, 2015.

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

    scarabcoder

    EDIT: Solved, I just needed to register the events in the onEnable method.



    I am trying to create a plugin, but for some reason my event code (and possibly more) is not working. Right now, it should not allow players to drop items (just random code that I wrote). But for some reason, this and any other event I write won't register. The onEnable code works fine, but not the event. I have written code before, lots of it in fact, and it worked then. I did get a new computer, so maybe I am doing something wrong. But the last time I wrote a plugin was months ago. Can anyone help with this? Here is my code so far:

    Code:
    package me.scarabcoder.vertoak;
    
    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
    
    
    
    public class Vertoak extends JavaPlugin implements Listener{
        public void onEnable(){
            Bukkit.broadcastMessage("Vertoak Plugin Enabled!");
        }
        @EventHandler
        public void playerRightclick(org.bukkit.event.player.PlayerDropItemEvent e){
            e.setCancelled(true);
        }
    }
    
     
    Last edited: Jan 3, 2015
  2. Offline

    1Rogue

    You didn't register your main class to listen for events:

    Code:java
    1. this.getServer().getPluginManager().registerListener(this, this);
     
  3. Offline

    scarabcoder

    Yes, I just realized that.
    Thanks a lot :)

    I remembered that I was supposed to do something related to events in the onEnable method.
     
Thread Status:
Not open for further replies.

Share This Page