Registering Events

Discussion in 'Plugin Development' started by ryryanator, Jun 17, 2014.

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


    So I already had some trouble with this, and now I'm having more problems. I'm unable to register my events that are in a different class. I already read a bunch of threads about it and it still doesn't make sense to me. All I know is I have to do something like this in my onEnable...
    1. PluginManager pm = getServer().getPluginManager();
    2. pm.registerEvents(new NoviceClick(), this);

    With NoviceClick being the class with the EventHandler. Could someone help clarify this for me?
  2. Offline


    Are you getting any errors... or..?
  3. Offline


    No. Its just not doing the event I have in the event handler. Here is my NoviceClick class.
    public class NoviceClick implements Listener{
        public static Inventory noviceInventory = Bukkit.createInventory(null, 9, "Novice Wand Spells");
        static {
            ItemStack NM1 = new ItemStack(Material.FIRE);
            ItemMeta meta = NM1.getItemMeta();
            meta.setDisplayName("Fire Spell");
            ArrayList<String> NL1 = new ArrayList<String>();
            NL1.add("Activates The Fire Spell");
            noviceInventory.setItem(0, new ItemStack(NM1));
        public static Main plugin;
        public void onRightClick(PlayerInteractEvent e) {
            final Player p = e.getPlayer();
            if ((e.getAction().equals(Action.RIGHT_CLICK_AIR)) || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK))) {
              if (p.getInventory().getItemInHand().equals(ChatColor.YELLOW + "Novice Wand")){
                  p.sendMessage(ChatColor.AQUA + "Wand Activated!");
    Is it something with this class?

    Can anyone help me?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 8, 2016
  4. Offline


    Try doing a System.out.println("Test #1"); right before your final Player p in your onRightClick method. Then interact with something in game and check the console.
  5. Offline


    Do this:
    1. Bukkit.getserver().getPluginMangaer().registerEvents(new NoviceClick, this);
Thread Status:
Not open for further replies.

Share This Page