Java 类org.bukkit.block.Hopper 实例源码

项目:Kineticraft    文件:Dungeons.java   
@EventHandler(ignoreCancelled = true) // Handles special items entering hoppers.
public void onHopperPickup(InventoryPickupItemEvent evt) {
    if (!(evt.getInventory().getHolder() instanceof Hopper))
        return; // Verify the inventory the item is going to enter is a hopper.

    Hopper hp = (Hopper) evt.getInventory().getHolder();
    Matcher mName = Pattern.compile("<Custom ID: (\\w+)>").matcher(hp.getInventory().getName());
    if (!mName.find())
        return; // If it doesn't have a Custom item ID defined, don't handle it.

    ItemWrapper iw = ItemManager.constructItem(evt.getItem().getItemStack());
    evt.setCancelled(true);

    if (mName.group(1).equalsIgnoreCase(iw.getTagString("id"))) { // We've found the right item! Consume it.
        evt.getItem().remove();
        hp.getBlock().getRelative(BlockFace.DOWN).setType(Material.REDSTONE_BLOCK);
    } else { // This item isn't acceptable, spit it back out.
        evt.getItem().setVelocity(new Vector(0, .15F, 0));
    }
}
项目:ExilePearl    文件:PlayerListener.java   
/**
 * Updates the pearl holder
 * @param pearl The pearl to update
 * @param holder The pearl holder
 * @param event The event
 */
private void updatePearlHolder(ExilePearl pearl, InventoryHolder holder, Cancellable event) {

    if (holder instanceof Chest) {
        updatePearl(pearl, (Chest)holder);
    } else if (holder instanceof DoubleChest) {
        updatePearl(pearl, (Chest) ((DoubleChest) holder).getLeftSide());
    } else if (holder instanceof Furnace) {
        updatePearl(pearl, (Furnace) holder);
    } else if (holder instanceof Dispenser) {
        updatePearl(pearl, (Dispenser) holder);
    } else if (holder instanceof Dropper) {
        updatePearl(pearl, (Dropper) holder);
    } else if (holder instanceof Hopper) {
        updatePearl(pearl, (Hopper) holder);
    } else if (holder instanceof BrewingStand) {
        updatePearl(pearl, (BrewingStand) holder);
    } else if (holder instanceof Player) {
        updatePearl(pearl, (Player) holder);
    }else {
        event.setCancelled(true);
    }
}
项目:SortingHopper    文件:BreakListener.java   
@EventHandler
public void onBlockBreak(BlockBreakEvent event){
    if(event.getPlayer().getGameMode() == GameMode.CREATIVE){
        return;
    }
    if (event.getBlock().getType() == Material.HOPPER){
        Hopper hopper = (Hopper)event.getBlock().getState();

        if(plugin.checkNames(hopper.getInventory().getName())){
            ItemStack drop = plugin.getItem();

            //Looks hacky
            event.setCancelled(true);
            event.getBlock().setType(Material.AIR);
            event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), drop);

            //-- Not working. Why?
            //event.getBlock().getDrops().clear();
            //event.getBlock().getDrops().add(drop);

        }
    }  
}
项目:SyncChest    文件:SyncHopper.java   
public SyncHopper(String hopperPath, int ID, Location hopperLoc, Location source, Location dest) {
this.hopperFile = new File(hopperPath + File.separator + ID + ".yml");
this.hopperConfig = YamlConfiguration.loadConfiguration(this.hopperFile);

this.HopperID = ID;
this.hopperLoc = hopperLoc.clone();

this.hopper = (Hopper) hopperLoc.getBlock().getState();

this.sourceLoc = source.clone();
this.destLoc = dest.clone();

if (this.destLoc.getWorld() != null && this.sourceLoc.getWorld() != null) {
    this.source = SyncManager.getManager().getInventory(this.sourceLoc);
}

this.inUse = false;
this.item = null;
save();
   }
