title: How to Make the Inventory Uneditable like Shops?
body: <p>I am quite new to Spigot plugin development. I was trying to create a shop plugin which most of the Minecraft servers have.</p>
  <pre class="lang-java prettyprint-override"><code>import org.bukkit.event.inventory.InventoryClickEvent;
  import org.bukkit.inventory.Inventory;
  import org.bukkit.inventory.ItemStack;
  
  public class Commands implements CommandExecutor {
  
  
      @Override
      public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
  
          Player player = (Player) commandSender;
          if( commandSender instanceof Player)
          {
              if(command.getName().equals(&quot;shop&quot;))
              {
                  Inventory shop = Bukkit.createInventory(player,27,&quot;Shop&quot;);
  
  
                  ItemStack unused = new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE , 1);
  
                  ItemStack Wood = new ItemStack(Material.OAK_LOG , 1);
                  ItemStack Food = new ItemStack(Material.PORKCHOP , 1);
                  ItemStack Stone = new ItemStack(Material.STONE , 1);
                  ItemStack Tools = new ItemStack(Material.IRON_PICKAXE , 1);
                  ItemStack Redstone = new ItemStack(Material.REDSTONE_BLOCK , 1);
  
                  shop.setItem(11,Redstone);
                  shop.setItem(12,Wood);
                  shop.setItem(13,Stone);
                  shop.setItem(14,Food);
                  shop.setItem(15,Tools);
  
                  for(int i = 0; i &lt; 27;i++)
                  {
                      if((i &gt;= 0 &amp;&amp; i&lt;=10) || (i &gt;=16 &amp;&amp; i&lt;=26))
                      {
                          shop.setItem(i,unused);
                      }
                  }
  
                  player.openInventory(shop);
  
              }
  
          }
          else
          {
              player.sendMessage(ChatColor.GRAY + &quot;Only a Player can Execute the Command.&quot;);
          }
  
          return true;
      }
  
      @EventHandler
      public void onInventoryShopClick(InventoryClickEvent e)
      {
          
      }
  }
  </code></pre>
  <p>I'm not able to get a solution to make the shop object of class Inventory uneditable, which is a local variable in function <code>onCommand()</code>. I want it so that if a player clicks on an object in the inventory, <code>event.setCancelled(true)</code> happens.</p>
  <p>I am sorry if this is a stupid question but I only know how to manipulate events using the <code>InventoryClickEvent</code> in a separate function.</p>