onPlayerInteract(): LEFT_CLICK_BLOCK not firing if not Op?

Discussion in 'Plugin Development' started by desht, Jun 9, 2011.

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

    desht

    Hi all, really puzzled by something here.

    I have an onPlayerInteract() handler in my PlayerListener subclass which needs to catch mouse clicks. The handler is called for RIGHT_CLICK_BLOCK, and for LEFT_CLICK_BLOCK if the player is an Op.

    But if the player is not an Op, the handler simply never gets called for left clicks, although it's still called for right-clicks. And it does get called for RIGHT_CLICK_AIR and LEFT_CLICK_AIR. Am I missing something basic here? Is there some reason non-Ops can never left click a block??

    Update: I'm not getting block damage events either when not an Op. And I can't build (even with Permissions 2.7.4 installed and 'build' set to true for my group). Very confused now.

    Update 2: Aha, this only happens when near my spawn point. Does Bukkit just not send these events for non-Ops when they're near their spawn?
     
  2. Offline

    Sethcran

    Do you have spawn protection enabled on your server? This may override these events in that area.
     
  3. Offline

    desht

    Ahh, that's it. Thanks :)

    It does seem strange though, that I don't even get a player interaction event for left-clicking a block. I can understand preventing any block damage inside the spawn protection radius, but not letting plugins see this event at all seems a bit weird. Or is there some good reason that I'm missing?
     
  4. Offline

    Sethcran

    Not sure about reasoning, but you could always turn off the spawn protection, and then use some other plugin to protect the area, such as worldguard.
     
  5. Offline

    Daniel Heppner

    It doesn't block the plugins from seeing this event, the event simply doesn't fire. The server doesn't restore the destroyed block after someone destroys it, it simply doesn't get destroyed.
     
  6. Offline

    desht

    Right, I understand that. What I don't understand is the rationale behind why the event doesn't fire at all ("the event" being PLAYER_INTERACT if a block is left-clicked).
     
  7. Offline

    Daniel Heppner

    Ah, okay. :)
    I'd like to know about this too.
     
  8. Offline

    chronopolis

    The server doesn't see the player as "interacting" with the block because it is protected (and thus cant be damaged, or left clicked). The animations you see are actually the client predicting what will happen...the block "regenerating" is the server correcting the client.
     
  9. Offline

    desht

    But BLOCK_DAMAGE and PLAYER_INTERACT are two different events. Normally both will fire if you left-click a block, but inside the spawn-protect area, neither event fires. My point is that PLAYER_INTERACT should still fire even if BLOCK_DAMAGE doesn't. Why not allow plugins to know if a block has been left-clicked, even if the block cannot be damaged?
     
  10. Offline

    chronopolis

    Good point...I was probably wrong.
     
Thread Status:
Not open for further replies.

Share This Page