Is there a better way to recognize a door event?

Discussion in 'Plugin Development' started by mirogon, Jan 17, 2019.

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

    mirogon

    Code:
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent e)
    {
       if(e.getClickedBlock().getType() == Material.ACACIA_DOOR
       ||e.getClickedBlock().getType() == Material.BIRCH_DOOR
       || e.getClickedBlock().getType() == Material.DARK_OAK_DOOR
       || e.getClickedBlock().getType() == Material.IRON_DOOR
       || e.getClickedBlock().getType() == Material.JUNGLE_DOOR
       || e.getClickedBlock().getType() == Material.OAK_DOOR
       || e.getClickedBlock().getType() == Material.SPRUCE_DOOR)
       {
         //DoorEvent
       }
    }
    
     
  2. Offline

    timtower Administrator Administrator Moderator

    @mirogon e.getClickedBlock().getState() instanceof Door
     
  3. Offline

    mirogon

    I tried that, it didn't recognize it, when I right clicked a door.
     
  4. Offline

    timtower Administrator Administrator Moderator

    What Door class did you import?
     
  5. Offline

    mirogon

    Oh, good point. I didn't think about that, thanks!

    I used the eclipse auto-import function and it imported the wrong one ^^

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 17, 2019
  6. Offline

    timtower Administrator Administrator Moderator

    Auto imports are tricky with Bukkit, always check it.
     
Thread Status:
Not open for further replies.

Share This Page