[Solved] PlayerInteractEvent not being thrown? Bukkit 1.2.3-R0.2

Discussion in 'Plugin Development' started by Mitsugaru, Mar 5, 2012.

?

Are you having this issue as well?

  1. Yes

    3 vote(s)
    60.0%
  2. No

    2 vote(s)
    40.0%
  3. Don't care

    0 vote(s)
    0.0%
Thread Status:
Not open for further replies.
  1. Offline

    Mitsugaru

    Ok, is it just me or is the PlayerInteractEvent not being thrown all the time?

    What I am experiencing is that it is working for players who are OP. But for players that are not OP, it only throws it for the right click... Whereas, I would really like to get that left click interaction for non-OP players.

    I'm just asking to see if its something on my end or if other devs have noticed this at all. :\
     
  2. Offline

    Njol

    I use R6, and the event is thrown no matter whether i'm op or not. Do you reject cancelled events? I read that rightclicking air is cancelled from the beginning, so if you ignore cancelled events, you won't see these.
     
  3. Offline

    Mitsugaru

    No, I did the simplest example, to see if the plugin was even getting the event at all:
    Code:
    @EventHandler(priority = EventPriority.NORMAL)
        public void onPlayerInteract(PlayerInteractEvent event) {
                  plugin.getLogger().info(event.getAction());
                  //Plugin specific code afterwards
            }
    }
    And on the 1.2.3 API, it doesn't seem to want to give me the left clicks of normal players... :\

    EDIT: Just tried it with build 1988 with API 1.1-R6, and same thing... IDEK anymore D:

    EDIT 2: To clarify, I am getting the right click event for op and non-op just fine, as I stated in the original post. However, what I am no longer getting is the left click for non-op players. I DO get the left click interact event if a player is op... but I need the left click interact event for non-op players as well.
     
  4. With the latest development build I have no problems with this. Op or not.

    I use left and right click. Also clicking air also returns an action (as long as you're not ignoring the event when it's cancelled.)
     
  5. Offline

    Mitsugaru

    Honestly, at this point, I have no idea what's wrong :\

    I grabbed the latest dev build from dl.bukkit.org, 2037. I wrote up a stub plugin with the following code:
    Code:
    public class PlayerInteractNotify extends JavaPlugin implements Listener{
     
        @Override
        public void onEnable()
        {
            getServer().getPluginManager().registerEvents(this, this);
            getLogger().info("PlayerInteractNotify enabled");
        }
     
        @EventHandler(priority = EventPriority.NORMAL)
        public void onPlayerInteract(PlayerInteractEvent event) {
            getLogger().info("Click: " + event.getAction());
            event.getPlayer().sendMessage("Click: " + event.getAction());
        }
    }
    And it still won't give me the non-OP left click...

    Which of your plugins works? I would like to test it on my server and see if it receives the event properly or not.
     
  6. Offline

    Chiller

    This is why it is a DEV build not a recommended build.
     
  7. Do you have any other plugins running? I don't have any plugin available right now that uses the left click event. What happens if you remove the priority?

    PS: Are you in the spawn area?
     
    Mitsugaru likes this.
  8. Offline

    Mitsugaru

    I was only using that stub plugin.

    And yeah, I was in spawn area :\
    Did not realize that event doesn't get thrown there.
    Alright, thanks for the help. I feel stupid now.
     
  9. Hahaha. I just came up with that. I remembered that when there is spawn protection people couldn't place blocks. So this was probably the same thing. It's still strange that Bukkit doesn't fire the event. It should of course be cancelled, but it would be better to at least fire the event.
     
  10. Offline

    Mitsugaru

    Yeah, that much would be nice... Oh well...
    Still, at least its worked out and not as big of a deal as I had thought it was.
     
  11. Offline

    desht

  12. Offline

    Mitsugaru

  13. Offline

    desht

    No worries, it's a pretty old one...
     
Thread Status:
Not open for further replies.

Share This Page