项目:SyncChest    文件:SyncHopper.java   
public SyncHopper(File hopperFile) {
this.hopperFile = hopperFile;
this.hopperConfig = YamlConfiguration.loadConfiguration(this.hopperFile);

this.HopperID = this.hopperConfig.getInt("config.Hopper.ID");

this.hopperLoc = new Location(Bukkit.getWorld(UUID.fromString(this.hopperConfig.getString("config.Hopper.Location.world"))), this.hopperConfig.getInt("config.Hopper.Location.X"), this.hopperConfig.getInt("config.Hopper.Location.Y"), this.hopperConfig.getInt("config.Hopper.Location.Z"));
this.destLoc = new Location(Bukkit.getWorld(UUID.fromString(this.hopperConfig.getString("config.Hopper.Location.Destination.world"))), this.hopperConfig.getInt("config.Hopper.Location.Destination.X"), this.hopperConfig.getInt("config.Hopper.Location.Destination.Y"), this.hopperConfig.getInt("config.Hopper.Location.Destination.Z"));
this.sourceLoc = new Location(Bukkit.getWorld(UUID.fromString(this.hopperConfig.getString("config.Hopper.Location.Source.world"))), this.hopperConfig.getInt("config.Hopper.Location.Source.X"), this.hopperConfig.getInt("config.Hopper.Location.Source.Y"), this.hopperConfig.getInt("config.Hopper.Location.Source.Z"));

if (this.hopperLoc.getWorld() != null) {
    this.hopper = (Hopper) this.hopperLoc.getBlock().getState();
}

if (this.sourceLoc.getWorld() != null) {
    this.source = SyncManager.getManager().getInventory(this.sourceLoc);
}

   }
项目:sensibletoolbox    文件:FurnaceListener.java   
@EventHandler
public void onFurnaceInsertHopper(InventoryMoveItemEvent event) {
    if (event.getDestination().getType() != InventoryType.FURNACE) {
        return;
    }

    if (event.getSource().getHolder() instanceof Hopper) {
        Block b1 = ((BlockState) event.getSource().getHolder()).getBlock();
        Block b2 = ((BlockState) event.getDestination().getHolder()).getBlock();
        if (b1.getY() == b2.getY() + 1) {
            // hopper above the furnace - trying to insert items to be smelted
            if (!validateSmeltingIngredient(event.getItem())) {
                event.setCancelled(true);
            }
        }
    }
}
项目:NeverLag    文件:WorldInfo.java   
public WorldInfo(World world) {
    this.worldName = world.getName();
    this.totalOnline = world.getPlayers().size();
    for (Entity entity : world.getEntities()) {
        this.totalEntity++;
        if (entity instanceof Animals) {
            this.totalAnimals++;
        } else if (entity instanceof Monster) {
            this.totalMonsters++;
        } else if (entity instanceof Item) {
            this.totalDropItem++;
        }
    }
    for (Chunk loadedChunk : world.getLoadedChunks()) {
        this.totalChunk++;
        for (BlockState tiles : loadedChunk.getTileEntities()) {
            this.totalTiles++;
            if (tiles instanceof Hopper) {
                this.totalHopper++;
            } else if (tiles instanceof Chest) {
                this.totalChest++;
            } else if (tiles instanceof Dispenser) {
                this.totalDispenser++;
            } else if (tiles instanceof Dropper) {
                this.totalDropper++;
            } else if (tiles instanceof BrewingStand) {
                this.totalBrewingStand++;
            }
        }

    }
}
项目:NeverLag    文件:AntiNetherHopper.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onHopper(InventoryMoveItemEvent e) {
    if (cm.isAntiNetherHopper) {
        if (e.getInitiator().getHolder() instanceof Hopper) {
            Hopper hopper = (Hopper) e.getInitiator().getHolder();
            if (hopper.getWorld().getEnvironment() == World.Environment.NETHER) {
                e.setCancelled(true);
            }
        }
    }
}
项目:civcraft    文件:WarRegen.java   
public static void destroyThisBlock(Block blk, Town town) {

    WarRegen.saveBlock(blk, town.getName(), false);

    switch (blk.getType()) {
    case TRAPPED_CHEST:
        ((Chest)blk.getState()).getBlockInventory().clear();
        break;
    case CHEST:
        ((Chest)blk.getState()).getBlockInventory().clear();
        break;
    case DISPENSER:
        ((Dispenser)blk.getState()).getInventory().clear();
        break;
    case BURNING_FURNACE:
    case FURNACE:
        ((Furnace)blk.getState()).getInventory().clear();
        break;
    case DROPPER:
        ((Dropper)blk.getState()).getInventory().clear();
        break;
    case HOPPER:
        ((Hopper)blk.getState()).getInventory().clear();
        break;
    default:
        break;
    }

    ItemManager.setTypeId(blk, CivData.AIR);
    ItemManager.setData(blk, 0x0, true);

}
项目:Slimefun4    文件:ItemListener.java   
/**
 * Listens to InventoryMoveItemEvent to handle IGNITION_CHAMBER.
 * @param e InventoryMoveItemEvent
 * @since 4.1.11
 */
