Hide Player Functionality

Discussion in 'Spigot Plugin Development' started by Bladian, Jun 18, 2015.

  1. Okay, thanks for the code. But what if I need to open the Brewing Stand inventory with the same contents.

    Basically, I open the inventory, cancel the event, open a new inventory with the same contents.
     
  2. Now that I think about it may be a lot easier using a player interact event and checking if the player clicks the inventory.
     
  3. sothatsit

    Patron

    Use the same checks as above, but when you find, for example, a brewing stand, cancel the event and open your own inventory.

    Code (Text):
    e.setCancelled(true);
    p.openInventory(customInventory);
    Then you also have to add a check to the listener to make sure the inventory that is being opened isn't your custom one.

    You can just add this to the start of the method.

    Code (Text):
    Inventory customInventory = /* get your custom inventory */;
    if(e.getInventory().equals(customInventory)) {
        return;
    }
     
  4. sothatsit

    Patron

    Actually, thinking more on it, you are right. It would be easier to just use the PlayerInteractEvent.

    Just check if it is RIGHT_CLICK_BLOCK, if it is, use the block from e.getClickedBlock() and check if it is a furnace/brewing stand/chest. If it is one of those, open your custom inventory and cancel the event to stop it opening the blocks actual inventory.