org.bukkit.block.BrewingStand Java Examples

The following examples show how to use org.bukkit.block.BrewingStand. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BrewingStandContainer.java    From Transport-Pipes with MIT License 6 votes vote down vote up
@Override
public ItemStack extractItem(TPDirection extractDirection, int amount, ItemFilter itemFilter) {
    if (!isInLoadedChunk()) {
        return null;
    }
    if (isInvLocked(cachedBrewingStand)) {
        return null;
    }
    if (extractDirection != TPDirection.DOWN && ((BrewingStand) block.getState()).getBrewingTime() == 0) {
        ItemStack takeItem = null;
        if (itemFilter.applyFilter(cachedInv.getItem(0)) > 0) {
            takeItem = cachedInv.getItem(0);
            cachedInv.setItem(0, null);
        } else if (itemFilter.applyFilter(cachedInv.getItem(1)) > 0) {
            takeItem = cachedInv.getItem(1);
            cachedInv.setItem(1, null);
        } else if (itemFilter.applyFilter(cachedInv.getItem(2)) > 0) {
            takeItem = cachedInv.getItem(2);
            cachedInv.setItem(2, null);
        }
        if (takeItem != null) {
            return takeItem;
        }
    }
    return null;
}
 
Example #2
Source File: TPContainerListener.java    From Transport-Pipes with MIT License 5 votes vote down vote up
public TransportPipesContainer createContainerFromBlock(Block block) {
    if (block.getState() instanceof Furnace) {
        return new FurnaceContainer(block);
    } else if (block.getState() instanceof BrewingStand) {
        return new BrewingStandContainer(block);
    } else if (block.getState() instanceof InventoryHolder) {
        return new SimpleInventoryContainer(block);
    }
    return null;
}
 
Example #3
Source File: ItemsListener.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onHopperEvent(InventoryMoveItemEvent event) {
	Inventory inv = event.getDestination();
	if(inv.getType().equals(InventoryType.BREWING) && GameManager.getGameManager().getConfiguration().getBanLevelTwoPotions() && inv.getHolder() instanceof BrewingStand){
		Bukkit.getScheduler().runTaskLater(UhcCore.getPlugin(), new CheckBrewingStandAfterClick((BrewingStand) inv.getHolder(), null),1);
	}
	
}
 
Example #4
Source File: BrewObjective.java    From BetonQuest with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onIngredientPut(InventoryClickEvent event) {
    if (event.getInventory().getType() != InventoryType.BREWING)
        return;
    if (event.getRawSlot() == 3 || event.getClick().equals(ClickType.SHIFT_LEFT)) {
        String playerID = PlayerConverter.getID((Player) event.getWhoClicked());
        if (!containsPlayer(playerID))
            return;
        locations.put(((BrewingStand) event.getInventory().getHolder()).getLocation(), playerID);
    }
}
 
Example #5
Source File: VanillaMachinesListener.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPreBrew(InventoryClickEvent e) {
    Inventory inventory = e.getInventory();

    if (inventory.getType() == InventoryType.BREWING && e.getRawSlot() < inventory.getSize() && inventory.getHolder() instanceof BrewingStand) {
        e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCursor())));
    }
}
 
Example #6
Source File: TestVanillaMachinesListener.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
private InventoryClickEvent mockBrewingEvent(ItemStack item) {
    Player player = server.addPlayer();
    Inventory inv = TestUtilities.mockInventory(InventoryType.BREWING);
    Mockito.when(inv.getHolder()).thenReturn(Mockito.mock(BrewingStand.class));
    Mockito.when(inv.getSize()).thenReturn(5);

    InventoryView view = player.openInventory(inv);
    view.setCursor(item);
    InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 1, ClickType.LEFT, InventoryAction.PICKUP_ONE);
    listener.onPreBrew(event);
    return event;
}
 
Example #7
Source File: CraftInventoryBrewer.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
 
Example #8
Source File: BrewingStandContainer.java    From Transport-Pipes with MIT License 4 votes vote down vote up
public BrewingStandContainer(Block block) {
    super(block);
    this.chunk = block.getChunk();
    this.cachedBrewingStand = (BrewingStand) block.getState();
    this.cachedInv = cachedBrewingStand.getInventory();
}
 
Example #9
Source File: BrewingStandContainer.java    From Transport-Pipes with MIT License 4 votes vote down vote up
@Override
public void updateBlock() {
    this.cachedBrewingStand = ((BrewingStand) block.getState());
    this.cachedInv = cachedBrewingStand.getInventory();
}
 
Example #10
Source File: ItemsListener.java    From UhcCore with GNU General Public License v3.0 4 votes vote down vote up
private CheckBrewingStandAfterClick(BrewingStand stand, HumanEntity human) {
	this.stand = stand;
	this.human = human;
}
 
Example #11
Source File: CraftInventoryBrewer.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BrewingStand getHolder() {
    return (BrewingStand) inventory.getOwner();
}
 
Example #12
Source File: ObserverModule.java    From CardinalPGM with MIT License 4 votes vote down vote up
@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);
            }
        }
    }
}
 
Example #13
Source File: BrewerInventory.java    From Kettle with GNU General Public License v3.0 votes vote down vote up
BrewingStand getHolder();