@EventHandler
public void onIgnitionChamberItemMove(InventoryMoveItemEvent e) {
    if (e.getInitiator().getHolder() instanceof Hopper) {
        if (BlockStorage.check(((Hopper) e.getInitiator().getHolder()).getBlock(), "IGNITION_CHAMBER")) {
            e.setCancelled(true);
        }
    }
}
项目:Bukkit-EnderEnhance    文件:EnderListener.java   
private Block getHopperBlock(Hopper h) {
    int i = h.getData().toString().charAt(7) - '0';
    if (i <= 5) {
        return h.getBlock().getRelative(hopperMap[i]);
    } else {
        //Something strange happened, I keep getting the number 8  when I look inside a chest above a hopper?
        return h.getBlock();
    }
}
项目:acidisland    文件:Island.java   
/**
 * @return number of hoppers on the island
 */
public int getHopperCount() {
    tileEntityCount.clear();
    int result = 0; 
    for (int x = getMinProtectedX() /16; x <= (getMinProtectedX() + getProtectionSize() - 1)/16; x++) {
        for (int z = getMinProtectedZ() /16; z <= (getMinProtectedZ() + getProtectionSize() - 1)/16; z++) {
            for (BlockState holder : world.getChunkAt(x, z).getTileEntities()) {
                if (holder instanceof Hopper && onIsland(holder.getLocation())) {
                    result++;
                }
            }
        }  
    }
    return result;
}
项目:SyncChest    文件:SyncManager.java   
public SyncHopper getHopper(Inventory inventory) {

if (inventory.getHolder() != null && inventory.getHolder() instanceof Hopper) {
    if (getHopper(((Hopper) inventory.getHolder()).getLocation()) != null) {
    return getHopper(((Hopper) inventory.getHolder()).getLocation());
    }
}
return null;
   }
项目:askyblock    文件:Island.java   
/**
 * @return number of hoppers on the island
 */
