Solved Block chest interacting except breaking

Discussion in 'Spigot Plugin Development' started by Kompye, Sep 11, 2019.

  1. I am working on a plugin that simply blocks opening chests. The problem is that the players cannot break the blocks because I am checking for interacting with the chest when cancelling the action. How can I check if the player is trying to break it or maybe left click it? Here is my code:
    Code (Text):
        public void onInventoryOpen(PlayerInteractEvent e) {
            Player p = (Player) e.getPlayer();
            if(mainClass.getConfig().getBoolean("chest") == true) {
            if(e.getClickedBlock().getType() == Material.CHEST){
  2. Get the Action and check if it's a RIGHT_CLICK_BLOCK action. Then you will know that the player tried to right click the block.
  3. Thanks!