public int getHopperCount() {
    tileEntityCount.clear();
    int result = 0; 
    for (int x = getMinProtectedX() /16; x <= (getMinProtectedX() + getProtectionSize() - 1)/16; x++) {
        for (int z = getMinProtectedZ() /16; z <= (getMinProtectedZ() + getProtectionSize() - 1)/16; z++) {
            for (BlockState holder : world.getChunkAt(x, z).getTileEntities()) {
                if (holder instanceof Hopper && onIsland(holder.getLocation())) {
                    result++;
                }
            }
        }  
    }
    return result;
}
项目:HopperFilterSimplified    文件:HfsBlockListener.java   
/** 
 * Event handler to watch whenever a container tries to move an item to another container.
 * Hoppers for example are the only thing that triggers this so far.
 * If the item being moved is not allowed in the destination container, then the event will be canceled to prevent the move.
 *
 *  @param event InventoryMoveItemEvent containing data about the event given by the system. We care about hoppers being the receiving end of the transfer.
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
    //Get destination container
    InventoryHolder destHolder = event.getDestination().getHolder();

    //since we only care about hoppers, then ignore everything else
    if (destHolder instanceof Hopper) {
        //Get the location of the hopper in question.  
        Block hopperBlock = ((Hopper) destHolder).getBlock();

        //Get the cache, if any, for the hopper location.
        String cache = plugin.knownHoppersCache_Get(hopperBlock);

        //get the itemStack that was moved and convert it to a String for comparison
        String eventItemInformation = plugin.GetItemInformationForInventory(event.getItem(), false);

        //debug if requested
        if (plugin.debugLevel_get() > 0) plugin.getLogger().info("Testing item (" + eventItemInformation + ") in hopper (" + hopperBlock.getLocation().toString() + ") against allowed:" + cache);

        //do the actual filtering
        if (cache.length() > 0)
            //we have a cache to compare against
            if (!cache.contains(eventItemInformation))
                //the item is not allowed in the hopper
                event.setCancelled(true);
    }
}
项目:Slimefun4-Chinese-Version    文件:ItemListener.java   
@EventHandler
public void onIgnitionChamberItemMove(InventoryMoveItemEvent e) {
    if(BlockStorage.check(((Hopper) e.getInitiator().getHolder()).getBlock(), "IGNITION_CHAMBER")) {
        e.setCancelled(true);
    }
}
项目:ExilePearl    文件:ExileListenerTest.java   
@Test
public void testOnInventoryMoveTnt() {
    when(player.getGameMode()).thenReturn(GameMode.SURVIVAL);
    ItemStack item = new ItemStack(Material.TNT, 1);


    Inventory top = mock(Inventory.class);
    when(top.getHolder()).thenReturn(mock(Dropper.class));
    when(top.getSize()).thenReturn(9);

    Inventory bottom = mock(Inventory.class);
    when(bottom.getHolder()).thenReturn(mock(Player.class));
    when(bottom.getSize()).thenReturn(45);

    InventoryView view = mock(InventoryView.class);
    when(view.getPlayer()).thenReturn(player);
    when(view.getTopInventory()).thenReturn(top);
    when(view.getBottomInventory()).thenReturn(bottom);
    when(view.getCursor()).thenReturn(item);
    when(view.getItem(eq(5))).thenReturn(item);
    when(view.getItem(eq(40))).thenReturn(item);

    InventoryClickEvent e = new InventoryClickEvent(view, null, 5, ClickType.LEFT, InventoryAction.PLACE_SOME);
    when(config.canPerform(ExileRule.PLACE_TNT)).thenReturn(true);
    dut.onInventoryClick(e);
    assertFalse(e.isCancelled());

    e = new InventoryClickEvent(view, null, 5, ClickType.LEFT, InventoryAction.PLACE_SOME);
    when(config.canPerform(ExileRule.PLACE_TNT)).thenReturn(false);
    dut.onInventoryClick(e);
    assertFalse(e.isCancelled());

    e = new InventoryClickEvent(view, null, 5, ClickType.LEFT, InventoryAction.PLACE_SOME);
    when(config.canPerform(ExileRule.PLACE_TNT)).thenReturn(true);
    when(pearlApi.isPlayerExiled(uid)).thenReturn(true);
    dut.onInventoryClick(e);
    assertFalse(e.isCancelled());

    e = new InventoryClickEvent(view, null, 5, ClickType.LEFT, InventoryAction.PLACE_SOME);
    when(config.canPerform(ExileRule.PLACE_TNT)).thenReturn(false);
    dut.onInventoryClick(e);
    assertTrue(e.isCancelled());

    e = new InventoryClickEvent(view, null, 5, ClickType.LEFT, InventoryAction.PLACE_SOME);
    when(top.getHolder()).thenReturn(mock(Chest.class));
    dut.onInventoryClick(e);
    assertFalse(e.isCancelled());

    e = new InventoryClickEvent(view, null, 5, ClickType.LEFT, InventoryAction.PLACE_ALL);
    when(top.getHolder()).thenReturn(mock(Hopper.class));
    dut.onInventoryClick(e);
    assertTrue(e.isCancelled());

    e = new InventoryClickEvent(view, null, 5, ClickType.LEFT, InventoryAction.PLACE_ONE);
    when(top.getHolder()).thenReturn(mock(Dispenser.class));
    dut.onInventoryClick(e);
    assertTrue(e.isCancelled());

    e = new InventoryClickEvent(view, null, 5, ClickType.SHIFT_LEFT, InventoryAction.MOVE_TO_OTHER_INVENTORY);
    dut.onInventoryClick(e);
    assertFalse(e.isCancelled());

    e = new InventoryClickEvent(view, null, 40, ClickType.LEFT, InventoryAction.PLACE_SOME);
    dut.onInventoryClick(e);
    assertFalse(e.isCancelled());

    e = new InventoryClickEvent(view, null, 40, ClickType.SHIFT_LEFT, InventoryAction.MOVE_TO_OTHER_INVENTORY);
    when(view.getType()).thenReturn(InventoryType.DISPENSER);
    assertEquals(e.getCurrentItem(), item);
    dut.onInventoryClick(e);
    assertTrue(e.isCancelled());

}
项目:civcraft    文件:WarRegen.java   
private static String blockToString(Block blk, boolean save_as_air) {
    if (save_as_air) { 
        return blockAsAir(blk);
    }
    else {
        String str = blockBasicString(blk);

        Inventory inv = null;
        switch (blk.getType()) {
        case TRAPPED_CHEST:
        case CHEST:
            inv = ((Chest)blk.getState()).getBlockInventory();
            str += blockInventoryString(inv);
            break;
        case DISPENSER:
            inv = ((Dispenser)blk.getState()).getInventory();
            str += blockInventoryString(inv);
            break;
        case BURNING_FURNACE:
        case FURNACE:
            inv = ((Furnace)blk.getState()).getInventory();
            str += blockInventoryString(inv);
            break;
        case DROPPER:
            inv = ((Dropper)blk.getState()).getInventory();
            str += blockInventoryString(inv);
            break;
        case HOPPER:
            inv = ((Hopper)blk.getState()).getInventory();
            str += blockInventoryString(inv);
            break;
        case SIGN:
        case SIGN_POST:
        case WALL_SIGN:
            Sign sign = (Sign)blk.getState();
            str += blockSignString(sign);
            break;
        default:
            break;
        }

        return str;
    }
}
项目:civcraft    文件:WarRegen.java   
private static void restoreBlockFromString(String line) {
    String[] split = line.split(":");

    int type = Integer.valueOf(split[0]);
    byte data = Byte.valueOf(split[1]);
    int x = Integer.valueOf(split[2]);
    int y = Integer.valueOf(split[3]);
    int z = Integer.valueOf(split[4]);
    String world = split[5];

    Block block = BukkitObjects.getWorld(world).getBlockAt(x,y,z);

    ItemManager.setTypeId(block, type);
    ItemManager.setData(block, data, false);

    // End of basic block info, try to get more now.
    Inventory inv = null;
    switch (block.getType()) {
    case TRAPPED_CHEST:
        inv = ((Chest)block.getState()).getBlockInventory();
        InventorySerializer.StringToInventory(inv, split[6]);
        break;
    case CHEST:
        inv = ((Chest)block.getState()).getBlockInventory();
        InventorySerializer.StringToInventory(inv, split[6]);
        break;
    case DISPENSER:         
        inv = ((Dispenser)block.getState()).getInventory();
        InventorySerializer.StringToInventory(inv, split[6]);
        break;
    case BURNING_FURNACE:
    case FURNACE:
        inv = ((Furnace)block.getState()).getInventory();
        InventorySerializer.StringToInventory(inv, split[6]);
        break;
    case DROPPER:
        inv = ((Dropper)block.getState()).getInventory();
        InventorySerializer.StringToInventory(inv, split[6]);
        break;
    case HOPPER:
        inv = ((Hopper)block.getState()).getInventory();
        InventorySerializer.StringToInventory(inv, split[6]);
        break;
    case SIGN:
    case SIGN_POST:
    case WALL_SIGN:
        Sign sign = (Sign)block.getState();
        String[] messages = split[6].split(",");
        for (int i = 0; i < 4; i++) {
            if (messages[i] != null) {
                sign.setLine(i, messages[i]);
            }
        }
        sign.update();
        break;
    default:
        break;
    }


}
项目:SyncChest    文件:BlockBreakListener.java   
@EventHandler
   public void onBlockBreak(BlockBreakEvent event) {

Player eventPlayer = event.getPlayer();
MessageManager msg = MessageManager.getManager();

if (event.getPlayer().getItemInHand() != null) {
    if (event.getPlayer().getItemInHand().equals(SyncChest.connector)) {
    event.setCancelled(true);
    return;
    }
}

if (event.getBlock().getState() instanceof Chest) {
    Chest chest = (Chest) event.getBlock().getState();

    if (chest.getInventory().getTitle().contains("MainChest") || chest.getInventory().getTitle().contains("RelatedChest")) {
    if (eventPlayer.hasPermission("sc.remove")) {
        boolean success = false;

        if (chest.getInventory().getTitle().contains("MainChest")) {
        success = SyncManager.getManager().removeChest(ChestType.MAIN, event.getBlock().getLocation());
        } else if (chest.getInventory().getTitle().contains("RelatedChest")) {
        success = SyncManager.getManager().removeChest(ChestType.RELATED, event.getBlock().getLocation());
        }

        if (success) {
        eventPlayer.sendMessage(msg.get_CHEST_REMOVED());
        } else {
        eventPlayer.sendMessage(msg.ERROR_CHEST_REMOVE());
        }
        return;
    } else {
        eventPlayer.sendMessage(msg.ERROR_NO_PERMISSIONS());
        event.setCancelled(true);
        return;
    }
    }
}

if (event.getBlock().getState() instanceof Hopper) {
    if (SyncManager.getManager().getHopper(event.getBlock().getLocation()) != null) {
    if (eventPlayer.hasPermission("sc.remove")) {
        if (SyncManager.getManager().removeHopper(event.getBlock().getLocation()) == true) {
        eventPlayer.sendMessage(msg.get_HOPPER_REMOVED());
        return;
        } else {
        eventPlayer.sendMessage(msg.ERROR_HOPPER_REMOVE());
        return;
        }
    } else {
        eventPlayer.sendMessage(msg.ERROR_NO_PERMISSIONS());
        event.setCancelled(true);
        return;
    }
    }
}
   }
项目:SyncChest    文件:SyncHopper.java   
public Hopper getHopper() {
return this.hopper;
   }
项目:CardinalPGM    文件:ObserverModule.java   
@EventHandler
public void onInteraction(PlayerInteractEvent event) {
    if (testObserver(event.getPlayer())) {
        event.setCancelled(true);
        if ((event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) && (event.getPlayer().getInventory().getItemInMainHand() != null && event.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.WRITTEN_BOOK))){
            event.setUseInteractedBlock(Event.Result.DENY);
            event.setUseItemInHand(Event.Result.ALLOW);
        }
        if (event.getClickedBlock() != null && !event.getPlayer().isSneaking() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if (event.getClickedBlock().getType().equals(Material.CHEST) || event.getClickedBlock().getType().equals(Material.TRAPPED_CHEST)) {
                Inventory chest = Bukkit.createInventory(null, ((Chest) event.getClickedBlock().getState()).getInventory().getSize());
                for (int i = 0; i < ((Chest) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    chest.setItem(i, ((Chest) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(chest);
            }
            if (event.getClickedBlock().getType().equals(Material.FURNACE) || event.getClickedBlock().getType().equals(Material.BURNING_FURNACE)) {
                Inventory furnace = Bukkit.createInventory(null, InventoryType.FURNACE);
                for (int i = 0; i < ((Furnace) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    furnace.setItem(i, ((Furnace) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(furnace);
            }
            if (event.getClickedBlock().getType().equals(Material.DISPENSER)) {
                Inventory dispenser = Bukkit.createInventory(null, InventoryType.DISPENSER);
                for (int i = 0; i < ((Dispenser) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    dispenser.setItem(i, ((Dispenser) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(dispenser);
            }
            if (event.getClickedBlock().getType().equals(Material.DROPPER)) {
                Inventory dropper = Bukkit.createInventory(null, InventoryType.DROPPER);
                for (int i = 0; i < ((Dropper) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    dropper.setItem(i, ((Dropper) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(dropper);
            }
            if (event.getClickedBlock().getType().equals(Material.HOPPER)) {
                Inventory hopper = Bukkit.createInventory(null, InventoryType.HOPPER);
                for (int i = 0; i < ((Hopper) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    hopper.setItem(i, ((Hopper) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(hopper);
            }
            if (event.getClickedBlock().getType().equals(Material.BREWING_STAND)) {
                Inventory brewingStand = Bukkit.createInventory(null, InventoryType.BREWING);
                for (int i = 0; i < ((BrewingStand) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    brewingStand.setItem(i, ((BrewingStand) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(brewingStand);
            }
            if (event.getClickedBlock().getType().equals(Material.BEACON)) {
                Inventory beacon = Bukkit.createInventory(null, InventoryType.BEACON);
                for (int i = 0; i < ((Beacon) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    beacon.setItem(i, ((Beacon) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(beacon);
            }
        }
    }
}